/*
 * theme.css — Sales Command Center. Values taken from the Sales.AI CRM
 * dashboard: Inter, white working surfaces, hairline grey borders, blue
 * figures and links, a near-black active pill, pale red for cells that need
 * attention. Dense and calm, like the existing Sales CRM screens.
 */

:root {
  --canvas: #f8f9fb;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --border: #e6e8ec;
  --border-strong: #d0d4db;
  --ink: #111827;
  --muted: #5f6672;
  --accent: #18181b;
  --accent-hover: #3f3f46;
  --accent-ink: #ffffff;
  --accent-text: #1d5fd8;
  --accent-strong: #1d4ed8;
  --accent-soft: #eef4ff;
  --accent-border: #c7d8fb;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #e3f6ea;
  --success-strong: #166534;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #fdf3dc;
  --warning-strong: #8a3c06;
  --danger: #dc2626;
  --danger-ink: #ffffff;
  --danger-soft: #fdeeee;
  --danger-strong: #b91c1c;
  --chart-1: #2563eb;
  --chart-2: #18181b;
  --chart-3: #16a34a;
  --chart-4: #f59e0b;
  --chart-5: #dc2626;
  --chart-6: #8b5cf6;

  --font-display: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 600;
  --display-tracking: -0.015em;
  --eyebrow-tracking: 0.06em;

  --radius-btn: 0.5rem;
  --radius-input: 0.5rem;
  --radius-card: 0.75rem;
  --border-w: 1px;
  --border-strong-w: 1px;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-raised: 0 16px 40px rgba(0, 0, 0, 0.14);
  --shadow-btn: none;
  --card-pad: 1.25rem;
  --btn-weight: 500;
  --caps: none;
  --caps-tracking: 0.04em;
}

html[data-theme="dark"] {
  --canvas: #0b0d12;
  --surface: #12151c;
  --surface-2: #191d26;
  --border: #252a35;
  --border-strong: #3a4150;
  --ink: #f2f4f7;
  --muted: #a0a7b4;
  --accent: #f4f4f5;
  --accent-hover: #d4d4d8;
  --accent-ink: #18181b;
  --accent-text: #7cb0ff;
  --accent-strong: #a9c8ff;
  --accent-soft: #15213d;
  --accent-border: #26407a;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #0f2a1a;
  --success-strong: #6ee59a;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #2e1f0a;
  --warning-strong: #f5c56b;
  --danger: #dc2626;
  --danger-ink: #ffffff;
  --danger-soft: #2f1215;
  --danger-strong: #fb8b8b;
  --chart-1: #6ea2ff;
  --chart-2: #e4e4e7;
  --chart-3: #4ade80;
  --chart-4: #fbbf24;
  --chart-5: #f87171;
  --chart-6: #b49cfc;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-raised: 0 16px 40px rgba(0, 0, 0, 0.55);
}

/* app.css — the Sales Command Center's own pieces, in tokens only. */

/* ---- frame ------------------------------------------------------------- */
.app-frame { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; width: 15.5rem; flex-shrink: 0;
  display: none; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
@media (min-width: 64rem) { .sidebar { display: flex; } }
.side-label { @apply px-3 pb-1 pt-2 text-xs font-medium text-muted; }
.side-link {
  @apply flex h-10 items-center gap-3 rounded-lg px-3 text-sm font-medium text-ink transition-colors duration-150;
}
.side-link:hover { background: var(--surface-2); text-decoration: none; }
.side-link.is-active { background: var(--accent); color: var(--accent-ink); }
.side-link .icon { width: 1.05rem; height: 1.05rem; }
.brand-mark {
  @apply grid size-8 place-items-center rounded-full;
  background: var(--accent); color: var(--accent-ink);
}
.brand-mark .icon { width: 1rem; height: 1rem; }

.topbar {
  @apply sticky top-0 z-20 flex h-16 items-center justify-between gap-3 px-4 sm:px-6 lg:px-8;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(8px);
}
.page-title { @apply text-2xl font-semibold tracking-tight text-ink; font-family: var(--font-display); }
.select-sm { @apply h-9 w-56 text-sm; }

/* ---- lifecycle and command tiles -------------------------------------- */
.life-tile {
  @apply flex flex-col gap-1 rounded-xl border border-border bg-surface p-4 text-ink transition-colors duration-150;
  box-shadow: var(--shadow-card);
}
a.life-tile:hover { border-color: var(--border-strong); text-decoration: none; }
.life-label { @apply flex items-center gap-2 text-xs font-medium text-muted; }
.life-label .icon { width: 0.95rem; height: 0.95rem; }
.life-num { @apply text-3xl font-semibold tabular-nums tracking-tight; }
.life-note { @apply text-xs text-muted; }

.cmd-tile {
  @apply relative flex min-h-32 flex-col rounded-xl border border-border bg-surface p-4 text-ink transition-[border-color,transform] duration-150;
  box-shadow: var(--shadow-card);
}
.cmd-tile:hover { border-color: var(--border-strong); text-decoration: none; transform: translateY(-1px); }
.cmd-icon { @apply mb-3 grid size-8 place-items-center rounded-lg; background: var(--surface-2); color: var(--muted); }
.cmd-icon .icon { width: 1rem; height: 1rem; }
.tone-blue .cmd-icon { background: var(--accent-soft); color: var(--accent-strong); }
.tone-warn .cmd-icon { background: var(--warning-soft); color: var(--warning-strong); }
.tone-danger .cmd-icon { background: var(--danger-soft); color: var(--danger-strong); }
.cmd-num { @apply text-2xl font-semibold tabular-nums leading-none; color: var(--accent-text); }
.tone-danger .cmd-num { color: var(--danger-strong); }
.cmd-label { @apply mt-2 text-sm font-medium; }
.cmd-note { @apply mt-0.5 text-xs text-muted; }

/* ---- team performance table (mirrors the Sales CRM dashboard) --------- */
.team-table th, .team-table td { @apply px-3 py-3; }
.team-table thead th { @apply text-[0.6875rem] font-semibold uppercase tracking-wide; background: var(--surface-2); }
.team-table .group-row th { @apply pb-1 pt-3 text-center; box-shadow: none; }
.team-table .group-th { border-bottom: 1px solid var(--border); }
.team-table .sep, .team-table .group-th + .group-th { border-left: 1px solid var(--border); }
.team-table td.num { @apply text-right align-top; }
.fig { @apply block text-sm font-medium tabular-nums; color: var(--accent-text); }
a.fig:hover { text-decoration: underline; }
.fig-zero { color: var(--ink); font-weight: 400; }
.pct { @apply block text-[0.6875rem] tabular-nums text-muted; }
.cell-hot { background: var(--danger-soft); }
.cell-hot .fig, .cell-hot .pct { color: var(--danger-strong); font-weight: 600; }
.team-table tfoot td { @apply py-3; background: var(--surface-2); border-top: 1px solid var(--border); }
.role-tag {
  @apply mt-0.5 inline-flex h-4.5 items-center rounded px-1.5 text-[0.625rem] font-semibold;
  background: var(--accent-soft); color: var(--accent-strong); border: 1px solid var(--accent-border);
}

/* ---- agenda ------------------------------------------------------------ */
.agenda-row { @apply flex items-center gap-3 px-5 py-3 transition-colors duration-150; }
.agenda-row:hover { background: var(--surface-2); text-decoration: none; }
.agenda-dot { @apply size-2 shrink-0 rounded-full; background: var(--warning); }
.agenda-dot.is-late { background: var(--danger); }

/* ---- stage pill -------------------------------------------------------- */
.stage-pill { @apply inline-flex items-center gap-2 whitespace-nowrap text-xs font-medium text-ink; }
.stage-bars { @apply inline-flex gap-0.5; }
.stage-bars i { @apply block h-2.5 w-1.5 rounded-sm; background: var(--border); }
.stage-bars i.on { background: var(--accent-text); }

/* ---- leads list -------------------------------------------------------- */
.filter-bar { @apply grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-6; }
.filter-bar .input { @apply h-9 text-sm; }
@media (min-width: 64rem) { .filter-search { grid-column: span 2 / span 2; } }
.filter-bar .input-group .icon { width: 1rem; height: 1rem; }
.row-link a:hover .font-medium { color: var(--accent-text); }
.lead-av { background: var(--surface-2); color: var(--ink); }

/* ---- lead page: the five questions ------------------------------------ */
.q-grid { @apply grid grid-cols-1 overflow-hidden rounded-xl border border-border sm:grid-cols-2 xl:grid-cols-5; }
.q-cell { @apply relative flex flex-col gap-1.5 p-4; border-bottom: 1px solid var(--border); background: var(--surface); }
@media (min-width: 80rem) { .q-cell { border-bottom: 0; border-right: 1px solid var(--border); } .q-cell:last-child { border-right: 0; } }
.q-num { @apply absolute right-3 top-3 grid size-5 place-items-center rounded-full text-[0.625rem] font-semibold; background: var(--surface-2); color: var(--muted); }
.q-label { @apply pr-6 text-xs text-muted; }
.q-value { @apply min-h-6; }

/* ---- stepper ----------------------------------------------------------- */
.stepper { @apply grid grid-cols-5 gap-1; }
.stepper li { position: relative; }
.stepper li::before {
  content: ""; position: absolute; top: 0.875rem; left: -50%; width: 100%; height: 2px; background: var(--border);
}
.stepper li:first-child::before { display: none; }
.stepper li.is-done::before, .stepper li.is-current::before { background: var(--accent-text); }
.step-btn { @apply relative flex w-full flex-col items-center gap-1.5 rounded-lg py-1 text-center; background: transparent; border: 0; cursor: default; }
button.step-btn { cursor: pointer; }
button.step-btn:hover .step-dot { border-color: var(--accent-text); color: var(--accent-text); }
.step-dot {
  @apply relative z-[1] grid size-7 place-items-center rounded-full text-xs font-semibold transition-colors duration-150;
  background: var(--surface); border: 2px solid var(--border-strong); color: var(--muted);
}
.is-done .step-dot { background: var(--accent-text); border-color: var(--accent-text); color: var(--surface); }
.is-current .step-dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px var(--accent-soft); }
.step-label { @apply text-[0.6875rem] font-medium text-muted sm:text-xs; }
.is-current .step-label { color: var(--ink); font-weight: 600; }

/* ---- timeline ---------------------------------------------------------- */
.timeline { @apply relative flex flex-col; }
.tl-item { @apply relative flex gap-3 pb-5; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: 0.8125rem; top: 1.75rem; bottom: 0.25rem; width: 1px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-icon {
  @apply relative z-[1] grid size-6.5 shrink-0 place-items-center rounded-full;
  background: var(--accent-soft); color: var(--accent-strong);
}
.tl-item.is-in .tl-icon { background: var(--success-soft); color: var(--success-strong); }
.tl-item.is-system .tl-icon { background: var(--surface-2); color: var(--muted); }

/* ---- tasks, demos, escalation ----------------------------------------- */
.task-row { @apply flex items-start gap-3 rounded-lg border border-border p-3; }
.task-check {
  @apply grid size-5.5 shrink-0 place-items-center rounded-md transition-colors duration-150;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: transparent; cursor: pointer;
}
.task-check:hover { border-color: var(--success); color: var(--success-strong); background: var(--success-soft); }
.demo-row { @apply rounded-lg border border-border p-3; }
.kv { @apply grid grid-cols-[6rem_1fr] gap-x-3 gap-y-2 text-sm; }
.kv dt { color: var(--muted); }
.kv dd { color: var(--ink); }
.escalate-card > summary { list-style: none; }
.escalate-card > summary::-webkit-details-marker { display: none; }

.chip-scroll { overflow-x: auto; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }
.seg { @apply flex w-max gap-2; }

.demo-date {
  @apply flex w-20 shrink-0 flex-col rounded-lg px-2.5 py-1.5 text-xs;
  background: var(--accent-soft); color: var(--accent-strong);
}
.demo-date b { @apply text-sm font-semibold; }
.demo-date.is-late { background: var(--danger-soft); color: var(--danger-strong); }

.journey { @apply flex flex-col gap-4; }
.journey li { @apply relative pl-5; }
.journey li::before { content: ""; position: absolute; left: 0; top: 0.4rem; width: 0.5rem; height: 0.5rem; border-radius: 999px; background: var(--accent-text); }
.journey li:last-child::before { background: var(--success); }

/* the one moment that moves: content arriving after a filter */
#lead-results.htmx-settling { animation: fade-in 180ms ease-out both; }
html.reduced-motion #lead-results.htmx-settling { animation: none; }
