/* ============================================================
   Magnificent Lighting — Studio
   Brand-accurate dark "night" theme. Clean by day, brilliant by night.
   ============================================================ */
:root {
  /* themeable base channels (flipped by data-theme / data-accent) */
  --surface-rgb: 255, 255, 255;
  --accent-rgb: 255, 196, 0;
  /* surfaces */
  --bg: #0a0a0b;
  --bg-2: #0d0d0f;
  --surface: #1313160d;
  --panel: #141418;
  --panel-2: #191920;
  --panel-3: #20202a;
  --line: rgba(var(--surface-rgb), 0.075);
  --line-2: rgba(var(--surface-rgb), 0.13);
  --line-strong: rgba(var(--surface-rgb), 0.2);

  /* text */
  --text: #f3efe6;
  --text-2: #a8a39a;
  --text-3: #6f6a61;
  --text-4: #4d4942;

  /* brand */
  --gold: #ffc400;
  --gold-2: #ffd566;
  --gold-soft: #fff3c4;
  --gold-deep: #e0a800;
  --gold-wash: rgba(var(--accent-rgb), 0.1);
  --gold-wash-2: rgba(var(--accent-rgb), 0.16);
  --gold-line: rgba(var(--accent-rgb), 0.32);

  /* semantic */
  --ok: #36d6a0;
  --ok-wash: rgba(54, 214, 160, 0.13);
  --warn: #ffb454;
  --warn-wash: rgba(255, 180, 84, 0.14);
  --danger: #ff6f6f;
  --danger-wash: rgba(255, 111, 111, 0.13);
  --info: #82a9ff;
  --info-wash: rgba(130, 169, 255, 0.14);
  --purple: #c490ff;
  --purple-wash: rgba(196, 144, 255, 0.14);

  /* shape */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --shadow: 0 1px 0 rgba(var(--surface-rgb), 0.03) inset, 0 18px 50px -22px rgba(0, 0, 0, 0.85);
  --shadow-lg: 0 1px 0 rgba(var(--surface-rgb), 0.04) inset, 0 40px 90px -30px rgba(0, 0, 0, 0.9);
  --glow: 0 0 0 1px rgba(var(--accent-rgb), 0.45), 0 12px 34px -8px rgba(var(--accent-rgb), 0.4);
  --ambient:
    radial-gradient(1100px 520px at 88% -8%, rgba(var(--accent-rgb), 0.08), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(var(--accent-rgb), 0.05), transparent 55%);
  --bulb-glow: 0 0 0 4px rgba(var(--accent-rgb), 0.14), 0 0 18px 2px rgba(var(--accent-rgb), 0.55);
  --primary-bg: linear-gradient(180deg, var(--gold-2), var(--gold));
  --primary-shadow: 0 8px 22px -10px rgba(var(--accent-rgb), 0.65);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;

  color-scheme: dark;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ambient), var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14.5px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(var(--accent-rgb), 0.28); color: #fff; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: rgba(var(--surface-rgb), 0.09); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--surface-rgb), 0.16); background-clip: padding-box; }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.money { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.hide { display: none !important; }

/* ===================== Login ===================== */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(680px 420px at 50% -10%, rgba(var(--accent-rgb), 0.16), transparent 60%),
    radial-gradient(500px 500px at 85% 120%, rgba(var(--accent-rgb), 0.07), transparent 60%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: min(412px, 100%);
  background: linear-gradient(180deg, rgba(var(--surface-rgb), 0.035), transparent 40%), var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  padding: 38px 34px 32px;
  box-shadow: var(--shadow-lg);
}
.login-card .wordmark { font-size: 15px; margin-bottom: 26px; }
.login h1 { font-family: var(--display); font-weight: 600; font-size: 30px; line-height: 1.08; margin: 0 0 8px; letter-spacing: 0.01em; }
.login .sub { color: var(--text-2); margin: 0 0 26px; font-size: 14px; }
.login .field { margin-bottom: 16px; }

/* ===================== Wordmark ===================== */
.wordmark { display: inline-flex; align-items: center; gap: 11px; font-family: var(--display); font-weight: 600; letter-spacing: 0.005em; }
.wordmark .bulb {
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-soft), var(--gold) 55%, var(--gold-deep));
  box-shadow: var(--bulb-glow);
  flex: none;
}
.wordmark .txt { line-height: 1; }
.wordmark .txt b { font-weight: 600; }
.wordmark .txt .co { color: var(--gold); }

/* ===================== App shell ===================== */
.shell { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 20px 14px 14px;
  background: linear-gradient(180deg, rgba(var(--surface-rgb), 0.02), transparent 22%), var(--bg-2);
  border-right: 1px solid var(--line);
  z-index: 5;
}
.side-brand { padding: 6px 10px 18px; }
.side-brand .wordmark { font-size: 17px; }
.side-brand .tag { color: var(--text-3); font-size: 11.5px; margin-top: 7px; letter-spacing: 0.02em; padding-left: 24px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; overflow-y: auto; }
.nav .grp { color: var(--text-4); font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; padding: 16px 12px 7px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  position: relative; transition: background 0.14s, color 0.14s;
}
.nav a svg { width: 17px; height: 17px; opacity: 0.85; flex: none; }
.nav a:hover { background: rgba(var(--surface-rgb), 0.04); color: var(--text); }
.nav a.active { background: var(--gold-wash); color: #fff; }
.nav a.active svg { color: var(--gold); opacity: 1; }
.nav a.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--gold);
  box-shadow: 0 0 12px 1px rgba(var(--accent-rgb), 0.6);
}
.nav .count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-3); background: rgba(var(--surface-rgb), 0.05); padding: 1px 7px; border-radius: 99px; }
.nav a.active .count { color: var(--gold-2); background: var(--gold-wash-2); }
.side-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.sync-pill { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-3); padding: 4px 6px; }
.sync-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); flex: none; }
.sync-pill .dot.off { background: var(--text-4); box-shadow: none; }

/* ===================== Main / topbar ===================== */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 4;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 30px; min-height: 74px;
  background: rgba(10, 10, 11, 0.72); backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.topbar .title { min-width: 0; }
.topbar h1 { font-family: var(--display); font-weight: 600; font-size: 24px; letter-spacing: 0.01em; margin: 0; line-height: 1.15; }
.topbar .sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.topbar .spacer { flex: 1; }
.kbd-trigger {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--panel); border: 1px solid var(--line-2); color: var(--text-3);
  padding: 8px 12px; border-radius: 10px; font-size: 13px; transition: border-color 0.14s, color 0.14s;
}
.kbd-trigger:hover { border-color: var(--line-strong); color: var(--text-2); }
.kbd-trigger kbd {
  font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--text-3);
  background: rgba(var(--surface-rgb), 0.06); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px;
}
.content { padding: 26px 30px 60px; }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  min-height: 38px; padding: 0 14px; border-radius: 10px; font-weight: 600; font-size: 13.5px;
  transition: background 0.14s, border-color 0.14s, transform 0.06s, box-shadow 0.14s; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--panel-2); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary-bg); border-color: var(--gold-deep); color: #1a1300; box-shadow: var(--primary-shadow); }
.btn.primary:hover { box-shadow: var(--glow); filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: rgba(var(--surface-rgb), 0.05); color: var(--text); }
.btn.subtle { background: rgba(var(--surface-rgb), 0.04); border-color: var(--line); }
.btn.danger { color: var(--danger); border-color: rgba(255, 111, 111, 0.28); background: transparent; }
.btn.danger:hover { background: var(--danger-wash); }
.btn.sm { min-height: 31px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 0; width: 38px; flex: none; }
.btn.icon.sm { width: 31px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===================== Cards / panels ===================== */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.panel.pad { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.panel-head .hint { color: var(--text-3); font-size: 12.5px; }
.panel-body { padding: 8px 20px 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr); gap: 16px; align-items: start; }
.section-title { font-family: var(--display); font-weight: 600; font-size: 17px; margin: 4px 2px 12px; letter-spacing: 0.01em; }

/* KPI */
.kpi { position: relative; padding: 18px 18px 16px; overflow: hidden; }
.kpi .ico { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--gold-wash); color: var(--gold); }
.kpi .ico svg { width: 18px; height: 18px; }
.kpi .label { color: var(--text-3); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.kpi .value { font-family: var(--display); font-weight: 600; font-size: 30px; margin-top: 9px; line-height: 1; letter-spacing: 0.005em; }
.kpi .value.money { font-variant-numeric: tabular-nums; }
.kpi .delta { margin-top: 9px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.kpi .delta b { font-weight: 600; }
.kpi .delta .up { color: var(--ok); } .kpi .delta .down { color: var(--danger); }

/* ===================== Tables ===================== */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: left; color: var(--text-3); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl th.right, table.tbl td.right { text-align: right; }
table.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr { transition: background 0.12s; }
table.tbl tbody tr:hover { background: rgba(var(--surface-rgb), 0.022); }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tr:last-child td { border-bottom: 0; }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 600; font-size: 12px; color: var(--gold-2); background: var(--gold-wash); border: 1px solid var(--gold-line); flex: none; text-transform: uppercase; }
.with-avatar { display: flex; align-items: center; gap: 11px; }

/* ===================== Status pills ===================== */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 23px; padding: 0 10px; border-radius: 99px; font-size: 11.5px; font-weight: 600; text-transform: capitalize; letter-spacing: 0.01em; border: 1px solid transparent; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.neutral { color: var(--text-2); background: rgba(var(--surface-rgb), 0.05); }
.pill.gold, .pill.sent, .pill.scheduled, .pill.lead { color: var(--gold-2); background: var(--gold-wash); border-color: var(--gold-line); }
.pill.ok, .pill.paid, .pill.completed, .pill.approved, .pill.active, .pill.converted { color: var(--ok); background: var(--ok-wash); border-color: rgba(54, 214, 160, 0.28); }
.pill.warn, .pill.in_progress, .pill.draft, .pill.watch { color: var(--warn); background: var(--warn-wash); border-color: rgba(255, 180, 84, 0.28); }
.pill.bad, .pill.overdue, .pill.declined, .pill.cancelled, .pill.void, .pill.issue, .pill.inactive { color: var(--danger); background: var(--danger-wash); border-color: rgba(255, 111, 111, 0.26); }
.pill.info { color: var(--info); background: var(--info-wash); border-color: rgba(130, 169, 255, 0.26); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 8px; font-size: 12px; background: rgba(var(--surface-rgb), 0.05); border: 1px solid var(--line); color: var(--text-2); }
.chip.gold { background: var(--gold-wash); border-color: var(--gold-line); color: var(--gold-2); }

/* ===================== Empty ===================== */
.empty { border: 1px dashed var(--line-2); border-radius: var(--r); padding: 40px 24px; text-align: center; color: var(--text-3); }
.empty svg { width: 26px; height: 26px; opacity: 0.5; margin-bottom: 10px; }
.empty h3 { margin: 0 0 4px; color: var(--text-2); font-weight: 600; font-size: 14px; }

/* ===================== Toolbar / search ===================== */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.search input { width: 100%; padding: 10px 12px 10px 36px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; }
.search input:focus { outline: none; border-color: var(--gold-line); }
.segmented { display: inline-flex; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; color: var(--text-3); padding: 6px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; }
.segmented button.on { background: var(--gold-wash-2); color: var(--gold-2); }
.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-tabs button { border: 1px solid var(--line); background: transparent; color: var(--text-2); padding: 6px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 500; }
.filter-tabs button.on { background: #fff; color: #111; border-color: #fff; }

/* ===================== Forms / drawer ===================== */
.scrim { position: fixed; inset: 0; background: rgba(6, 6, 8, 0.62); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 40; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(620px, 100%);
  background: var(--bg-2); border-left: 1px solid var(--line-2); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 50; display: flex; flex-direction: column;
}
.drawer.wide { width: min(820px, 100%); }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.drawer-head .eyebrow { color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.drawer-head h2 { margin: 2px 0 0; font-family: var(--display); font-weight: 600; font-size: 21px; }
.drawer-body { padding: 22px 24px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: var(--bg-2); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; transition: border-color 0.14s, box-shadow 0.14s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold-line); box-shadow: 0 0 0 3px var(--gold-wash); }
.field textarea { min-height: 92px; resize: vertical; }
.field .help { color: var(--text-4); font-size: 11.5px; }
.subhead { font-size: 11px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.subhead::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* line editor */
.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 76px 104px 96px 32px; gap: 8px; align-items: center; }
.line .amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-2); }
.line input { padding: 8px 10px; }
.line-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.totals-box { margin-top: 16px; margin-left: auto; width: min(280px, 100%); display: flex; flex-direction: column; gap: 7px; }
.totals-box .row { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-2); }
.totals-box .row.grand { border-top: 1px solid var(--line-2); margin-top: 5px; padding-top: 10px; font-size: 17px; font-weight: 700; color: var(--text); }
.totals-box .row .money { font-variant-numeric: tabular-nums; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: rgba(var(--surface-rgb), 0.1); border: 1px solid var(--line-2); position: relative; transition: background 0.16s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: transform 0.16s, background 0.16s; }
.switch input:checked + .track { background: var(--gold-wash-2); border-color: var(--gold-line); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--gold); }

/* ===================== Timeline ===================== */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 26px 1fr; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 12px; top: 24px; bottom: 0; width: 1.5px; background: var(--line); }
.tl-dot { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text-3); }
.tl-dot svg { width: 13px; height: 13px; }
.tl-dot.gold { color: var(--gold); border-color: var(--gold-line); background: var(--gold-wash); }
.tl-dot.bad { color: var(--danger); border-color: rgba(255,111,111,.3); background: var(--danger-wash); }
.tl-dot.ok { color: var(--ok); border-color: rgba(54,214,160,.3); background: var(--ok-wash); }
.tl-body { min-width: 0; }
.tl-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.tl-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-time { color: var(--text-3); font-size: 11.5px; white-space: nowrap; }
.tl-text { color: var(--text-2); font-size: 13px; margin-top: 4px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tl-meta { color: var(--text-4); font-size: 11.5px; margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tl-meta a { color: var(--info); }

/* ===================== Detail header ===================== */
.detail-hero { display: flex; align-items: flex-start; gap: 16px; padding: 22px; }
.detail-hero .avatar.lg { width: 54px; height: 54px; border-radius: 14px; font-size: 19px; }
.detail-hero h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 24px; }
.detail-hero .meta { color: var(--text-2); font-size: 13px; margin-top: 5px; display: flex; flex-wrap: wrap; gap: 14px; }
.detail-hero .meta span { display: inline-flex; align-items: center; gap: 6px; }
.detail-hero .meta svg { width: 14px; height: 14px; color: var(--text-3); }
.mini-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-radius: var(--r); overflow: hidden; margin: 0 22px 8px; }
.mini-kpis .mk { background: var(--panel); padding: 14px 16px; }
.mini-kpis .mk .l { color: var(--text-3); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.mini-kpis .mk .v { font-size: 19px; font-weight: 600; margin-top: 5px; font-variant-numeric: tabular-nums; }

/* ===================== Calendar ===================== */
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cal-head .mname { font-family: var(--display); font-weight: 600; font-size: 20px; min-width: 210px; }
.cal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow { padding: 11px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); border-bottom: 1px solid var(--line); text-align: left; }
.cal-cell { min-height: 116px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 5px; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.out { background: rgba(0, 0, 0, 0.18); }
.cal-cell .dnum { font-size: 12.5px; color: var(--text-3); font-weight: 600; align-self: flex-start; padding: 1px 2px; }
.cal-cell.today .dnum { background: var(--gold); color: #1a1300; border-radius: 7px; padding: 1px 7px; box-shadow: 0 0 14px -2px rgba(var(--accent-rgb),.7); }
.cal-cell.out .dnum { color: var(--text-4); }
.ev { font-size: 11.5px; padding: 4px 7px; border-radius: 7px; background: var(--gold-wash); color: var(--gold-2); border: 1px solid var(--gold-line); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: background 0.12s; }
.ev:hover { background: var(--gold-wash-2); }
.ev.ok { background: var(--ok-wash); color: var(--ok); border-color: rgba(54,214,160,.28); }
.ev.bad { background: var(--danger-wash); color: var(--danger); border-color: rgba(255,111,111,.26); }
.ev.warn { background: var(--warn-wash); color: var(--warn); border-color: rgba(255,180,84,.28); }
.agenda-day { display: grid; grid-template-columns: 96px 1fr; gap: 16px; padding: 14px 6px; border-bottom: 1px solid var(--line); }
.agenda-day .d { text-align: right; }
.agenda-day .d .dow { color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.agenda-day .d .dn { font-family: var(--display); font-size: 26px; font-weight: 600; }

/* ===================== Pipeline ===================== */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(248px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-lg); display: flex; flex-direction: column; min-height: 220px; }
.col-head { padding: 13px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.col-head .nm { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.col-head .nm .dot { width: 8px; height: 8px; border-radius: 50%; }
.col-head .sum { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; }
.deal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 11px; padding: 12px; cursor: pointer; transition: border-color 0.14s, transform 0.06s; }
.deal:hover { border-color: var(--gold-line); }
.deal:active { transform: translateY(1px); }
.deal .t { font-weight: 600; font-size: 13px; }
.deal .c { color: var(--text-3); font-size: 12px; margin-top: 3px; }
.deal .b { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.deal .b .money { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===================== Charts ===================== */
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 168px; padding-top: 10px; }
.chart-bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart-bars .bar { width: 100%; max-width: 42px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--gold), var(--gold-deep)); box-shadow: 0 0 18px -6px rgba(var(--accent-rgb),.6); transition: height 0.5s cubic-bezier(.22,1,.36,1); min-height: 3px; }
.chart-bars .bar.soft { background: linear-gradient(180deg, rgba(var(--accent-rgb),.4), rgba(var(--accent-rgb),.12)); box-shadow: none; }
.chart-bars .x { font-size: 11px; color: var(--text-3); }
.chart-bars .v { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.aging-bar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: rgba(var(--surface-rgb),.05); }
.aging-bar span { display: block; height: 100%; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.legend .li { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.legend .li .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend .li b { font-variant-numeric: tabular-nums; color: var(--text); }
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut { --p: 0; width: 132px; height: 132px; border-radius: 50%; flex: none; background: conic-gradient(var(--gold) calc(var(--p) * 1%), rgba(var(--surface-rgb),.06) 0); display: grid; place-items: center; position: relative; }
.donut::after { content: ""; position: absolute; inset: 16px; border-radius: 50%; background: var(--panel); }
.donut .mid { position: relative; z-index: 1; text-align: center; }
.donut .mid .big { font-family: var(--display); font-size: 26px; font-weight: 600; }
.donut .mid .lbl { font-size: 11px; color: var(--text-3); }

/* progress (checklist) */
.checklist { display: flex; flex-direction: column; gap: 2px; }
.ck { display: flex; align-items: center; gap: 11px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.ck:last-child { border-bottom: 0; }
.ck .box { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; flex: none; cursor: pointer; transition: all 0.12s; color: transparent; }
.ck .box.done { background: var(--ok); border-color: var(--ok); color: #06241a; }
.ck .box svg { width: 13px; height: 13px; }
.ck .lbl { flex: 1; font-size: 13.5px; }
.ck.done .lbl { color: var(--text-3); text-decoration: line-through; }
.progress { height: 6px; border-radius: 99px; background: rgba(var(--surface-rgb),.06); overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); border-radius: 99px; transition: width 0.4s; }

/* ===================== Command palette ===================== */
.cmdk { position: fixed; inset: 0; z-index: 60; display: none; padding-top: 12vh; justify-content: center; }
.cmdk.open { display: flex; }
.cmdk .veil { position: absolute; inset: 0; background: rgba(6,6,8,.6); backdrop-filter: blur(4px); }
.cmdk .box { position: relative; width: min(620px, 92%); height: max-content; max-height: 64vh; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; }
.cmdk .inp { display: flex; align-items: center; gap: 11px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.cmdk .inp svg { width: 18px; height: 18px; color: var(--text-3); }
.cmdk .inp input { flex: 1; background: transparent; border: 0; outline: none; font-size: 16px; }
.cmdk .results { overflow-y: auto; padding: 8px; }
.cmdk .res { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.cmdk .res.sel { background: var(--gold-wash); }
.cmdk .res .ri { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); flex: none; }
.cmdk .res.sel .ri { color: var(--gold); border-color: var(--gold-line); }
.cmdk .res .rt { flex: 1; min-width: 0; }
.cmdk .res .rt .a { font-weight: 600; font-size: 13.5px; }
.cmdk .res .rt .b { font-size: 12px; color: var(--text-3); }
.cmdk .res .tag { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.cmdk .grp-label { padding: 10px 12px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-4); }

/* ===================== Toast ===================== */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; max-width: 380px; animation: toastIn 0.22s cubic-bezier(.22,1,.36,1); }
.toast .i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); flex: none; }
.toast.ok .i { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.toast.bad .i { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* note composer */
.composer { display: flex; gap: 8px; margin-bottom: 16px; }
.composer textarea { flex: 1; min-height: 42px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; resize: vertical; }

.share-link { display: flex; gap: 8px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 8px 8px 12px; margin-top: 8px; }
.share-link code { flex: 1; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== Responsive ===================== */
.menu-btn { display: none; }
.side-backdrop { display: none; }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3 { grid-template-columns: 1fr; }
}

/* Tablet & phone: sidebar becomes an off-canvas drawer with a backdrop */
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; left: 0; top: 0; height: 100dvh; width: 270px; z-index: 60;
    transform: translateX(-100%); transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 70px rgba(0, 0, 0, 0.7);
  }
  body.nav-open .side { transform: translateX(0); }
  .side-backdrop { position: fixed; inset: 0; background: rgba(6, 6, 8, 0.55); backdrop-filter: blur(2px); z-index: 55; }
  body.nav-open .side-backdrop { display: block; }
  .menu-btn { display: inline-flex !important; }
  .cols-2, .cols-4 { grid-template-columns: 1fr; }
  html, body { overflow-x: hidden; max-width: 100%; }
  .main { overflow-x: hidden; }
}

/* Phone: reflow the topbar, stack tables into cards, full-bleed drawers */
@media (max-width: 768px) {
  .topbar {
    position: static; flex-wrap: wrap; align-items: center;
    gap: 10px 12px; padding: 12px 14px; min-height: 0;
  }
  .topbar .menu-btn { order: 0; flex: 0 0 auto; }
  .topbar .title { order: 1; flex: 1 1 auto; min-width: 0; }
  .topbar h1 { font-size: 20px; line-height: 1.2; }
  .topbar .sub { font-size: 12px; line-height: 1.4; }
  .topbar .spacer { display: none; }
  .topbar .kbd-trigger { order: 2; flex: 0 0 auto; width: 40px; height: 40px; padding: 0; justify-content: center; }
  .topbar .kbd-trigger span, .topbar .kbd-trigger kbd { display: none; }
  .topbar .btn-row { order: 3; flex: 1 1 100%; gap: 8px; }
  .topbar .btn-row .btn { flex: 1 1 auto; justify-content: center; }

  .content { padding: 16px 14px 64px; }
  .grid { gap: 12px; }
  .kpi { padding: 16px; }
  .kpi .value { font-size: 25px; }
  .kpi .ico { top: 16px; right: 16px; }
  .section-title { font-size: 16px; }
  .panel-head { padding: 14px 16px; }
  .panel-body { padding: 6px 16px 14px; }
  .panel.pad { padding: 16px; }
  .toolbar { gap: 8px; }
  .search { max-width: none; min-width: 0; }

  /* Pipeline: one column per swipe, peek the next */
  .board { grid-auto-columns: 84vw; gap: 12px; }

  /* Filter tabs scroll horizontally instead of wrapping into a tall block */
  .filter-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; min-width: 0; }
  .filter-tabs button { white-space: nowrap; flex: 0 0 auto; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search { flex: 1 1 100%; }

  /* Tables → stacked cards */
  .tbl-wrap { overflow: visible; }
  table.tbl thead { display: none; }
  table.tbl, table.tbl tbody, table.tbl tr, table.tbl td { display: block; }
  table.tbl tr { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 10px; padding: 2px 0; background: rgba(var(--surface-rgb), 0.018); }
  table.tbl tr:last-child { margin-bottom: 0; }
  table.tbl tbody tr:hover, table.tbl tbody tr:hover td { background: rgba(var(--surface-rgb), 0.018); }
  table.tbl td { border: 0; border-top: 1px solid var(--line); padding: 11px 15px; display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right; }
  table.tbl td[data-label]::before {
    content: attr(data-label); color: var(--text-3); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em; text-align: left; margin-right: auto; align-self: center;
  }
  table.tbl td:first-child { display: block; border-top: 0; text-align: left; padding: 13px 15px 11px; }
  table.tbl td:first-child .cell-title { font-size: 15px; }
  table.tbl td:first-child .with-avatar { width: 100%; }
  table.tbl td:empty { display: none; }
  table.tbl td .actions, table.tbl td .btn-row { justify-content: flex-end; }

  /* Drawers fill the screen */
  .drawer, .drawer.wide { width: 100%; }
  .drawer-head { padding: 16px 18px; }
  .drawer-body { padding: 18px; }
  .drawer-foot { padding: 14px 18px; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .totals-box { width: 100%; }

  .detail-hero { padding: 18px; }
  .mini-kpis { margin: 0 18px 8px; }
  .cmdk { padding-top: 8vh; }
  .cmdk .box { width: 94%; }
  .toast-wrap { left: 14px; right: 14px; bottom: 14px; }
  .toast { max-width: none; }
}

@media (max-width: 560px) {
  .line { grid-template-columns: 1fr 58px 72px 30px; }
  .line [data-amt] { display: none; }
  .mini-kpis { grid-template-columns: 1fr; }
}

/* ============================================================
   APPEARANCE — accents, style spectrum, light theme
   ============================================================ */
/* Accent palettes (washes & glows auto-follow --accent-rgb) */
[data-accent="amber"]   { --accent-rgb: 255, 143, 58;  --gold: #ff8f3a; --gold-2: #ffb27a; --gold-soft: #ffe6d2; --gold-deep: #e0691a; }
[data-accent="emerald"] { --accent-rgb: 52, 211, 158;  --gold: #34d39e; --gold-2: #6ee7c0; --gold-soft: #d6f7ec; --gold-deep: #12a37a; }
[data-accent="sky"]     { --accent-rgb: 90, 176, 255;  --gold: #5ab0ff; --gold-2: #93c9ff; --gold-soft: #dcebff; --gold-deep: #2b86e0; }
[data-accent="violet"]  { --accent-rgb: 177, 139, 255; --gold: #b18bff; --gold-2: #ccb0ff; --gold-soft: #ece2ff; --gold-deep: #7d52df; }
[data-accent="mono"]    { --accent-rgb: 214, 217, 224; --gold: #d6d9e0; --gold-2: #eceef2; --gold-soft: #f6f7f9; --gold-deep: #9aa0ad; }

/* ---- Style: Balanced (calmer than Expressive, keeps serif) ---- */
[data-style="balanced"] {
  --ambient: radial-gradient(1000px 520px at 90% -10%, rgba(var(--accent-rgb), 0.05), transparent 60%);
  --shadow: 0 1px 0 rgba(var(--surface-rgb), 0.02) inset, 0 12px 30px -22px rgba(0, 0, 0, 0.7);
  --glow: 0 0 0 1px rgba(var(--accent-rgb), 0.4), 0 8px 22px -10px rgba(var(--accent-rgb), 0.28);
  --bulb-glow: 0 0 0 4px rgba(var(--accent-rgb), 0.1), 0 0 12px 1px rgba(var(--accent-rgb), 0.4);
  --primary-shadow: 0 6px 16px -10px rgba(var(--accent-rgb), 0.5);
}

/* ---- Style: Minimal (sans, flat, restrained) ---- */
[data-style="minimal"] {
  --display: var(--font);
  --ambient: none;
  --shadow: none;
  --shadow-lg: 0 30px 64px -40px rgba(0, 0, 0, 0.6);
  --glow: 0 0 0 1px var(--gold-line);
  --bulb-glow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
  --primary-bg: var(--gold);
  --primary-shadow: none;
}
[data-style="minimal"] .topbar { backdrop-filter: none; background: var(--bg); }
[data-style="minimal"] .nav a.active { color: var(--text); }
[data-style="minimal"] .nav a.active::before { box-shadow: none; }
[data-style="minimal"] .kpi .value { font-size: 25px; font-weight: 650; letter-spacing: -0.015em; }
[data-style="minimal"] .chart-bars .bar { box-shadow: none; }
[data-style="minimal"] .cal-cell.today .dnum { box-shadow: none; }
[data-style="minimal"] .btn.primary:hover { filter: none; background: var(--gold-2); }
[data-style="minimal"] .wordmark .bulb { background: var(--gold); }
[data-style="minimal"] .login::before { opacity: 0.35; }

/* ---- Theme: Light ---- */
[data-theme="light"] {
  --surface-rgb: 28, 22, 12;
  --bg: #f4f1ea;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #faf7f1;
  --panel-3: #f0ece3;
  --text: #1c1810;
  --text-2: #5f584c;
  --text-3: #8d8576;
  --text-4: #b6ad9d;
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.04), 0 14px 30px -22px rgba(40, 30, 10, 0.26);
  --shadow-lg: 0 30px 70px -34px rgba(40, 30, 10, 0.32);
  color-scheme: light;
}
[data-theme="light"] .topbar { background: rgba(255, 255, 255, 0.72); }
[data-theme="light"] .cal-cell.out { background: rgba(0, 0, 0, 0.025); }
[data-theme="light"] .nav a.active { color: var(--text); }
[data-theme="light"] ::selection { color: #1a1300; }
[data-theme="light"] .scrim, [data-theme="light"] .cmdk .veil { background: rgba(20, 16, 8, 0.35); }
[data-theme="light"] .filter-tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
/* accent-as-foreground needs the deep shade on light backgrounds */
[data-theme="light"] .kpi .ico,
[data-theme="light"] .avatar,
[data-theme="light"] .pill.gold, [data-theme="light"] .pill.sent, [data-theme="light"] .pill.scheduled, [data-theme="light"] .pill.lead,
[data-theme="light"] .chip.gold,
[data-theme="light"] .ev,
[data-theme="light"] .tl-dot.gold,
[data-theme="light"] .segmented button.on,
[data-theme="light"] .nav a.active svg,
[data-theme="light"] .nav a.active .count,
[data-theme="light"] .wordmark .txt .co { color: var(--gold-deep); }

/* ============================================================
   APPEARANCE — control widgets (in Account drawer)
   ============================================================ */
.appearance { display: flex; flex-direction: column; gap: 18px; }
.ap-row { display: flex; flex-direction: column; gap: 9px; }
.ap-row > label { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.spectrum { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 4px; gap: 3px; }
.spectrum button { border: 0; background: transparent; color: var(--text-3); padding: 10px 8px; border-radius: 9px; font-size: 12.5px; font-weight: 600; transition: background 0.14s, color 0.14s; }
.spectrum button:hover { color: var(--text-2); }
.spectrum button.on { background: var(--gold-wash-2); color: var(--gold-2); box-shadow: inset 0 0 0 1px var(--gold-line); }
.seg2 { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 4px; gap: 3px; max-width: 240px; }
.seg2 button { border: 0; background: transparent; color: var(--text-3); padding: 9px 12px; border-radius: 9px; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.seg2 button svg { width: 15px; height: 15px; }
.seg2 button.on { background: var(--gold-wash-2); color: var(--gold-2); }
.swatches { display: flex; gap: 11px; flex-wrap: wrap; }
.swatches .sw { width: 30px; height: 30px; border-radius: 9px; border: 0; background: var(--sw); cursor: pointer; box-shadow: 0 0 0 1px var(--line-2); transition: transform 0.1s; }
.swatches .sw:hover { transform: scale(1.08); }
.swatches .sw.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--sw); }
