/* ============ Sales Pipeline — Management Dashboard ============ */
/* Theme: warm-neutral enterprise, Geist sans + mono */

:root {
  --bg: #ECEDEA;          /* app background — warm signature neutral */
  --surface: #FFFFFF;     /* cards, sidebar, panels */
  --surface-2: #F5F6F2;   /* table rows, input backgrounds */
  --surface-3: #EDEEE9;   /* hover fills, chips */
  --border: #E0E2DC;
  --border-strong: #CDCFC7;
  --ink: #111827;         /* headings, primary */
  --ink-2: #374151;       /* body */
  --ink-3: #6B7280;       /* labels, placeholders, metadata */
  --ink-4: #9CA3AF;       /* timestamps, idle */

  --accent: #1F6E5A;       /* signature deep evergreen */
  --accent-soft: #E4F0EC;  /* accent backgrounds */
  --accent-ink: #15503F;   /* accent text on light */

  --won: #059669;
  --won-soft: #ECFDF5;
  --lost: #DC2626;
  --lost-soft: #FEF2F2;
  --warn: #D97706;
  --warn-soft: #FFFBEB;
  --info: #2563EB;
  --info-soft: #EFF6FF;

  /* Stage colors */
  --s-possible: #6366F1;
  --s-in_progress: #F59E0B;
  --s-on_hold: #64748B;
  --s-sold: #059669;
  --s-lost: #DC2626;

  /* Showroom colors */
  --ss-bay: #4F63D2;
  --ss-pak: #2563EB;
  --ss-che: #059669;
  --ss-cap: #D97706;

  --shadow-sm: 0 1px 3px rgba(17,24,39,0.06), 0 1px 2px rgba(17,24,39,0.04);
  --shadow-md: 0 4px 12px rgba(17,24,39,0.08);
  --shadow-lg: 0 20px 60px rgba(17,24,39,0.12);

  /* Sidebar — each theme gives it a distinct rich dark treatment */
  --sidebar-bg: #163A2E;
  --sidebar-ink: #EAF2EE;
  --sidebar-dim: #9DB5AC;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active: rgba(87,199,158,0.16);
  --sidebar-accent: #57C79E;
  --sidebar-border: rgba(255,255,255,0.09);

  /* Theme typeface */
  --font: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;

  --r-sm: 4px;
  --r-md: 7px;
  --r-lg: 10px;
  --r-xl: 14px;
}

/* Alternate theme palettes are applied inline on <html> at runtime from
   window.THEME_TOKENS (see Settings.jsx). :root above is the "Pine" default,
   which is also the no-JS fallback. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font, 'Inter', system-ui, -apple-system, sans-serif);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}
.mono, .num { font-family: 'Geist Mono', ui-monospace, monospace; font-feature-settings: 'tnum'; letter-spacing: -0.01em; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ===== App shell ===== */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 14px 8px;
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: background 0.25s ease;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 12px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 12px;
}
.brand-mark {
  min-width: 32px;
  height: 28px;
  padding: 0 4px;
  background: var(--accent);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700;
  font-size: 11px;
  letter-spacing: -0.02em;
}
.brand-name { font-weight: 600; color: var(--sidebar-ink); font-size: 12.5px; letter-spacing: -0.01em; line-height: 1.2; }
.brand-logo {
  width: 100%;
  max-width: 160px;
  max-height: 48px;
  object-fit: contain;
  display: block;
  background: #fff;
  padding: 6px 9px;
  border-radius: 7px;
}
.powered-by {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--sidebar-dim);
  padding: 6px 12px 0;
  letter-spacing: 0.01em;
}
.powered-by strong { color: var(--sidebar-ink); font-weight: 600; }
.pb-mark {
  width: 13px; height: 13px; border-radius: 4px;
  background: var(--sidebar-accent); position: relative; flex-shrink: 0;
}
.pb-mark::after { content: ''; position: absolute; top: 3px; right: 3px; width: 4px; height: 4px; border-radius: 50%; background: white; }
.pb-mark::before { content: ''; position: absolute; left: 3px; bottom: 3px; width: 6px; height: 1.5px; border-radius: 1px; background: white; }
.brand-sub { color: var(--sidebar-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; }

.nav-section { margin-bottom: 4px; }
.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-dim);
  opacity: 0.85;
  font-weight: 600;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: 36px;
  margin: 2px 0;
  border-radius: 7px;
  cursor: pointer;
  color: var(--sidebar-dim);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-ink); }
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-ink);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--sidebar-accent);
}
.nav-item .nav-icon { width: 16px; display: flex; color: var(--sidebar-dim); }
.nav-item:hover .nav-icon { color: var(--sidebar-ink); }
.nav-item.active .nav-icon { color: var(--sidebar-accent); }
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background: var(--sidebar-accent);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--sidebar-bg);
}
.nav-item.active .nav-badge { background: var(--sidebar-accent); color: var(--sidebar-bg); }

/* Help: spotlight a nav item while its demo drawer is open */
.nav-item.spotlight {
  background: var(--sidebar-active);
  color: var(--sidebar-ink);
  box-shadow: inset 3px 0 0 var(--sidebar-accent), 0 0 0 2px var(--sidebar-accent);
  animation: navSpotPulse 1.7s ease-in-out infinite;
}
.nav-item.spotlight .nav-icon { color: var(--sidebar-accent); }
@keyframes navSpotPulse {
  0%, 100% { box-shadow: inset 3px 0 0 var(--sidebar-accent), 0 0 0 2px color-mix(in oklch, var(--sidebar-accent) 50%, transparent); }
  50%      { box-shadow: inset 3px 0 0 var(--sidebar-accent), 0 0 0 5px color-mix(in oklch, var(--sidebar-accent) 12%, transparent); }
}
@keyframes demoScrub {
  from { width: 0%; }
  to   { width: 100%; }
}
.auth-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: authSpin 0.7s linear infinite;
}
@keyframes authSpin { to { transform: rotate(360deg); } }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 8px 4px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

/* ===== Main canvas ===== */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar > div:first-child { flex-shrink: 0; min-width: 0; }
.page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
  line-height: 1.2;
}
.page-sub {
  color: var(--ink-3);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.topbar-search {
  margin-left: auto;
  position: relative;
}
.topbar-search input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px 7px 32px;
  height: 36px;
  width: 320px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.topbar-search input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar-search .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); pointer-events: none;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px;
  height: 34px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(17,24,39,0.18);
}
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.accent {
  background: var(--accent); color: white; border-color: var(--accent);
}
.btn.accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.icon { padding: 0; width: 34px; justify-content: center; }
.btn.icon.sm { width: 28px; }

.canvas {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
}
.canvas.no-pad { padding: 0; }

/* ===== Cards & sections ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-hd {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.card-sub { color: var(--ink-3); font-size: 12px; margin-top: 2px; }

.grid-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-click { position: relative; cursor: pointer; border-radius: var(--r-lg); }
.kpi-click .kpi { transition: border-color 0.15s, box-shadow 0.15s; height: 100%; }
.kpi-click:hover .kpi { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.kpi-click.on .kpi { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.kpi-filtering {
  position: absolute; top: 10px; right: 12px;
  font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: white; background: var(--accent); padding: 2px 6px; border-radius: 4px;
}
.kpi {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  font-weight: 500;
}
.kpi-value {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-top: 8px;
  line-height: 1;
}
.kpi-meta {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 11.5px;
}
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 500; }
.delta.up { color: var(--won); }
.delta.down { color: var(--lost); }
.delta.flat { color: var(--ink-3); }
.kpi-foot { color: var(--ink-3); font-size: 11px; white-space: nowrap; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.grid-2-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ===== Tables ===== */
.tbl-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.tbl thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  padding: 9px 14px;
  height: 36px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  position: sticky; top: 0;
  white-space: nowrap;
  user-select: none;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable:hover { color: var(--ink); }
.tbl thead th .sort-ind { margin-left: 4px; opacity: 0.6; font-size: 9px; }
.tbl thead th.num-col, .tbl tbody td.num-col { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr { transition: background 0.1s; }
.tbl tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.tbl tbody tr.selected { background: var(--accent-soft); }

/* ===== Pills, badges ===== */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
}
.stage-pill { background: var(--surface-3); }
.stage-pill[data-stage="possible"] .dot { background: var(--s-possible); }
.stage-pill[data-stage="in_progress"] .dot { background: var(--s-in_progress); }
.stage-pill[data-stage="on_hold"] .dot { background: var(--s-on_hold); }
.stage-pill[data-stage="sold"] { background: var(--won-soft); color: oklch(0.35 0.1 155); }
.stage-pill[data-stage="sold"] .dot { background: var(--won); }
.stage-pill[data-stage="lost"] { background: var(--lost-soft); color: oklch(0.4 0.12 28); }
.stage-pill[data-stage="lost"] .dot { background: var(--lost); }

.pill.warn { background: var(--warn-soft); color: oklch(0.45 0.11 60); }
.pill.warn .dot { background: var(--warn); }
.pill.info { background: var(--info-soft); color: oklch(0.4 0.09 240); }
.pill.info .dot { background: var(--info); }

.customer-cell {
  display: flex; align-items: center; gap: 10px;
}
.customer-meta { display: flex; flex-direction: column; gap: 1px; }
.customer-name { font-weight: 500; color: var(--ink); }
.customer-sub { color: var(--ink-3); font-size: 11px; }

.rep-cell { display: flex; align-items: center; gap: 8px; }

/* ===== Pipeline / kanban ===== */
.pipeline-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 28px 0;
}
.pipeline-toolbar .pt-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  font-weight: 600;
}
.pipeline-search {
  position: relative;
  width: 340px;
  max-width: 42vw;
}
.pipeline-search .search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); pointer-events: none; display: flex;
}
.pipeline-search input {
  width: 100%; height: 34px;
  padding: 0 30px 0 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px; color: var(--ink); outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.pipeline-search input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.pipeline-search .ps-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 50%; border: none;
  background: var(--surface-3); color: var(--ink-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; padding: 0;
}
.pipeline-search .ps-clear:hover { background: var(--border-strong); color: var(--ink); }
.pipeline-match-count {
  font-size: 11.5px; color: var(--ink-3); font-weight: 600; white-space: nowrap;
}
.pipeline-toolbar .seg { margin-left: auto; }
.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(280px, 1fr));
  gap: 12px;
  padding: 20px 28px;
  min-height: 100%;
  align-items: start;
}

/* Compact board — denser columns & cards */
.kanban.compact {
  gap: 10px;
  padding: 14px 28px;
}
.kanban.compact .kanban-col-hd { padding: 9px 12px 8px; }
.kanban.compact .col-total {
  margin: 0 8px 8px;
  padding: 6px 10px;
}
.kanban.compact .col-total .ct-amount { font-size: 16px; }
.kanban.compact .kanban-list { padding: 8px; gap: 6px; }
.kanban.compact .deal-card { padding: 7px 10px; }
.kanban.compact .deal-card-hd { margin-bottom: 3px; }
.kanban.compact .deal-card-customer { font-size: 12px; margin-bottom: 0; }
.kanban.compact .deal-card-foot { font-size: 10px; margin-top: 5px; }
.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  min-height: 200px;
  transition: background 0.15s;
}
.kanban-col.drop { background: var(--accent-soft); border-color: var(--accent); }
.kanban-col-hd {
  padding: 12px 14px 10px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border);
}
.col-dot { width: 8px; height: 8px; border-radius: 50%; }
.col-dot.possible { background: var(--s-possible); }
.col-dot.in_progress { background: var(--s-in_progress); }
.col-dot.on_hold { background: var(--s-on_hold); }
.col-dot.sold { background: var(--s-sold); }
.col-dot.lost { background: var(--s-lost); }
.col-title { font-weight: 600; font-size: 12px; letter-spacing: -0.005em; }
.col-count {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.col-total {
  margin: 0 10px 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.col-total .ct-amount {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.col-total .ct-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  font-weight: 500;
}
.kanban-list {
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
  flex: 1;
  min-height: 60px;
}
.deal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: grab;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
  user-select: none;
}
.deal-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.deal-card.dragging { opacity: 0.5; transform: rotate(-1deg); }
.deal-card-hd {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.deal-id { font-size: 10.5px; color: var(--ink-3); }
.deal-value { font-size: 13px; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.deal-card-customer { font-weight: 500; font-size: 13px; margin-bottom: 1px; }
.deal-card-product { font-size: 11.5px; color: var(--ink-3); margin-bottom: 8px; }
.deal-card-foot {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; color: var(--ink-3);
}
.deal-card-foot .age {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 3px;
}
.age.stuck { color: var(--lost); font-weight: 500; }
.age.warn { color: oklch(0.55 0.13 60); font-weight: 500; }

/* ===== Bar charts ===== */
.chart-row {
  display: grid;
  grid-template-columns: 110px 1fr 80px;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  font-size: 12px;
}
.chart-row .lbl { color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.chart-row .bar-wrap {
  position: relative;
  height: 22px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.chart-row .bar {
  height: 100%;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 8px;
  color: white;
  font-size: 10.5px;
  font-weight: 500;
  transition: width 0.4s ease;
}
.chart-row .val { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-2); }
.bar.possible { background: var(--s-possible); }
.bar.in_progress { background: var(--s-in_progress); }
.bar.on_hold { background: var(--s-on_hold); }
.bar.sold { background: var(--s-sold); }
.bar.lost { background: var(--s-lost); }
.bar.won { background: var(--won); }
.bar.accent { background: var(--accent); }
.bar.ink { background: var(--ink); }

/* Funnel */
.funnel {
  display: flex; flex-direction: column; gap: 4px;
  align-items: center;
  padding: 8px 0;
}
.funnel-row {
  display: flex; align-items: center;
  width: 100%;
  gap: 14px;
}
.funnel-row .lbl {
  width: 110px; flex-shrink: 0;
  font-size: 12px; color: var(--ink-2);
}
.funnel-bar-wrap {
  flex: 1;
  display: flex; justify-content: center;
}
.funnel-bar {
  height: 36px;
  background: var(--ink);
  color: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: width 0.4s ease;
  min-width: 140px;
}
.funnel-row .conv {
  width: 70px;
  text-align: right;
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Sparklines / area charts (SVG) */
.area-chart { width: 100%; height: 200px; display: block; }

/* ===== Access control: user switcher, role pills, restricted banner ===== */
.role-pill {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
  margin-left: auto;
}
.role-pill.admin {
  background: var(--lost-soft);
  color: var(--lost);
}
.role-pill.leadership {
  background: #F5F3FF;
  color: #6D28D9;
}
.role-pill.manager {
  background: var(--warn-soft);
  color: var(--warn);
}
.role-pill.sales_designer {
  background: var(--info-soft);
  color: var(--info);
}
.role-pill.salesperson {
  background: var(--info-soft);
  color: var(--info);
}

.user-picker {
  position: fixed;
  bottom: 80px;
  left: 12px;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  max-height: min(480px, calc(100vh - 100px));
  overflow-y: auto;
}
.up-section { padding: 4px 0; }
.up-section + .up-section { border-top: 1px solid var(--border); margin-top: 4px; }
.up-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  padding: 6px 10px 4px;
  font-weight: 600;
}
.up-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--ink-2);
  transition: background 0.12s;
}
.up-item:hover { background: var(--surface-3); }
.up-item.on { background: var(--accent-soft); }
.up-name { font-size: 12.5px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-sub { font-size: 10.5px; color: var(--ink-3); }
.up-foot {
  padding: 8px 10px;
  font-size: 10.5px;
  color: var(--ink-3);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 5px;
  margin-top: 4px;
}

.access-banner {
  display: flex; align-items: center; gap: 6px;
  background: var(--warn-soft);
  color: oklch(0.4 0.11 60);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid oklch(0.85 0.08 70);
  font-weight: 500;
}
.access-banner strong { font-weight: 600; }

.ss-locked {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--ink-3);
  padding: 4px 9px;
  margin-left: 4px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
}

/* ===== Admin: status pill, role card, showroom picker, invite modal ===== */
.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.status-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}
.status-pill.active { background: var(--won-soft); color: oklch(0.35 0.1 155); }
.status-pill.active .dot { background: var(--won); }
.status-pill.invited { background: var(--warn-soft); color: oklch(0.4 0.11 60); }
.status-pill.invited .dot { background: var(--warn); }
.status-pill.disabled { background: var(--surface-3); color: var(--ink-3); }
.status-pill.disabled .dot { background: var(--ink-3); }

.role-card {
  flex: 1;
  text-align: left;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.role-card:hover:not(:disabled) { border-color: var(--border-strong); }
.role-card.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.role-card:disabled { opacity: 0.5; cursor: not-allowed; }

.showroom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sh-pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.sh-pick:hover { border-color: var(--border-strong); }
.sh-pick.on {
  border-color: var(--ink);
  background: var(--surface-2);
}

.checkbox {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  flex-shrink: 0;
}
.checkbox.on {
  background: var(--ink);
  border-color: var(--ink);
}

.home-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: 10.5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-3);
  border-radius: 4px;
  cursor: pointer;
}
.home-btn:hover { color: var(--ink); border-color: var(--border-strong); }
.home-btn.on {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.invite-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 560px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: modalIn 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes modalIn {
  from { transform: translate(-50%, -48%); opacity: 0; }
  to { transform: translate(-50%, -50%); opacity: 1; }
}

/* Reassignment picker */
.reassign-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.reassign-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.12s, background 0.12s;
}
.reassign-row:hover { border-color: var(--border-strong); }
.reassign-row.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.reassign-row.disabled {
  cursor: not-allowed;
  background: var(--surface-2);
  pointer-events: none;
}
.radio {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  flex-shrink: 0;
}
.radio.on { border-color: var(--accent); }
.radio.disabled { opacity: 0.4; }
.radio-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* Bulk selection action bar */
.bulk-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 40;
  font-size: 13px;
  font-weight: 500;
  animation: slideUp 0.18s ease;
}
.bulk-bar .bb-count {
  background: var(--accent);
  color: white;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.bulk-bar .bb-divider {
  width: 1px;
  height: 18px;
  background: oklch(0.35 0.012 70);
}
.bulk-bar button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  color: white;
  font-size: 12.5px;
  font-weight: 500;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s;
}
.bulk-bar button:hover { background: oklch(0.32 0.012 70); }
.bulk-bar button.danger { color: oklch(0.85 0.06 30); }
.bulk-bar button.primary { background: var(--accent); }
.bulk-bar button.primary:hover { background: var(--accent-ink); }

/* Row checkbox column */
.tbl .row-check {
  width: 28px;
  text-align: center;
  vertical-align: middle;
}
.tbl tbody tr.row-selected {
  background: var(--accent-soft);
}
.tbl tbody tr.row-selected:hover {
  background: color-mix(in oklch, var(--accent) 12%, var(--surface));
}

.drop-active {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
}

.quick-remind-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.quick-remind-row .lbl { font-size: 11px; color: var(--ink-3); }

/* ===== Calendar layout ===== */
.my-month {
  position: relative;
  padding: 9px 0;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.my-month:hover { border-color: var(--border-strong); background: var(--surface-2); }
.my-month.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.my-today-dot {
  position: absolute; top: 5px; right: 6px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
}
.cal-daycell-events::-webkit-scrollbar { width: 6px; }
.cal-daycell-events::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.cal-daycell-events::-webkit-scrollbar-track { background: transparent; }
.cal-daycell-events { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.cal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr); }
  .cal-side { flex-direction: row; flex-wrap: wrap; }
  .cal-side > .card { flex: 1; min-width: 260px; }
}

/* ===== Contact Journey visualization ===== */
.journey {
  display: flex;
  align-items: flex-start;
  gap: 0;
}
.j-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 0 0 auto;
  min-width: 0;
  padding: 0 2px;
}
.j-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.j-dot-inner {
  width: 6px; height: 6px;
  background: var(--ink-4);
  border-radius: 3px;
}
.j-step.achieved .j-dot {
  background: var(--won);
  border-color: var(--won);
}
.j-step.current .j-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 18%, transparent);
}
.j-step.lost-branch .j-dot {
  background: var(--lost);
  border-color: var(--lost);
}
.j-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.j-step.achieved .j-label,
.j-step.current .j-label {
  color: var(--ink);
}
.j-step.current .j-label { font-weight: 600; }
.j-step.lost-branch .j-label { color: var(--lost); }
.j-sub {
  font-size: 9.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1px;
  white-space: nowrap;
}
.j-line {
  height: 2px;
  background: var(--border);
  flex: 1;
  margin: 13px -4px 0;
  min-width: 12px;
  transition: background 0.2s;
}
.j-line.achieved {
  background: var(--won);
}
.j-line.lost-branch {
  background: linear-gradient(to right, var(--won) 0%, var(--lost) 100%);
}

/* Missing-detail highlight (contacts table) */
/* Missing-detail highlight (contacts table) */
.missing-detail {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--lost);
  background: var(--lost-soft);
  border: 1px dashed color-mix(in oklch, var(--lost) 35%, transparent);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 500;
}

@media print {
  .sidebar, .topbar, .showroom-switcher, .filters-bar, .topbar-actions, .seg, .toast, .tweaks-panel, button.btn { display: none !important; }
  .app { display: block; }
  .canvas { padding: 0 !important; overflow: visible !important; }
  body { background: white; font-size: 11px; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; margin-bottom: 12px; }
  .tbl-wrap { overflow: visible !important; max-height: none !important; }
  table { font-size: 10px; }
  .grid-kpis, .grid-2, .grid-2-eq { page-break-inside: avoid; }
}

.preset-card {
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.preset-card:hover { border-color: var(--border-strong); }
.preset-card.on { border-color: var(--accent); background: var(--accent-soft); }

/* ===== Showroom switcher (top global filter) ===== */
.showroom-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 24px;
  height: 44px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.ss-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  margin-right: 6px;
  font-weight: 600;
  flex-shrink: 0;
}
.ss-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.ss-tab:hover { background: var(--surface-3); color: var(--ink-2); }
.ss-tab.on {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
  font-weight: 600;
}
.ss-tab-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
}
.ss-tab-dot.all { background: linear-gradient(135deg, oklch(0.6 0.12 30), oklch(0.55 0.12 200)); }
.ss-tab-dot.bay { background: oklch(0.55 0.13 30); }
.ss-tab-dot.pak { background: oklch(0.5 0.11 200); }
.ss-tab-dot.che { background: oklch(0.55 0.12 140); }
.ss-tab-dot.cap { background: oklch(0.55 0.13 70); }
.ss-tab-state {
  font-size: 10px;
  background: var(--surface-3);
  color: var(--ink-3);
  padding: 1px 5px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.ss-tab.on .ss-tab-state {
  background: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.85);
}
.ss-tab-count {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.ss-tab.on .ss-tab-count { color: rgba(255,255,255,0.7); }

/* Showroom comparison cards */
.showroom-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.sh-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 18px 14px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}
.sh-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.sh-card-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px;
}
.sh-card-bar.bay { background: oklch(0.55 0.13 30); }
.sh-card-bar.pak { background: oklch(0.5 0.11 200); }
.sh-card-bar.che { background: oklch(0.55 0.12 140); }
.sh-card-bar.cap { background: oklch(0.55 0.13 70); }
.sh-card-hd {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.sh-card-name { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.sh-card-state { font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.06em; }
.sh-card-rank {
  position: absolute; top: 14px; right: 16px;
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 1px 7px;
  border-radius: 999px;
}
.sh-card-rank.first { background: var(--won-soft); color: oklch(0.35 0.1 155); font-weight: 600; }
.sh-card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-bottom: 12px;
}
.sh-metric .lbl { font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.sh-metric .val { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.sh-metric .delta { font-size: 10.5px; margin-top: 1px; }
.sh-quota {
  margin-top: 6px;
}
.sh-quota-row {
  display: flex; justify-content: space-between;
  font-size: 11px; margin-bottom: 4px; color: var(--ink-3);
}
.sh-quota-bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.sh-quota-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.sh-quota-fill.over { background: var(--won); }

/* Funnel comparison grid */
.funnel-compare {
  display: grid;
  grid-template-columns: 100px repeat(4, 1fr);
  gap: 6px;
  align-items: center;
  font-size: 12px;
}
.fc-hd {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding: 6px 4px;
  font-weight: 500;
  text-align: center;
}
.fc-hd.lbl-col { text-align: left; }
.fc-cell {
  padding: 7px 8px;
  text-align: center;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  position: relative;
}
.fc-cell .pct { font-weight: 600; }
.fc-cell .cnt { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }
.fc-cell.on-active .cnt { color: rgba(255,255,255,0.75); }
.fc-stage-lbl {
  font-size: 12px;
  color: var(--ink-2);
  padding-right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== Filters bar ===== */
.filters-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 24px;
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
.filter-chip:hover { border-color: var(--border-strong); }
.filter-chip.active { background: var(--accent); color: white; border-color: var(--accent); }
.filter-chip .x { font-size: 12px; opacity: 0.7; margin-left: 2px; }

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}
.seg button {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-3);
  border-radius: 4px;
  white-space: nowrap;
}
.seg button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Reports tab strip — darker, prominent selected state */
.seg.seg-reports button.on {
  background: var(--ink);
  color: #fff;
  box-shadow: none;
}
.seg.seg-reports button:not(.on):hover { color: var(--ink); }

select.sel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 26px 5px 10px;
  font-size: 12px;
  color: var(--ink-2);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='none' stroke='%23888' stroke-width='1.4' d='M2 4l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}

/* ===== Detail panel ===== */
.detail-overlay {
  position: fixed; inset: 0;
  background: oklch(0.2 0.01 70 / 0.35);
  z-index: 50;
  animation: fadeIn 0.15s ease;
}
.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 540px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  z-index: 51;
  animation: slideIn 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.detail-hd {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.detail-row1 { display: flex; align-items: center; gap: 10px; }
.detail-id { font-size: 11px; color: var(--ink-3); }
.detail-close {
  margin-left: auto;
  padding: 4px;
  border-radius: 4px;
  color: var(--ink-3);
}
.detail-close:hover { background: var(--surface-2); color: var(--ink); }
.detail-customer { font-size: 22px; font-weight: 600; letter-spacing: -0.025em; }
.detail-body { flex: 1; overflow-y: auto; padding: 18px 22px 30px; }
.detail-section { margin-bottom: 22px; }
/* Clear separators between detail sections */
.detail-body .detail-section + .detail-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}
.detail-section.section-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
.detail-body .detail-section.section-card + .detail-section,
.detail-body .detail-section + .detail-section.section-card {
  border-top: 0;
}
.detail-section h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); margin: 0 0 10px; font-weight: 500;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.detail-field { display: flex; flex-direction: column; gap: 2px; }
.detail-field .lbl { font-size: 11px; color: var(--ink-3); }
.detail-field .val { font-size: 13px; }
.detail-field .val.editable {
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: text;
}
.detail-field .val.editable:hover { border-color: var(--border); background: var(--surface-2); }
.detail-field input, .detail-field select, .detail-field textarea {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: var(--surface);
  outline: none;
  width: 100%;
}
.detail-field input:focus, .detail-field select:focus, .detail-field textarea:focus {
  border-color: var(--ink-3);
}

.stage-track {
  display: flex; gap: 4px;
  margin-bottom: 8px;
}
.stage-track .seg-step {
  flex: 1;
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
}
.stage-track .seg-step.on { background: var(--accent); }

.activity-list { display: flex; flex-direction: column; gap: 10px; }
.activity-item {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 12px;
}
.activity-dot {
  margin-top: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
  flex-shrink: 0;
}
.activity-dot.call { background: var(--info); }
.activity-dot.email { background: var(--s-presentation); }
.activity-dot.meeting { background: var(--accent); }
.activity-dot.note { background: var(--ink-4); }
.activity-meta { color: var(--ink-3); font-size: 11px; }

/* ===== Leaderboard ===== */
.rep-row {
  display: grid;
  grid-template-columns: 30px 1.6fr 0.8fr 1fr 1fr 1fr 1.4fr;
  gap: 14px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.rep-row:last-child { border-bottom: 0; }
.rep-rank { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 12px; }
.rep-prog {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.rep-prog .fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.rep-prog .fill.over { background: var(--won); }

/* ===== Misc ===== */
.empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12px;
}
.divider { height: 1px; background: var(--border); margin: 14px 0; }

.scroll-y { overflow-y: auto; }

/* Forecast cards */
.forecast-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.fc-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.fc-label { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.fc-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.fc-foot { font-size: 11px; color: var(--ink-3); margin-top: 4px; }

/* Aging colour scale */
.age-cell { font-variant-numeric: tabular-nums; }
.age-cell.fresh { color: var(--ink-2); }
.age-cell.warm { color: oklch(0.55 0.13 60); font-weight: 500; }
.age-cell.hot { color: var(--lost); font-weight: 600; }

/* Inline-editable in row */
.cell-edit {
  background: transparent;
  border: 1px solid transparent;
  padding: 3px 6px;
  margin: -3px -6px;
  border-radius: 4px;
  width: calc(100% + 12px);
  font: inherit;
}
.cell-edit:focus {
  background: var(--surface);
  border-color: var(--ink-3);
  outline: none;
}

/* Heatmap-style supplier bubble */
.chip-soft {
  display: inline-block;
  padding: 1px 7px;
  font-size: 10.5px;
  background: var(--surface-3);
  color: var(--ink-2);
  border-radius: 999px;
  margin-right: 4px;
  margin-bottom: 2px;
}

/* Toast */
.toast {
  position: fixed; bottom: 20px; right: 24px;
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  animation: slideUp 0.18s ease;
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== ROI Calculator view ===== */
.roi-view { max-width: 1080px; }

.roi-controls {
  display: flex; flex-wrap: wrap; gap: 18px 32px; align-items: flex-end;
  padding: 14px 18px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.roi-ctrl-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 7px;
}
.roi-seg { display: flex; gap: 4px; }
.roi-seg button {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--ink-2); font-size: 12px; font-weight: 500;
  transition: border-color 0.13s, background 0.13s, color 0.13s;
}
.roi-seg button:hover { border-color: var(--border-strong); }
.roi-seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.roi-seg button .px { font-size: 10px; opacity: 0.7; margin-left: 5px; font-variant-numeric: tabular-nums; }
.roi-seg button.on .px { opacity: 0.85; }

.roi-rate { display: flex; align-items: center; gap: 7px; }
.roi-rate input {
  width: 62px; padding: 6px 9px; font: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2);
  text-align: right; font-variant-numeric: tabular-nums; color: var(--ink);
}
.roi-rate input:focus { outline: none; border-color: var(--ink-3); background: var(--surface); }
.roi-rate .pre, .roi-rate .post { color: var(--ink-3); font-size: 12.5px; }
.roi-billing { font-size: 12px; color: var(--ink-3); }
.roi-billing strong { color: var(--ink); font-weight: 600; }

.roi-hero { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 12px; }
.roi-hero-card {
  padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface);
}
.roi-hero-card.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.roi-hero-lbl {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; color: var(--ink-3);
}
.roi-hero-card.accent .roi-hero-lbl { color: rgba(255,255,255,0.82); }
.roi-hero-val { font-size: 38px; font-weight: 600; letter-spacing: -0.03em; margin-top: 7px; line-height: 1; font-variant-numeric: tabular-nums; }
.roi-hero-card:not(.accent) .roi-hero-val { font-size: 28px; }
.roi-hero-foot { font-size: 11px; color: var(--ink-3); margin-top: 8px; }
.roi-hero-card.accent .roi-hero-foot { color: rgba(255,255,255,0.85); }

.roi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.roi-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.roi-panel-hd { padding: 14px 18px 11px; border-bottom: 1px solid var(--border); }
.roi-panel-title { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.roi-panel-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.roi-panel-body { padding: 4px 18px 14px; }

.roi-mrow { padding: 12px 0; border-bottom: 1px solid var(--border); }
.roi-mrow:last-child { border-bottom: 0; }
.roi-mrow-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.roi-mrow-lbl { font-size: 13px; font-weight: 500; color: var(--ink); }
.roi-mrow-val { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.roi-mrow-val.risk { color: var(--lost); }
.roi-mrow-formula {
  font-family: 'Geist Mono', ui-monospace, monospace; font-size: 11px;
  color: var(--ink-3); margin-top: 5px; letter-spacing: -0.01em;
}
.roi-mrow-formula .eq { color: var(--ink); }

.roi-sbar { display: grid; grid-template-columns: 116px 1fr 92px; gap: 12px; align-items: center; padding: 6px 0; font-size: 12px; }
.roi-sbar-lbl { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.roi-sbar-dot { width: 8px; height: 8px; border-radius: 4px; flex-shrink: 0; }
.roi-sbar-wr { font-size: 10.5px; color: var(--ink-3); }
.roi-sbar-track { position: relative; height: 18px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.roi-sbar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; transition: width 0.4s ease; }
.roi-sbar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.roi-vbuild { display: flex; flex-direction: column; gap: 9px; }
.roi-vbuild-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; }
.roi-vbuild-row .lbl { color: var(--ink-2); }
.roi-vbuild-row .lbl small { display: block; color: var(--ink-3); font-size: 10.5px; margin-top: 1px; }
.roi-vbuild-row .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.roi-vbuild-row.total { border-top: 1px solid var(--border-strong); padding-top: 9px; margin-top: 2px; }
.roi-vbuild-row.total .v { color: var(--accent-ink); font-size: 15px; }

.roi-assumptions { margin-top: 12px; padding: 14px 18px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); }
.roi-assumptions h4 { margin: 0 0 9px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; }
.roi-assumptions ul { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 5px 28px; }
.roi-assumptions li { font-size: 11.5px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 10px; }
.roi-assumptions li b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.roi-assumptions .note { margin: 10px 0 0; font-size: 11px; color: var(--ink-3); }

@media (max-width: 1100px) {
  .roi-hero { grid-template-columns: 1fr 1fr; }
  .roi-grid { grid-template-columns: 1fr; }
}

/* ROI — sectioned layout */
.roi-section { margin-top: 26px; }
.roi-section-hd { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.roi-eyebrow {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em;
  font-weight: 700; color: var(--accent);
}
.roi-section-title { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.roi-section-note { font-size: 11.5px; color: var(--ink-3); margin-left: auto; }

.roi-stats { display: grid; gap: 12px; }
.roi-stats.cols-2 { grid-template-columns: 1fr 1fr; }
.roi-stats.cols-3 { grid-template-columns: repeat(3, 1fr); }
.roi-stats.cols-4 { grid-template-columns: 1.4fr 1fr 1fr 1fr; }

.roi-stat {
  padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface);
}
.roi-stat.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.roi-stat.risk { border-color: color-mix(in oklch, var(--lost) 35%, var(--border)); background: var(--lost-soft, var(--surface)); }
.roi-stat-lbl {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; color: var(--ink-3);
}
.roi-stat.accent .roi-stat-lbl { color: rgba(255,255,255,0.82); }
.roi-stat.risk .roi-stat-lbl { color: var(--lost); }
.roi-stat-val {
  font-size: 38px; font-weight: 600; letter-spacing: -0.03em; line-height: 1;
  margin-top: 8px; font-variant-numeric: tabular-nums;
}
.roi-stat.sub .roi-stat-val { font-size: 30px; }
.roi-stat.risk .roi-stat-val { color: var(--lost); }
.roi-stat-foot { font-size: 11px; color: var(--ink-3); margin-top: 9px; }
.roi-stat.accent .roi-stat-foot { color: rgba(255,255,255,0.85); }
.roi-stat-foot .mono { font-family: 'Geist Mono', ui-monospace, monospace; letter-spacing: -0.01em; }

/* Hourly-cost slider */
.roi-slider {
  padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); margin-bottom: 12px;
}
.roi-slider-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.roi-slider-top .lbl { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.roi-slider-top .lbl small { display: block; color: var(--ink-3); font-size: 11px; font-weight: 400; margin-top: 1px; }
.roi-slider-val { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.roi-slider-val span { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.roi-slider input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  border-radius: 3px; background: var(--surface-3); outline: none; cursor: pointer;
  accent-color: var(--accent);
}
.roi-slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
  border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--accent);
}
.roi-slider input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--accent);
}
.roi-slider-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-3); margin-top: 8px; font-variant-numeric: tabular-nums; }

/* What-if recovery callout */
.roi-whatif {
  margin-top: 26px; padding: 22px 24px; border-radius: var(--r-lg);
  background: var(--accent-soft); border: 1px solid var(--accent);
  display: flex; gap: 30px; align-items: center; flex-wrap: wrap;
}
.roi-whatif-num { flex-shrink: 0; }
.roi-whatif-lbl {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 700; color: var(--accent-ink);
}
.roi-whatif-val { font-size: 46px; font-weight: 600; color: var(--accent-ink); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.05; margin-top: 6px; }
.roi-whatif-copy { flex: 1; min-width: 260px; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.roi-whatif-copy strong { color: var(--ink); font-weight: 600; }
.roi-whatif-copy .roi-mrow-formula { margin-top: 8px; }

/* What-if scenario cards */
.roi-scenarios { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.roi-scenario {
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface);
  padding: 18px 20px; display: flex; flex-direction: column;
}
.roi-scenario-tag { display: inline-flex; align-items: center; gap: 8px; }
.roi-scenario-tag .n {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
}
.roi-scenario-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 11px; letter-spacing: -0.01em; min-height: 34px; }
.roi-scenario-val {
  font-size: clamp(20px, 2.3vw, 30px); font-weight: 600; color: var(--accent-ink);
  letter-spacing: -0.025em; margin-top: 10px; font-variant-numeric: tabular-nums; line-height: 1;
}
.roi-scenario-val .unit { font-size: 13px; color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.roi-scenario-basis {
  font-family: 'Geist Mono', ui-monospace, monospace; font-size: 10.5px;
  color: var(--ink-3); margin-top: 10px; letter-spacing: -0.01em; line-height: 1.5;
}

@media (max-width: 1100px) {
  .roi-stats.cols-3, .roi-stats.cols-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .roi-stats.cols-2, .roi-stats.cols-3, .roi-stats.cols-4 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .roi-scenarios { grid-template-columns: 1fr; }
}

/* ============================================================ */
/* ===== Responsive layout & mobile drawer ==================== */
/* ============================================================ */

/* Hamburger + scrim hidden on desktop */
.nav-toggle { display: none; }
.nav-scrim { display: none; }

/* Fluid card grids — collapse columns as the viewport narrows */
@media (max-width: 1180px) {
  .grid-kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2-eq, .grid-3 { grid-template-columns: 1fr; }
  .forecast-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .kanban { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid-kpis, .forecast-grid { grid-template-columns: 1fr; }
}

/* Tablet / mobile: sidebar becomes an off-canvas drawer */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 264px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: translateX(0); }

  .nav-scrim {
    display: block;
    position: fixed; inset: 0;
    background: rgba(17, 24, 39, 0.42);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 55;
  }
  .app.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }

  .nav-toggle {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border-radius: 7px;
    color: var(--ink-2);
    flex-shrink: 0;
    margin-left: -6px;
    background: transparent;
  }
  .nav-toggle:hover { background: var(--surface-3); color: var(--ink); }

  .topbar { padding: 0 16px; gap: 10px; }
  .topbar-search { display: none; }
  .canvas { padding: 16px; }
  .showroom-switcher,
  .filters-bar,
  .pipeline-toolbar,
  .kanban { padding-left: 16px; padding-right: 16px; }
}

/* Phones: keep only the dominant action, give panels room */
@media (max-width: 620px) {
  .topbar-actions .btn:not(.primary) { display: none; }
  .detail-panel { width: 100%; }
  .invite-modal { width: calc(100vw - 24px); }
  .page-sub { display: none; }
}

/* ============================================================ */
/* ===== Negative numbers (accounting style) ================== */
/* Parentheses come from fmt.*; the painter adds .neg for red.  */
.neg { color: var(--lost) !important; }

/* ============================================================ */
/* ===== Auth gate (live mode sign-in) ======================== */
.auth-wrap {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in oklch, var(--accent) 18%, var(--bg)), var(--bg)), var(--bg);
  font-family: var(--font, 'Inter', system-ui, sans-serif);
  overflow-y: auto;
  z-index: 200;
}
.auth-card {
  width: 100%; max-width: 408px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 30px 30px 26px;
}
.auth-brand { display: flex; align-items: center; justify-content: center; margin-bottom: 20px; }
.auth-brand-mark {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, #2A8F73, #134034);
  color: #fff; font-weight: 800; font-size: 28px; letter-spacing: -0.03em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 6px 18px rgba(19,64,52,0.25);
}
.auth-title { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); margin: 0 0 4px; text-align: center; }
.auth-sub { font-size: 13px; color: var(--ink-3); margin: 0 0 18px; text-align: center; line-height: 1.5; }
.auth-tabs {
  display: flex; gap: 3px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; margin-bottom: 16px;
}
.auth-tabs button {
  flex: 1; height: 32px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3); cursor: pointer; background: transparent;
}
.auth-tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-input {
  height: 42px; padding: 0 13px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); font-size: 13.5px; color: var(--ink);
  outline: none; transition: border-color 0.13s, box-shadow 0.13s, background 0.13s; width: 100%;
}
.auth-input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-msg { font-size: 12px; padding: 8px 11px; border-radius: 8px; line-height: 1.45; }
.auth-msg.err { background: var(--lost-soft); color: var(--lost); }
.auth-msg.ok { background: var(--won-soft); color: var(--won); }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--ink-4); font-size: 11px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-demo {
  display: block; width: 100%; text-align: center; margin-top: 18px;
  font-size: 12.5px; color: var(--ink-3); cursor: pointer; background: none; padding: 6px;
}
.auth-demo:hover { color: var(--accent); }

/* ============================================================ */
/* ===== AI Assistant ========================================= */
/* ============================================================ */
.ai-launcher {
  position: fixed;
  bottom: 22px; right: 22px;
  z-index: 90;
  display: inline-flex; align-items: center; gap: 9px;
  height: 48px; padding: 0 18px 0 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(17,24,39,0.20), 0 2px 6px rgba(17,24,39,0.12);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.ai-launcher:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(17,24,39,0.26), 0 3px 8px rgba(17,24,39,0.14); background: var(--accent-ink); }
.ai-launcher .ai-spark {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: inline-flex; align-items: center; justify-content: center;
}
.ai-launcher.hidden { display: none; }

.ai-panel {
  position: fixed;
  bottom: 22px; right: 22px;
  z-index: 91;
  width: 396px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 44px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: aiIn 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes aiIn { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

.ai-head {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.ai-head .ai-avatar {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ai-head .ai-title { font-size: 14px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.ai-head .ai-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.ai-head .ai-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--won); }
.ai-head .ai-close { margin-left: auto; padding: 6px; border-radius: 7px; color: var(--ink-3); }
.ai-head .ai-close:hover { background: var(--surface-3); color: var(--ink); }

.ai-body {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--bg);
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.ai-body::-webkit-scrollbar { width: 7px; }
.ai-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.ai-msg { display: flex; gap: 9px; max-width: 92%; }
.ai-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.ai-msg .ai-msg-av {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.ai-msg.bot .ai-msg-av { background: var(--accent-soft); color: var(--accent); }
.ai-msg.user .ai-msg-av { background: var(--ink); color: #fff; font-size: 10px; font-weight: 600; }
.ai-bubble {
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13px; line-height: 1.55;
  color: var(--ink-2);
}
.ai-msg.bot .ai-bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 4px; }
.ai-msg.user .ai-bubble { background: var(--accent); color: #fff; border-top-right-radius: 4px; }
.ai-bubble p { margin: 0 0 8px; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble strong { font-weight: 600; color: var(--ink); }
.ai-msg.user .ai-bubble strong { color: #fff; }
.ai-bubble ul { margin: 4px 0; padding-left: 18px; }
.ai-bubble li { margin: 2px 0; }
.ai-bubble code { font-family: 'Geist Mono', monospace; font-size: 11.5px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }

.ai-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.ai-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); animation: aiBounce 1.2s infinite ease-in-out; }
.ai-typing span:nth-child(2) { animation-delay: 0.16s; }
.ai-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes aiBounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-4px); opacity: 1; } }

.ai-suggest { display: flex; flex-wrap: wrap; gap: 7px; }
.ai-chip {
  font-size: 12px; font-weight: 500;
  padding: 7px 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  color: var(--ink-2);
  cursor: pointer; text-align: left;
  transition: border-color 0.13s, background 0.13s, color 0.13s;
}
.ai-chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

.ai-foot { border-top: 1px solid var(--border); padding: 12px; background: var(--surface); }
.ai-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 7px 7px 12px;
  transition: border-color 0.13s, box-shadow 0.13s;
}
.ai-input-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ai-input-row textarea {
  flex: 1; border: 0; background: none; outline: none; resize: none;
  font-size: 13px; line-height: 1.45; color: var(--ink); max-height: 96px;
  padding: 4px 0; font-family: inherit;
}
.ai-send {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.13s, opacity 0.13s;
}
.ai-send:hover { background: var(--accent-ink); }
.ai-send:disabled { opacity: 0.4; cursor: default; }
.ai-disclaimer { font-size: 10px; color: var(--ink-4); text-align: center; margin-top: 8px; }

@media (max-width: 620px) {
  .ai-panel { width: 100%; height: 100%; max-height: 100%; bottom: 0; right: 0; border-radius: 0; }
  .ai-launcher { bottom: 16px; right: 16px; }
}
