@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #0f1d2a;
  --muted: #5a6b7b;
  --line: #d6dde5;
  --brand: #0d9488;
  --brand-2: #0f766e;
  --accent: #f59e0b;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0% 0%, rgba(13, 148, 136, 0.18), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(245, 158, 11, 0.14), transparent 45%),
    var(--bg);
  min-height: 100vh;
}

body.nav-open {
  overflow: hidden;
}

body.modal-open {
  overflow: hidden;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
}

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  overflow-x: clip;
}

.sidebar-head {
  display: block;
}

.sidebar {
  background: linear-gradient(165deg, #0f172a 0%, #1f2937 100%);
  color: #e5edf5;
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-nav {
  overflow-y: auto;
  min-height: 0;
}

.sidebar-actions {
  display: none;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(229, 237, 245, 0.14);
}

.sidebar-logout {
  width: 100%;
}

.brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin: 0 0 24px;
}

.menu-toggle,
.menu-close,
.sidebar-backdrop {
  display: none;
}

.menu-toggle {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}

.menu-close {
  border: 1px solid rgba(229, 237, 245, 0.35);
  border-radius: 10px;
  background: transparent;
  color: #e5edf5;
  padding: 6px 10px;
  font-weight: 600;
  cursor: pointer;
}

.nav-link {
  display: block;
  color: #d1d8e0;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  transition: background 180ms ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(13, 148, 136, 0.24);
  color: #ffffff;
}

.main {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-title {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 700;
}

input,
select,
textarea,
button {
  font-family: inherit;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.textarea {
  min-height: 90px;
  resize: vertical;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-new { background: #dbeafe; color: #1e3a8a; }
.badge-contacted { background: #fef3c7; color: #92400e; }
.badge-demo { background: #dcfce7; color: #166534; }
.badge-quotation { background: #ede9fe; color: #5b21b6; }
.badge-followup { background: #ffe4e6; color: #9f1239; }
.badge-negotiation { background: #e0f2fe; color: #075985; }
.badge-order_confirmed { background: #d1fae5; color: #065f46; }
.badge-lost { background: #fee2e2; color: #991b1b; }
.badge-closed { background: #e5e7eb; color: #111827; }

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 10px;
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.form-grid > div {
  min-width: 0;
}

label {
  display: inline-block;
  margin-bottom: 6px;
}

.notice {
  margin-top: 10px;
  font-size: 14px;
}

.notice.ok { color: #166534; }
.notice.err { color: #b91c1c; }

.popup {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  z-index: 1300;
}

.popup.open {
  display: flex;
}

.popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(2px);
}

.popup-dialog {
  position: relative;
  width: min(980px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
}

.popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.popup-close {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
    position: relative;
  }

  .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0;
    width: 82vw;
    max-width: 320px;
    height: 100vh;
    height: 100dvh;
    transform: translate3d(-106%, 0, 0);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 220ms ease, opacity 220ms ease;
    z-index: 1000;
    overflow-y: auto;
  }

  .shell.menu-open .sidebar {
    transform: translate3d(0, 0, 0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .shell.menu-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    z-index: 900;
  }

  .sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
  }

  .brand {
    margin: 0;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer;
  }

  .menu-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(229, 237, 245, 0.35);
    border-radius: 10px;
    background: transparent;
    color: #e5edf5;
    padding: 6px 10px;
    font-weight: 600;
    cursor: pointer;
  }

  .topbar {
    align-items: flex-start;
  }

  .shell.menu-open .menu-toggle {
    visibility: hidden;
  }

  .topbar-title {
    align-items: flex-start;
    width: 100%;
    justify-content: space-between;
  }

  .topbar-logout {
    display: none;
  }

  .sidebar-actions {
    display: block;
  }

  .grid-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .grid-cards,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 14px;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  .menu-toggle {
    padding: 8px 10px;
    font-size: 14px;
  }

  th,
  td {
    white-space: nowrap;
  }

  table {
    min-width: 620px;
  }

  .popup {
    padding: 10px;
    align-items: flex-end;
  }

  .popup-dialog {
    width: 100%;
    max-height: calc(100vh - 20px);
    border-radius: 14px;
    padding: 14px;
  }
}
