/* ─────────────────────────────────────────────────────────────
   Marlow Hub — design system
   Dark mode, plum accent, Linear/Notion/Stripe quality bar.
   ──────────────────────────────────────────────────────────── */

:root {
  --bg: #0F0F14;
  --panel: #1A1A22;
  --panel-hover: #22222E;
  --panel-elev: #20202B;
  --text: #F2EFE8;
  --text-dim: #8a8a90;
  --text-mute: #5e5e66;
  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);
  --accent: #4A3548;
  --accent-light: #6B4F69;
  --accent-soft: rgba(107,79,105,0.18);
  --success: #5b8c5a;
  --warn: #c89d5a;
  --danger: #b85c5c;
  --hot: #d97757;
  --warm: #e0b85c;
  --cold: #6b8eb5;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.55);

  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 320ms cubic-bezier(0.34, 1.56, 0.64, 1);

  --sidebar-w: 220px;
  --topbar-h: 56px;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01';
  letter-spacing: -0.005em;
  min-height: 100vh;
  overflow-x: hidden;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
a { color: inherit; text-decoration: none; }
code, pre, .mono { font-family: 'JetBrains Mono', Menlo, monospace; }
::selection { background: var(--accent-light); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }

/* ─── Brand wordmark ────────────────────────────────────────── */
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.brand-name {
  font-weight: 500;
  letter-spacing: -0.02em;
  font-size: 16px;
}
.brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.brand--lg .brand-name { font-size: 28px; }
.brand--lg .brand-dot { width: 9px; height: 9px; }

/* ─── Login screen ──────────────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(107,79,105,0.12), transparent 60%), var(--bg);
  z-index: 1000;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  padding: 40px 28px;
}
.login-tag {
  margin: 8px 0 28px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.login-form input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-form input.shake { animation: shake 380ms cubic-bezier(0.36, 0.07, 0.19, 0.97); border-color: var(--danger); }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.login-error {
  font-size: 12px;
  color: var(--danger);
  margin: 4px 0 0;
  letter-spacing: 0.05em;
}

/* ─── App shell ─────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  z-index: 30;
}
.sidebar-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 10px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item:hover { background: var(--panel-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  margin-left: -14px;
  width: 3px;
  height: 18px;
  background: var(--accent-light);
  border-radius: 0 3px 3px 0;
}
.nav-item i { width: 16px; height: 16px; }
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  border-top: 1px solid var(--border);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* ─── Top bar ───────────────────────────────────────────────── */
.topbar {
  grid-area: topbar;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.topbar-search {
  flex: 1;
  display: flex;
  align-items: center;
  max-width: 480px;
  margin-left: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  gap: 8px;
  transition: border-color var(--t-base);
}
.topbar-search:focus-within { border-color: var(--accent-light); }
.topbar-search i { width: 14px; height: 14px; color: var(--text-mute); }
.topbar-search input {
  background: transparent;
  border: 0;
  outline: 0;
  flex: 1;
  font-size: 13px;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-clock {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* ─── Main content ──────────────────────────────────────────── */
.content {
  grid-area: content;
  padding: 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:hover { background: var(--panel-hover); border-color: var(--border-strong); }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text);
}
.btn--primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn--ghost:hover { background: var(--panel-hover); color: var(--text); }
.btn--danger { color: var(--danger); border-color: rgba(184,92,92,0.3); }
.btn--danger:hover { background: rgba(184,92,92,0.1); }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn i { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Forms ─────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
}
.input, select.input, textarea.input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  color: var(--text);
  font-size: 13px;
  transition: border-color var(--t-base), box-shadow var(--t-base);
  width: 100%;
}
.input:focus, textarea.input:focus, select.input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }
select.input { appearance: none; padding-right: 32px; background-image:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a90' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* ─── Cards / panels ────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-title { font-size: 13px; font-weight: 600; margin: 0 0 12px; letter-spacing: -0.005em; }
.card-sub { font-size: 12px; color: var(--text-dim); margin: 0 0 12px; }

/* ─── Heading hierarchy ─────────────────────────────────────── */
.h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 4px; }
.h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 8px; }
.h3 { font-size: 13px; font-weight: 600; margin: 0 0 4px; color: var(--text); }
.subtitle { font-size: 13px; color: var(--text-dim); margin: 0 0 24px; }

/* ─── Dashboard ─────────────────────────────────────────────── */
.greeting { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.greeting-time { color: var(--text-dim); font-weight: 400; margin-left: 8px; }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 24px 0;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color var(--t-base), background var(--t-base);
}
.metric:hover { border-color: var(--border-strong); background: var(--panel-hover); }
.metric-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.metric-label i { width: 12px; height: 12px; }
.metric-value {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.quick-actions { display: flex; flex-direction: column; gap: 8px; }
.quick-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.quick-action:hover { background: var(--panel-hover); border-color: var(--border-strong); }
.quick-action i { width: 14px; height: 14px; color: var(--text-dim); }

.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: center;
}
.activity-row:last-child { border-bottom: 0; }
.activity-row .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-light);
  margin: 0 4px;
}
.activity-row .text { color: var(--text); }
.activity-row .text strong { font-weight: 500; }
.activity-row .text .note { color: var(--text-dim); font-size: 12px; }
.activity-row .when { color: var(--text-mute); font-size: 11px; font-variant-numeric: tabular-nums; }

.hitlist-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: center;
}
.hitlist-row:last-child { border-bottom: 0; }
.hitlist-name { color: var(--text); font-weight: 500; }
.hitlist-meta { color: var(--text-dim); font-size: 12px; }
.hitlist-score {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--accent-light);
  font-weight: 500;
}

/* ─── CRM table ─────────────────────────────────────────────── */
.crm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.crm-toolbar .input { flex: 0 0 220px; }
.crm-toolbar select.input { flex: 0 0 150px; }
.crm-toolbar .grow { flex: 1; }

.crm-table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.crm-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-elev);
  white-space: nowrap;
}
.crm-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.crm-table tr { cursor: pointer; transition: background var(--t-fast); }
.crm-table tbody tr:hover { background: var(--panel-hover); }
.crm-table tr:last-child td { border-bottom: 0; }
.crm-table .col-name { min-width: 180px; font-weight: 500; }
.crm-table .col-mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-dim); }
.crm-table .col-num { font-variant-numeric: tabular-nums; text-align: right; color: var(--accent-light); font-weight: 500; }
.crm-row-actions {
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.crm-table tbody tr:hover .crm-row-actions { opacity: 1; }
.crm-empty { padding: 60px 20px; text-align: center; color: var(--text-mute); font-size: 13px; }

/* ─── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: var(--panel-hover);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge-temp { padding: 2px 9px; }
.badge-temp.hot  { background: rgba(217,119,87,0.14);  color: var(--hot); }
.badge-temp.warm { background: rgba(224,184,92,0.14);  color: var(--warm); }
.badge-temp.cold { background: rgba(107,142,181,0.14); color: var(--cold); }

.badge-grade { font-family: 'JetBrains Mono', monospace; font-size: 10px; }
.badge-grade.a { background: rgba(91,140,90,0.14); color: var(--success); }
.badge-grade.b { background: rgba(91,140,90,0.10); color: #88b888; }
.badge-grade.c { background: rgba(224,184,92,0.14); color: var(--warm); }
.badge-grade.d { background: rgba(217,119,87,0.14); color: var(--hot); }
.badge-grade.f { background: rgba(184,92,92,0.18);  color: var(--danger); }

/* ─── Slide-in panel ────────────────────────────────────────── */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  transition: opacity var(--t-base);
}
.panel-backdrop.show { opacity: 1; }
.panel {
  position: fixed;
  top: 0; right: 0;
  width: 100%;
  max-width: 520px;
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 100;
  transform: translateX(100%);
  transition: transform var(--t-spring);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.panel.show { transform: translateX(0); }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-header .title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}
.panel-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ─── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow);
  transform: translateY(8px);
  opacity: 0;
  transition: transform var(--t-base), opacity var(--t-base);
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(91,140,90,0.4); }
.toast.error { border-color: rgba(184,92,92,0.4); }

/* ─── Quick palette (Cmd+K) ─────────────────────────────────── */
.palette {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(0,0,0,0.55);
}
.palette-card {
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.palette-card input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  padding: 16px 18px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.palette-results { list-style: none; margin: 0; padding: 6px; max-height: 360px; overflow-y: auto; }
.palette-results li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.palette-results li.sel { background: var(--accent-soft); }
.palette-results li:hover { background: var(--panel-hover); }
.palette-results .meta { color: var(--text-dim); font-size: 12px; }

/* ─── Playbook ──────────────────────────────────────────────── */
.stepper {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 6px;
  margin: 16px 0 28px;
}
.step {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.step:hover { background: var(--panel-hover); border-color: var(--border-strong); }
.step.active { border-color: var(--accent-light); background: var(--accent-soft); }
.step-n {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  text-transform: uppercase;
}
.step-title {
  display: block;
  font-size: 11px;
  font-weight: 500;
  margin-top: 4px;
}
.stage-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 16px;
}
.stage-card h2 { font-size: 18px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.stage-card .goal { color: var(--text-dim); font-size: 13px; margin: 0 0 16px; }
.stage-card h3 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; }
.stage-card ul, .stage-card ol { margin: 0 0 14px 18px; padding: 0; }
.stage-card li { font-size: 13px; margin: 4px 0; line-height: 1.55; }
.warning {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(184,92,92,0.1);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 12px 0;
  color: var(--text);
}
.kickoff-prompt {
  background: var(--panel-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 8px 0;
  white-space: pre-wrap;
  position: relative;
}

/* ─── Phone script & objections ─────────────────────────────── */
.script-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  overflow: hidden;
}
.script-section summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 14px;
  user-select: none;
}
.script-section summary::-webkit-details-marker { display: none; }
.script-section summary::after {
  content: '+';
  color: var(--text-dim);
  font-size: 18px;
  font-weight: 300;
  transition: transform var(--t-base);
}
.script-section[open] summary::after { transform: rotate(45deg); }
.script-body { padding: 0 18px 16px; }
.script-line {
  background: var(--panel-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.6;
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}
.script-line .copy-btn {
  background: transparent;
  border: 0;
  color: var(--text-mute);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
}
.script-line .copy-btn:hover { color: var(--text); background: var(--panel-hover); }
.script-line.note { background: transparent; border-color: transparent; padding: 4px 12px; color: var(--text-dim); font-size: 12px; }

/* ─── Templates view ────────────────────────────────────────── */
.templates-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: start;
}
.tpl-list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
}
.tpl-item {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.tpl-item:hover { background: var(--panel-hover); color: var(--text); }
.tpl-item.active { background: var(--accent-soft); color: var(--text); }
.tpl-item .num {
  display: inline-block;
  width: 22px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-mute);
}
.tpl-detail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
}
.tpl-subject {
  background: var(--panel-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tpl-subject .label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-mute); }
.tpl-body {
  background: var(--panel-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.tpl-body .field-bracket {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-light);
  padding: 0 6px;
  border-radius: 4px;
  font-weight: 500;
}
.tpl-fills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
  background: var(--panel-elev);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.tpl-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.tpl-note {
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(224,184,92,0.08);
  border-left: 3px solid var(--warm);
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
}

/* ─── Contracts ─────────────────────────────────────────────── */
.contract-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.contract-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.contract-card:hover { background: var(--panel-hover); border-color: var(--border-strong); }
.contract-card.active { border-color: var(--accent-light); background: var(--accent-soft); }
.contract-card .h2 { margin: 0 0 6px; }
.contract-card .desc { color: var(--text-dim); font-size: 12px; margin: 0; }
.contract-detail {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}
.contract-body {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  font-family: 'Inter', sans-serif;
}
.contract-fills {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
}
.contract-fills .field { margin-bottom: 10px; }
.contract-fills .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* ─── Pricing ───────────────────────────────────────────────── */
.pricing-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
.tier-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  position: relative;
}
.tier-card:hover { background: var(--panel-hover); border-color: var(--border-strong); }
.tier-card.active { border-color: var(--accent-light); background: var(--accent-soft); }
.tier-card.active::after {
  content: '✓';
  position: absolute;
  top: 10px; right: 12px;
  width: 18px; height: 18px;
  background: var(--accent);
  color: var(--text);
  border-radius: 50%;
  text-align: center;
  font-size: 11px;
  line-height: 18px;
  font-weight: 600;
}
.tier-cap { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-mute); margin: 0; }
.tier-price { font-size: 18px; font-weight: 600; margin: 4px 0 2px; letter-spacing: -0.01em; }
.tier-price .suffix { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.tier-detail { font-size: 11px; color: var(--text-dim); margin: 0; }

.summary {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
}
.summary-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 16px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
}
.summary-row .label { color: var(--text-dim); }
.summary-row .value { font-weight: 500; font-variant-numeric: tabular-nums; }
.summary-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}
.summary-row.total .value { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.summary-row.subtle { color: var(--text-mute); font-size: 11px; }

/* ─── Reference tabs ────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tab {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent-light); font-weight: 500; }

.ref-section { margin-bottom: 28px; }
.ref-section h2 { font-size: 14px; font-weight: 600; margin: 0 0 10px; letter-spacing: -0.01em; }
.ref-section ul { margin: 6px 0 0 18px; padding: 0; }
.ref-section li { font-size: 13px; line-height: 1.6; margin: 3px 0; }
.ref-section dl { margin: 6px 0 0; }
.ref-section dt { font-size: 12px; color: var(--text-dim); margin-top: 8px; letter-spacing: 0.02em; }
.ref-section dd { margin: 2px 0 0; font-size: 13px; }
.ref-section .ref-quote {
  background: var(--panel-elev);
  border-left: 3px solid var(--accent-light);
  padding: 10px 14px;
  font-size: 13px;
  font-style: italic;
  color: var(--text-dim);
  margin: 8px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.ref-section .body { font-size: 13px; line-height: 1.65; color: var(--text); }
.ref-section .footer-note { font-size: 12px; color: var(--text-dim); margin-top: 8px; font-style: italic; }
.flagship-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.flagship-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.flagship-card .name { font-weight: 600; font-size: 13px; }
.flagship-card .kind { color: var(--text-dim); font-size: 11px; }
.flagship-card a { color: var(--accent-light); font-size: 11px; word-break: break-all; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
}
.checks li.done { color: var(--text-dim); text-decoration: line-through; }
.checks li::before {
  content: "";
  width: 14px; height: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
  background: var(--panel);
}
.checks li.done::before {
  background: var(--success);
  border-color: var(--success);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230F0F14' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-size: 10px;
  background-repeat: no-repeat;
  background-position: center;
}

/* ─── Bottom nav (mobile) ───────────────────────────────────── */
.bottom-nav {
  display: none;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "content";
  }
  .sidebar { display: none; }
  .topbar { padding: 0 16px; }
  .topbar-search { max-width: 100%; }
  .content { padding: 16px 16px 88px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid, .pricing-layout, .templates-layout, .contract-detail { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: repeat(4, 1fr); }
  .step-title { display: none; }
  .crm-table { font-size: 12px; }
  .crm-table .col-hide-mobile { display: none; }
  .panel { max-width: 100%; }
  .bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex;
    justify-content: space-around;
    background: var(--panel);
    border-top: 1px solid var(--border);
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 50;
  }
  .bnav-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    color: var(--text-mute);
    transition: color var(--t-fast);
  }
  .bnav-item.active { color: var(--accent-light); }
  .bnav-item i { width: 20px; height: 20px; }
  .contract-fills, .summary, .tpl-list { position: static; }
}

/* ─── Skeleton loading ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--panel) 0%, var(--panel-hover) 50%, var(--panel) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Helpers ───────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.gap-sm { gap: 4px; } .gap-md { gap: 12px; } .gap-lg { gap: 20px; }
.muted { color: var(--text-dim); }
.mt-sm { margin-top: 8px; } .mt-md { margin-top: 16px; } .mt-lg { margin-top: 28px; }
.mb-sm { margin-bottom: 8px; } .mb-md { margin-bottom: 16px; } .mb-lg { margin-bottom: 28px; }
.flex-1 { flex: 1; }
.text-right { text-align: right; }
.text-mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
[hidden] { display: none !important; }
