/* Nexus Sales — design system. One file, no build step. */
:root {
  --navy: #16213e; --navy-2: #1d2b4f; --navy-3: #2a3a63;
  --brand: #e94560; --brand-ink: #c42b47; --brand-soft: #fdecef;
  --bg: #f5f6fa; --paper: #ffffff; --paper-2: #f9fafc;
  --ink: #18203a; --ink-2: #3c4664; --muted: #6b7491; --faint: #9aa2b8;
  --line: #e3e6ef; --line-2: #eef0f6;
  --blue: #2563c9; --blue-soft: #e8f0fd;
  --green: #138a5b; --green-soft: #e3f5ec;
  --amber: #b26a00; --amber-soft: #fff3dc;
  --red: #c62f3d; --red-soft: #fde9eb;
  --violet: #6a4bc4; --violet-soft: #efeafb;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20,28,60,.06), 0 1px 3px rgba(20,28,60,.06);
  --shadow-lg: 0 10px 30px rgba(20,28,60,.16);
  --sidebar: 232px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1424; --paper: #161d31; --paper-2: #1a2238; --ink: #e6e9f3; --ink-2: #c3c8d9; --muted: #9098b3;
    --faint: #6b7391; --line: #273049; --line-2: #212a41; --blue-soft: #1b2b4b; --green-soft: #13322a;
    --amber-soft: #3a2c12; --red-soft: #3b1c23; --violet-soft: #2a2347; --brand-soft: #3b1a24;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 30px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1424; --paper: #161d31; --paper-2: #1a2238; --ink: #e6e9f3; --ink-2: #c3c8d9; --muted: #9098b3;
  --faint: #6b7391; --line: #273049; --line-2: #212a41; --blue-soft: #1b2b4b; --green-soft: #13322a;
  --amber-soft: #3a2c12; --red-soft: #3b1c23; --violet-soft: #2a2347; --brand-soft: #3b1a24;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 30px rgba(0,0,0,.5); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 10px; }
[x-cloak] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--navy); color: #c9d0e6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 800; font-size: 18px; }
.sidebar .brand img { width: 30px; height: 30px; }
.sidebar .brand span b { color: #ff6b84; font-weight: 600; }
.nav-group { padding: 6px 10px; }
.nav-group .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #7c87a8; padding: 10px 10px 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #c9d0e6; font-weight: 500; }
.nav-link:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--navy-3); color: #fff; }
.nav-link svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-link .count { margin-left: auto; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 7px; }
.sidebar .me { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--navy-2); display: flex; gap: 10px; align-items: center; font-size: 13px; }
.sidebar .me a { color: #c9d0e6; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .search { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; color: var(--muted); cursor: text; }
.topbar .search kbd { margin-left: auto; }
.topbar .menu-btn { display: none; }
.content { padding: 22px 24px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 3px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
kbd { font: 11px var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--muted); background: var(--paper-2); }

/* ---------- surfaces ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--line-2); }
.card-head .meta { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.split-3 { display: grid; grid-template-columns: 300px minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--line-2); margin: 12px 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.empty .big { font-size: 15px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }

/* ---------- stats ---------- */
.stat { padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .v { font-size: 24px; font-weight: 750; letter-spacing: -.01em; margin-top: 2px; }
.stat .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.meter { height: 6px; background: var(--line-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.meter.green > i { background: var(--green); }
.meter.blue > i { background: var(--blue); }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--paper-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-dark:hover { background: var(--navy-2); }
.btn-danger { color: var(--red); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn svg { width: 16px; height: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label, .label-text { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=url],
input[type=date], input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; font: 14px var(--font); color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: 7px; padding: 8px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.errors { background: var(--red-soft); color: var(--red); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 13.5px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 650; padding: 1px 8px; border-radius: 20px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.brand { background: var(--brand-soft); color: var(--brand-ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); }
.dot.green { background: var(--green); } .dot.amber { background: var(--amber); } .dot.red { background: var(--red); } .dot.blue { background: var(--blue); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--violet-soft); color: var(--violet); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10.5px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--paper-2); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--paper-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 18px; border-bottom: 1px solid var(--line-2); }
.list > li:last-child { border-bottom: none; }
.list .grow { flex: 1; min-width: 0; }
.kind-icon { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--line-2); color: var(--ink-2); }
.kind-icon svg { width: 16px; height: 16px; }
.kind-icon.call { background: var(--green-soft); color: var(--green); }
.kind-icon.email { background: var(--blue-soft); color: var(--blue); }
.kind-icon.meeting { background: var(--violet-soft); color: var(--violet); }
.kind-icon.task { background: var(--amber-soft); color: var(--amber); }
.kind-icon.alert { background: var(--red-soft); color: var(--red); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a, .tabs button { padding: 9px 14px; border: none; background: none; font: 600 13.5px var(--font); color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs a.active, .tabs button.active { color: var(--ink); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 140px; height: 34px; padding: 5px 10px; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 18px; }
.timeline li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.timeline li:last-child { border-bottom: none; }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); margin-top: 3px; }

/* ---------- pipeline board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 210px); }
.col-head { padding: 11px 12px 9px; border-bottom: 1px solid var(--line); }
.col-head .t { font-weight: 700; font-size: 13.5px; display: flex; justify-content: space-between; }
.col-head .s { font-size: 12px; color: var(--muted); }
.col-body { padding: 8px; overflow-y: auto; min-height: 80px; flex: 1; }
.deal-card { background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.deal-card.stale-1 { border-left-color: var(--amber); }
.deal-card.stale-2 { border-left-color: var(--red); }
.deal-card .n { font-weight: 650; font-size: 13.5px; }
.deal-card .c { font-size: 12.5px; color: var(--muted); }
.deal-card .f { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 12.5px; }
.sortable-ghost { opacity: .4; }

/* ---------- calendar ---------- */
.week { display: grid; grid-template-columns: 56px repeat(7, minmax(110px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--paper); }
.week .hd { position: sticky; top: 0; background: var(--paper-2); border-bottom: 1px solid var(--line); padding: 8px; font-size: 12.5px; font-weight: 600; text-align: center; z-index: 2; }
.week .hd.today { color: var(--brand-ink); }
.week .hours { border-right: 1px solid var(--line); }
.week .hour { height: 48px; font-size: 11px; color: var(--faint); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.week .day { position: relative; border-right: 1px solid var(--line-2); background-image: repeating-linear-gradient(to bottom, transparent 0 47px, var(--line-2) 47px 48px); }
.week .ev { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 6px; font-size: 11.5px; overflow: hidden; background: var(--violet-soft); color: var(--violet); border-left: 3px solid var(--violet); }
.week .ev.busy { background: var(--line-2); color: var(--ink-2); border-left-color: var(--faint); }
.week .ev.cancelled { opacity: .45; text-decoration: line-through; }
.week .ev a { color: inherit; }

/* ---------- toast / modal / palette ---------- */
.flash { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; background: var(--green-soft); color: var(--green); font-weight: 600; }
.overlay { position: fixed; inset: 0; background: rgba(10,14,30,.45); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; }
.modal { background: var(--paper); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 620px; max-height: 84vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.palette input { border: none; border-bottom: 1px solid var(--line); border-radius: 0; font-size: 16px; padding: 14px 18px; box-shadow: none !important; }
.palette .res a { display: flex; gap: 10px; padding: 9px 18px; color: var(--ink); align-items: center; }
.palette .res a.sel, .palette .res a:hover { background: var(--blue-soft); text-decoration: none; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 80; font-weight: 600; }
.toast.err { background: var(--red); }

/* ---------- auth / public pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, var(--navy) 0%, #24325c 60%, #3a2240 100%); }
.auth-card { width: 100%; max-width: 410px; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 28px 28px 22px; }
.auth-card .logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; margin-bottom: 18px; color: var(--ink); }
.auth-card .logo img { width: 34px; height: 34px; }
.auth-card .logo b { color: var(--brand); font-weight: 600; }
.auth-card .btn { width: 100%; height: 40px; }
.public { min-height: 100vh; background: var(--bg); }
.public-wrap { max-width: 980px; margin: 0 auto; padding: 28px 16px 60px; }
.book-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0; }
.book-side { padding: 24px; border-right: 1px solid var(--line); }
.book-main { padding: 24px; }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.days button { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 8px 6px; cursor: pointer; font: 600 13px var(--font); color: var(--ink); }
.days button.sel { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.days button small { display: block; color: var(--muted); font-weight: 500; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 14px; }
.slots button { border: 1px solid var(--blue); color: var(--blue); background: var(--paper); border-radius: 8px; padding: 9px 4px; font: 650 13.5px var(--font); cursor: pointer; }
.slots button.sel { background: var(--blue); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .split-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 70; transform: translateX(-100%); transition: transform .18s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { padding: 8px 12px; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .search kbd { display: none; }
  .content { padding: 16px 14px 70px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book-grid { grid-template-columns: minmax(0, 1fr); }
  .book-side { border-right: none; border-bottom: 1px solid var(--line); }
  .hide-sm { display: none !important; }
  .week { grid-template-columns: 44px repeat(7, minmax(84px, 1fr)); }
  .board { grid-auto-columns: minmax(230px, 85vw); }
  .col { max-height: none; }
}
@media print { .sidebar, .topbar { display: none; } .shell { display: block; } }

/* ---------- charts (palette validated with the dataviz checker: light + dark) ---------- */
:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4;
  --seq-250: #86b6ef; --seq-350: #5598e7; --seq-450: #2a78d6; --seq-550: #1c5cab; --seq-650: #104281;
  --chart-grid: #e8eaf0; --chart-axis: #6b7491;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
    --seq-250: #184f95; --seq-350: #1c5cab; --seq-450: #256abf; --seq-550: #3987e5; --seq-650: #6da7ec;
    --chart-grid: #263049; --chart-axis: #9098b3;
  }
}
:root[data-theme="dark"] {
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
  --seq-250: #184f95; --seq-350: #1c5cab; --seq-450: #256abf; --seq-550: #3987e5; --seq-650: #6da7ec;
  --chart-grid: #263049; --chart-axis: #9098b3;
}
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-table { margin-top: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; vertical-align: 3px; }
.funnel-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 90px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.funnel-bar { height: 22px; border-radius: 4px; background: var(--seq-450); min-width: 2px; }
.topbar .search svg { width: 17px; height: 17px; flex: none; }
.topbar .btn svg { width: 17px; height: 17px; }
