/* ─── Reset & Variables ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Dark theme (default) ─────────────────────────────────────── */
:root, html[data-theme="dark"] {
  --bg:         #111827;
  --surface:    #1e2a3a;
  --surface2:   #263446;
  --border:     #2e4060;
  --border2:    #3a5070;
  --text:       #f0f6ff;
  --muted:      #a0b8d0;
  --dimmed:     #2e4060;
  --accent:     #ff7043;
  --accent2:    #ff8a65;
  --sidebar-bg: #0d1520;
  --sidebar-t:  #f0f6ff;
  --sidebar-m:  #8aaac8;
  --green:      #4ade80;
  --green-bg:   rgba(74,222,128,.18);
  --red:        #f87171;
  --red-bg:     rgba(248,113,113,.18);
  --amber:      #fbbf24;
  --amber-bg:   rgba(251,191,36,.18);
  --blue:       #60a5fa;
  --blue-bg:    rgba(96,165,250,.18);
  --purple:     #c084fc;
  --purple-bg:  rgba(192,132,252,.18);
  --teal:       #34d8c8;
  --teal-bg:    rgba(52,216,200,.18);
  --hs:         #fb923c;
  --hs-bg:      rgba(251,146,60,.18);
  --personio:   #38bdf8;
  --personio-bg:rgba(56,189,248,.18);
  --slack:      #c084fc;
  --slack-bg:   rgba(192,132,252,.18);
  --linkedin:   #60a5fa;
  --linkedin-bg:rgba(96,165,250,.18);
  --font:  'DM Sans', sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  --mono:  'DM Mono', monospace;
  --r: 8px; --r-lg: 12px;
  --ch1: #60a5fa; --ch2: #4ade80; --ch3: #fbbf24;
  --ch4: #f87171; --ch5: #c084fc; --ch6: #34d8c8;
  --ch-grid: rgba(255,255,255,.07);
  --ch-text: #8aaac8;
}

/* ── Light theme ──────────────────────────────────────────────── */
html[data-theme="light"] {
  --bg:         #f5f3ee;
  --surface:    #ffffff;
  --surface2:   #f0ede6;
  --border:     #e4e0d8;
  --border2:    #d0ccc2;
  --text:       #1a1916;
  --muted:      #7a7670;
  --dimmed:     #c8c4bc;
  --accent:     #c44b1b;
  --accent2:    #e06030;
  --sidebar-bg: #ffffff;
  --sidebar-t:  #1a1916;
  --sidebar-m:  #7a7670;
  --green:      #1a8040;
  --green-bg:   #e5f6ed;
  --red:        #c0392b;
  --red-bg:     #fdecea;
  --amber:      #a06010;
  --amber-bg:   #fef6e4;
  --blue:       #1a50a8;
  --blue-bg:    #eaf0fc;
  --purple:     #5a2d82;
  --purple-bg:  #f3edfb;
  --teal:       #0e6b6b;
  --teal-bg:    #e3f5f5;
  --hs:         #e86040;
  --hs-bg:      #fff2ee;
  --personio:   #0080b8;
  --personio-bg:#e6f4fc;
  --slack:      #4a154b;
  --slack-bg:   #f4eef5;
  --linkedin:   #0a66c2;
  --linkedin-bg:#e7f0fb;
  --ch1: #2563eb; --ch2: #16a34a; --ch3: #d97706;
  --ch4: #dc2626; --ch5: #7c3aed; --ch6: #0891b2;
  --ch-grid: rgba(0,0,0,.06);
  --ch-text: #7a7670;
}

html, body { height: 100%; font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 10px;
}
.logo-mark {
  width: 30px; height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
}
.logo-name {
  font-size: 13px; font-weight: 500; color: var(--sidebar-t);
  line-height: 1.2;
}
.logo-sub { font-size: 10px; color: var(--sidebar-m); font-weight: 300; }

.nav-section {
  font-family: var(--mono); font-size: 9px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--sidebar-m);
  opacity: .55; padding: 18px 18px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px; font-size: 12.5px; font-weight: 400;
  color: var(--sidebar-m); cursor: pointer;
  border-left: 2px solid transparent;
  transition: all .12s; text-decoration: none;
  position: relative;
}
.nav-item:hover { color: var(--sidebar-t); background: rgba(0,0,0,.04); }
.nav-item.active {
  color: var(--sidebar-t);
  border-left-color: var(--accent2);
  background: rgba(0,0,0,.05);
  font-weight: 500;
}
.nav-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  margin-left: auto;
}
.nav-dot.green  { background: #22c55e; box-shadow: 0 0 4px #22c55e80; }
.nav-dot.amber  { background: #f59e0b; }
.nav-dot.gray   { background: rgba(255,255,255,.2); }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.api-row {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 9.5px; color: var(--sidebar-m);
  opacity: .55; padding: 3px 0;
}
.sidebar-footer .countdown-row { opacity: .4; }
.sidebar-footer .countdown-val { opacity: .7; }
.api-row .dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.dot-green  { background: #22c55e; }
.dot-amber  { background: #f59e0b; }
.dot-red    { background: #ef4444; }
.dot-gray   { background: var(--sidebar-m); opacity: .4; }

/* ─── Main container ──────────────────────────────────────────── */
.main-wrap {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}

/* ─── Topbar ──────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.page-title { font-family: var(--serif); font-size: 17px; font-weight: 400; }
.page-title em { font-style: italic; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.refresh-pill {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 10px;
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
.live-dot.syncing { background: var(--amber); animation: none; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r);
  font-family: var(--font); font-size: 12px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border2); background: transparent;
  color: var(--muted); transition: all .12s; text-decoration: none;
}
.btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.btn-ghost { background: transparent; border-color: var(--border2); color: var(--muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* ─── Main content ────────────────────────────────────────────── */
.main-content {
  padding: 28px 32px 56px;
  flex: 1;
}
.view { display: none; }
.view.active { display: block; }

/* ─── Section ─────────────────────────────────────────────────── */
.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-family: var(--serif);
  font-size: 18px; font-weight: 300; color: var(--text);
}
.section-title strong { font-weight: 600; }
.section-meta {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
}
.section-gap { margin-bottom: 32px; }

/* ── Product filter toggle ─────────────────────────────────── */
.product-filter {
  display: flex; gap: 0; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface);
}
.pf-btn {
  padding: 5px 14px; font-size: 12px; font-family: var(--sans);
  font-weight: 500; cursor: pointer; border: none;
  background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.pf-btn:not(:last-child) { border-right: 1px solid var(--border); }
.pf-btn:hover { background: var(--surface2); color: var(--text); }
.pf-btn.active { background: var(--accent); color: #fff; }

/* ─── Source badge ────────────────────────────────────────────── */
.source-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 9px; font-weight: 400;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 20px;
}
.src-hs        { background: var(--hs-bg);        color: var(--hs); }
.src-personio  { background: var(--personio-bg);   color: var(--personio); }
.src-slack     { background: var(--slack-bg);      color: var(--slack); }
.src-linkedin  { background: var(--linkedin-bg);   color: var(--linkedin); }

/* ─── KPI grid ────────────────────────────────────────────────── */
.kpi-row { display: grid; gap: 12px; margin-bottom: 28px; }
.kpi-row-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-row-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-row-2 { grid-template-columns: repeat(2, 1fr); }
.kpi-row-5 { grid-template-columns: repeat(5, 1fr); }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  position: relative; overflow: hidden;
}
.kpi-card.featured { border-color: var(--border2); }
.kpi-card.featured::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent);
}
.kpi-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .10em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.kpi-value {
  font-family: var(--serif);
  font-size: 28px; font-weight: 300; line-height: 1;
  margin-bottom: 6px; letter-spacing: -.01em;
}
.kpi-value.big { font-size: 34px; }
.kpi-sub { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* Dark mode readability */
html[data-theme="dark"] .kpi-sub        { color: #b8d0e8; font-size: 12px; }
html[data-theme="dark"] .kpi-label      { color: #8aaac8; font-size: 10.5px; letter-spacing: .08em; }
html[data-theme="dark"] .kpi-value      { color: #f0f6ff; }
html[data-theme="dark"] .section-meta   { color: #8aaac8; }
html[data-theme="dark"] .section-title  { color: #f0f6ff; }
html[data-theme="dark"] .h-bar-val      { color: #c0d8f0; }
html[data-theme="dark"] .h-bar-label    { color: #d8eaff; font-size: 13px; }
html[data-theme="dark"] .today-detail   { color: #9ab8d0; font-size: 12px; }
html[data-theme="dark"] .today-name     { color: #e8f2ff; font-size: 14px; }
html[data-theme="dark"] .panel-title    { color: #e8f2ff; font-size: 14px; }
html[data-theme="dark"] .panel-count    { color: #8aaac8; }
html[data-theme="dark"] .nav-section    { color: rgba(160,190,220,.55); font-size: 10px; opacity: 1; }
html[data-theme="dark"] .nav-item       { color: #8aaac8; font-size: 13.5px; }
html[data-theme="dark"] .nav-item.active { color: #f0f6ff; }
html[data-theme="dark"] .funnel-label   { color: #d8eaff; }
html[data-theme="dark"] .funnel-count   { color: #9ab8d0; }
html[data-theme="dark"] .funnel-amount  { color: #d8eaff; }
html[data-theme="dark"] .legend-item    { color: #9ab8d0; font-size: 11px; }
html[data-theme="dark"] .strip-source   { font-size: 13px; }
html[data-theme="dark"] .strip-value    { color: #f0f6ff; }
html[data-theme="dark"] .strip-label    { color: #8aaac8; font-size: 10px; }
html[data-theme="dark"] .compare-label  { color: #8aaac8; }
html[data-theme="dark"] .cmp-btn        { color: #b0c8e0; border-color: #3a5070; font-size: 12px; }
html[data-theme="dark"] td              { color: #c8e0f8; font-size: 12px; }
html[data-theme="dark"] th              { color: #8aaac8; font-size: 10px; }
html[data-theme="dark"] td:first-child  { color: #e8f2ff; font-size: 13px; }
html[data-theme="dark"] .api-row        { color: rgba(168,198,228,.55); font-size: 10px; opacity: 1; }
html[data-theme="dark"] .logo-name      { color: #f0f6ff; }
html[data-theme="dark"] .logo-sub       { color: #8aaac8; }
html[data-theme="dark"] .sidebar-footer .api-row { border-top: none; }
html[data-theme="dark"] .topbar-title   { color: #8aaac8; font-size: 13px; }
html[data-theme="dark"] .page-title     { color: #f0f6ff; }
html[data-theme="dark"] .page-title em  { color: #8aaac8; }
html[data-theme="dark"] .kpi-card       { background: #1e2a3a; border-color: #2e4060; }
html[data-theme="dark"] .kpi-card.featured { border-color: #3a5070; background: #223040; }
html[data-theme="dark"] .panel          { background: #1e2a3a; border-color: #2e4060; }
html[data-theme="dark"] .panel-header   { border-color: #2e4060; background: #1a2535; }
html[data-theme="dark"] .panel th       { background: #162030; }
html[data-theme="dark"] tr:hover td     { background: rgba(255,255,255,.03); }
html[data-theme="dark"] .today-item     { border-color: #2e4060; }
html[data-theme="dark"] .compare-bar    { background: #162030; border-color: #2e4060; }
html[data-theme="dark"] .custom-picker-inner { background: #1e2a3a; border-color: #3a5070; }
html[data-theme="dark"] .picker-input   { background: #162030; border-color: #3a5070; color: #f0f6ff; }
html[data-theme="dark"] .refresh-pill   { background: #162030; border-color: #2e4060; color: #8aaac8; }
html[data-theme="dark"] .config-notice  { background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.4); color: #fbbf24; }
html[data-theme="dark"] .overview-section-line { background: #2e4060; }
.kpi-change {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--mono); font-size: 10px; font-weight: 400;
  padding: 2px 6px; border-radius: 4px; margin-top: 6px;
}
.ch-up   { background: var(--green-bg);  color: var(--green); }
.ch-down { background: var(--red-bg);    color: var(--red); }
.ch-flat { background: var(--surface2);  color: var(--muted); }
.ch-info { background: var(--blue-bg);   color: var(--blue); }

/* ─── Grid layouts ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-2-3 { display: grid; grid-template-columns: 2fr 3fr; gap: 16px; }
.grid-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }

/* ─── Panel ───────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-header {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.panel-title {
  font-size: 13px; font-weight: 500; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.ext-link {
  font-family: var(--mono); font-size: 9.5px; color: var(--accent);
  text-decoration: none; opacity: .7;
  display: flex; align-items: center; gap: 3px;
  transition: opacity .12s; margin-left: auto;
}
.ext-link:hover { opacity: 1; }

/* ─── Table ───────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  padding: 8px 16px; text-align: right;
  font-family: var(--mono); font-size: 9px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--bg);
}
th:first-child { text-align: left; }
td {
  padding: 10px 16px; text-align: right;
  font-family: var(--mono); font-size: 11.5px; color: var(--text);
  border-bottom: 1px solid var(--border);
}
td:first-child { text-align: left; font-family: var(--font); font-size: 13px; font-weight: 500; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ─── Sortable table headers ─────────────────────────────────── */
th.sortable { cursor: pointer; user-select: none; transition: color .12s; }
th.sortable:hover { color: var(--text); }
th.sortable.active-sort { color: var(--accent); }
.sort-arrow { font-size: 8px; margin-left: 3px; opacity: .7; }

/* ─── Pipeline expandable stages ─────────────────────────────── */
.stage-row { cursor: pointer; transition: background .12s; border-radius: 4px; padding: 6px 0; }
.stage-row:hover { background: var(--surface2); }
.stage-row.expanded { background: var(--surface2); }
.stage-chevron { font-size: 10px; margin-right: 4px; color: var(--muted); display: inline-block; width: 12px; }
.stage-deals-panel {
  max-height: 0; overflow: hidden; transition: max-height .3s ease;
  margin: 0 0 4px; border-radius: 0 0 var(--r) var(--r);
}
.stage-deals-panel.open { max-height: 2000px; }
.stage-deals-table { background: var(--bg); border-radius: var(--r); margin: 4px 0 8px; }
.stage-deals-table th { font-size: 9px; padding: 6px 12px; }
.stage-deals-table td { font-size: 12px; padding: 8px 12px; }
.stage-deals-table td:first-child { font-size: 12px; }

/* ─── Pipeline by Vertical table ─────────────────────────────── */
.vp-table { width: 100%; border-collapse: collapse; }
.vp-table th { text-align: center; padding: 10px 14px; }
.vp-table th.vp-vert-head { text-align: left; }
.vp-table th.vp-total-head { text-align: right; }
.vp-table td.vp-vert { font-family: var(--font); font-size: 13px; font-weight: 500; text-align: left; }
.vp-table td.vp-cell { text-align: center; padding: 10px 14px; }
.vp-table td.vp-cell.vp-total { text-align: right; font-family: var(--mono); }
.vp-table td.vp-empty { color: var(--muted); opacity: .5; }
.vp-table .vp-count { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.vp-table .vp-weighted { font-size: 12.5px; font-weight: 600; color: var(--text); font-family: var(--mono); margin-top: 2px; }
.vp-table tfoot tr.vp-totals-row td { background: var(--bg); border-top: 1px solid var(--border); border-bottom: none; }
.vp-table tfoot tr.vp-totals-row td.vp-vert { font-weight: 700; }
.vp-table tfoot tr.vp-totals-row td.vp-cell .vp-weighted { font-weight: 700; }

/* ─── Gauge / Speedometer ─────────────────────────────────────── */
.gauges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 16px 20px;
}
.gauge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 14px 14px;
  border-radius: var(--r);
  background: var(--surface);
  transition: background .15s;
  cursor: pointer;
}
.gauge-card:hover { background: var(--surface2); }
.gauge-svg { width: 100%; max-width: 180px; }
.gauge-label {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-top: 8px;
  text-align: center;
  line-height: 1.3;
  width: 100%;
}
.gauge-amounts {
  font-size: 16px;
  color: var(--text);
  margin-top: 5px;
  text-align: center;
  font-weight: 500;
  opacity: 0.8;
  width: 100%;
}
.gauge-sub {
  font-size: 15px;
  color: var(--muted);
  margin-top: 4px;
  text-align: center;
  width: 100%;
}
.gauge-dual {
  display: flex;
  gap: 6px;
  justify-content: center;
  width: 100%;
  margin-top: 6px;
}
.gauge-mini-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.gauge-mini-svg { width: 100%; max-width: 120px; }
.gauge-mini-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 1px;
}
.gauge-mini-delta {
  font-size: 12px;
  font-weight: 600;
  margin-top: 1px;
}
.gauge-card-active { background: var(--surface2); outline: 1px solid var(--border); }
.gauge-detail-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.gauge-detail-section { margin-bottom: 14px; }
.gauge-detail-section:last-child { margin-bottom: 0; }
.gauge-detail-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}
@media (max-width: 900px) {
  .gauges-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .gauges-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── Expandable rows (Verticals, Owner stages) ──────────────── */
.expandable-row { transition: background .15s; }
.expandable-row:hover { background: var(--surface2); }
.expandable-row.expanded { background: var(--surface2); }
.expandable-detail td { background: var(--bg); }
.expandable-detail .stage-deals-table { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* ─── Search ─────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  margin-bottom: 16px;
  max-width: 400px;
}
.search-input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color .12s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 16px; padding: 2px 4px; line-height: 1; display: none;
}
.search-clear.visible { display: block; }
.search-clear:hover { color: var(--text); }
.search-count {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  margin-top: 4px;
}
tr.totals td {
  background: var(--surface2); color: var(--text);
  font-weight: 600; border-top: 1px solid var(--border2);
  border-bottom: none;
}

/* ─── Inline bar ──────────────────────────────────────────────── */
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-track { width: 56px; height: 3px; background: var(--surface2); border-radius: 2px; flex-shrink: 0; }
.bar-fill  { height: 100%; border-radius: 2px; }

/* ─── Stage / Status badge ────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-family: var(--mono);
  padding: 2px 7px; border-radius: 4px; white-space: nowrap;
}
.badge-blue    { background: var(--blue-bg);   color: var(--blue); }
.badge-purple  { background: var(--purple-bg); color: var(--purple); }
.badge-teal    { background: var(--teal-bg);   color: var(--teal); }
.badge-amber   { background: var(--amber-bg);  color: var(--amber); }
.badge-orange  { background: #fff0eb;          color: #c04010; }
.badge-green   { background: var(--green-bg);  color: var(--green); }
.badge-red     { background: var(--red-bg);    color: var(--red); }
.badge-gray    { background: var(--surface2);  color: var(--muted); }

/* ─── Avatar ──────────────────────────────────────────────────── */
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600; flex-shrink: 0;
  vertical-align: middle; margin-right: 7px;
}
.avatar-cell { display: flex; align-items: center; }

/* ─── Overview cross-platform strips ─────────────────────────── */
.strip {
  display: grid; grid-template-columns: 100px 1fr;
  align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.strip:last-child { border-bottom: none; }
.strip-source { font-size: 11px; font-weight: 500; }
.strip-metrics { display: flex; gap: 20px; flex-wrap: wrap; }
.strip-metric { display: flex; flex-direction: column; }
.strip-value { font-family: var(--serif); font-size: 20px; font-weight: 300; line-height: 1; }
.strip-label { font-family: var(--mono); font-size: 9px; color: var(--muted); margin-top: 2px; letter-spacing: .08em; text-transform: uppercase; }

/* ─── Horizontal bar chart ────────────────────────────────────── */
.h-bar-wrap { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.h-bar-row { display: grid; grid-template-columns: 160px 1fr 120px; align-items: center; gap: 10px; }
.h-bar-label { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-bar-track { background: var(--surface2); border-radius: 3px; height: 6px; overflow: hidden; }
.h-bar-fill  { height: 100%; border-radius: 3px; transition: width .4s ease; }
.h-bar-val   { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; }
.sankey-toggle { display: flex; align-items: center; gap: 6px; padding: 10px 16px 0; flex-wrap: wrap; }
.flow-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; padding: 8px 4px; }
.flow-card { background: var(--surface); border-radius: var(--r); padding: 12px; }
.flow-card-title { font-size: 11px; font-weight: 700; color: var(--text); margin-bottom: 8px; padding-left: 8px; }
.flow-card-rows { display: flex; flex-direction: column; gap: 4px; }
.flow-row { display: flex; justify-content: space-between; align-items: center; font-size: 11px; }
.flow-label { color: var(--muted); }
.flow-val { font-weight: 600; font-family: var(--mono); font-size: 11px; }
.sankey-svg { display: block; }
.sankey-node { transition: opacity .2s; }
.sankey-node:hover { opacity: 1 !important; filter: brightness(1.2); }
.sankey-flow { transition: opacity .2s; }
.sankey-flow:hover { opacity: 0.3 !important; }
.sankey-hover:hover { filter: brightness(1.3); }
.sankey-tooltip {
  position: absolute;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  z-index: 100;
  max-width: 400px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  pointer-events: none;
}
.sankey-tip-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.sankey-tooltip table { width: 100%; border-collapse: collapse; font-size: 11px; }
.sankey-tooltip th { color: var(--muted); font-weight: 500; text-align: left; padding: 2px 6px; border-bottom: 1px solid var(--border); }
.sankey-tooltip td { padding: 3px 6px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.sankey-tooltip tr:hover td { background: var(--surface2); }
.sankey-panel {
  position: absolute;
  left: 0; right: 0; top: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  z-index: 110;
  display: flex;
  flex-direction: column;
  max-height: 500px;
}
.sankey-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.sankey-panel-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 14px;
}
.sankey-panel-close:hover { color: var(--text); background: var(--surface2); }
.sankey-panel-scroll {
  overflow-y: auto;
  padding: 8px 16px 16px;
  max-height: 440px;
}

/* ─── Today card ──────────────────────────────────────────────── */
.today-list { padding: 0; list-style: none; }
.today-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.today-item:last-child { border-bottom: none; }
.today-name { font-weight: 500; }
.today-detail { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ─── Divider ─────────────────────────────────────────────────── */
hr.divider {
  border: none; border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ─── Config notice ───────────────────────────────────────────── */
.config-notice {
  background: var(--amber-bg); border: 1px solid var(--amber);
  border-radius: var(--r); padding: 10px 16px 10px 14px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 12px; color: var(--amber); margin-bottom: 24px;
  line-height: 1.5;
  opacity: 1;
}
.config-notice code {
  background: rgba(0,0,0,.06); padding: 1px 5px;
  border-radius: 3px; font-family: var(--mono); font-size: 11px;
}
.notice-close { margin-left: auto; cursor: pointer; font-size: 16px; line-height: 1; flex-shrink: 0; opacity: .5; }
.notice-close:hover { opacity: 1; }

/* ─── Compare Bar ─────────────────────────────────────────────── */
.compare-bar {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  position: sticky; top: 52px; z-index: 40;
}
.compare-bar-inner {
  display: flex; align-items: center; gap: 10px;
  height: 42px; flex-wrap: wrap;
}
.compare-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap;
  padding-right: 6px; border-right: 1px solid var(--border2);
  margin-right: 2px;
}
.compare-presets { display: flex; gap: 4px; }
.cmp-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--border2); background: transparent;
  font-family: var(--font); font-size: 11.5px; color: var(--muted);
  cursor: pointer; white-space: nowrap; transition: all .12s;
}
.cmp-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border2); }
.cmp-btn.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.cmp-btn-apply { background: var(--accent); color: #fff; border-color: var(--accent); }
.cmp-btn-apply:hover { background: var(--accent2); color: #fff; }
.cmp-btn-clear { padding: 4px 8px; font-size: 14px; line-height: 1; }

.custom-picker {
  display: none; align-items: center;
}
.custom-picker.open { display: flex; }
.custom-picker-inner {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 10px; padding: 5px 10px;
}
.picker-group { display: flex; align-items: center; gap: 5px; }
.picker-label { font-family: var(--mono); font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.picker-input {
  border: 1px solid var(--border2); border-radius: 6px;
  background: var(--bg); color: var(--text);
  font-family: var(--mono); font-size: 11px;
  padding: 3px 7px; outline: none;
}
.picker-input:focus { border-color: var(--accent); }
.picker-sep { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.compare-active {
  margin-left: 6px; display: flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10.5px;
  background: rgba(196,75,27,.08); color: var(--accent);
  border: 1px solid rgba(196,75,27,.2);
  padding: 3px 8px; border-radius: 20px;
}
.compare-clear {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 14px; line-height: 1; padding: 0 0 0 2px;
  opacity: .7; transition: opacity .12s;
}
.compare-clear:hover { opacity: 1; }

/* ─── Delta indicators (old, replaced by Time Travel) ──────── */
.delta-up   { background: var(--green-bg); color: var(--green); }
.delta-down { background: var(--red-bg);   color: var(--red); }
.delta-flat { background: var(--surface2); color: var(--muted); }

.compare-period-label {
  font-family: var(--mono); font-size: 9px; color: var(--muted);
  margin-top: 3px; display: none;
}
.compare-period-label.visible { display: block; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--dimmed); border-radius: 2px; }

/* ── Charts ───────────────────────────────────────────────────── */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap canvas { display: block; }
.chart-panel-body { padding: 4px 16px 14px; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  padding: 10px 20px 0;
}
.legend-item {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px; color: var(--muted);
}
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.charts-row { display: grid; gap: 16px; margin-bottom: 20px; }
.charts-2 { grid-template-columns: 1fr 1fr; }
.charts-3 { grid-template-columns: 1fr 1fr 1fr; }


/* ─── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }
.view.active .kpi-card,
.view.active .panel {
  animation: fadeIn .35s ease both;
}
.view.active .kpi-card:nth-child(2) { animation-delay: .04s; }
.view.active .kpi-card:nth-child(3) { animation-delay: .08s; }
.view.active .kpi-card:nth-child(4) { animation-delay: .12s; }
.view.active .kpi-card:nth-child(5) { animation-delay: .16s; }

.tag { display: inline-block; font-family: var(--mono); font-size: 9px; padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border2); color: var(--muted); }

.overview-section-label {
  display: flex; align-items: center; gap: 10px;
  margin: 24px 0 14px;
}
.overview-section-line { flex: 1; height: 1px; background: var(--border); }

/* ─── ARR Pie Chart ────────────────────────────────────────────── */
/* ARR dual row layout */
.arr-dual-row { display: flex; gap: 16px; }
.arr-dual-col { flex: 1 1 0%; min-width: 0; }
.arr-dual-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.arr-dual-title { font-size: 13px; font-weight: 600; color: var(--text); }
@media (max-width: 900px) { .arr-dual-row { flex-direction: column; } }

.arr-pie-panel {
  width: 100%;
  display: flex; justify-content: center; align-items: center; min-height: 180px;
}
.arr-pie-svg { max-width: 100%; height: auto; }
.arr-slice { transition: opacity .15s, filter .15s, transform .15s; }
.arr-table-row { transition: background .15s, opacity .15s; }
.arr-tooltip {
  position: absolute; pointer-events: auto; z-index: 100;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 8px; padding: 10px 14px; max-width: 300px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  font-size: 12px; color: var(--text); line-height: 1.5;
}
.arr-tip-hs {
  margin-left: auto; padding: 2px 6px; border-radius: 4px; font-size: 11px;
  color: var(--accent); text-decoration: none; border: 1px solid var(--accent);
  transition: all .15s; flex-shrink: 0;
}
.arr-tip-hs:hover { background: var(--accent); color: #fff; }
.arr-tooltip.pinned { border-color: var(--accent); box-shadow: 0 4px 20px rgba(0,0,0,.35); }

/* ─── KPI hover tooltip ──────────────────────────────────────── */
.hover-tip {
  position: fixed; z-index: 9999;
  display: none; pointer-events: none;
  max-width: 280px; padding: 9px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border2); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  font-size: 11.5px; line-height: 1.5;
}

/* ─── Time Travel ────────────────────────────────────────────── */
.pf-divider {
  width: 1px; height: 18px; background: var(--border); margin: 0 4px; flex-shrink: 0;
}
.tt-clock {
  padding: 5px 7px !important; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border) !important; border-radius: 6px; background: var(--surface) !important;
  color: var(--muted); transition: all .15s;
}
.tt-clock:hover { background: var(--surface2) !important; color: var(--text); }
.tt-clock.active { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
.tt-presets { display: inline-flex; align-items: center; gap: 4px; animation: ttFadeIn .15s ease-out; }
@keyframes ttFadeIn { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: translateX(0); } }
.tt-btn.active { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
.tt-close-btn { color: var(--muted) !important; font-size: 13px !important; padding: 3px 8px !important; }
.tt-close-btn:hover { color: var(--text) !important; background: rgba(255,255,255,.08) !important; }

/* Global filter bar */
.global-filter-bar {
  padding: 0 24px; margin-top: 14px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.tt-controls {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-left: 8px;
}

/* Preset editor modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
.preset-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.preset-row-name { font-weight: 500; color: var(--text); flex: 1; }
.preset-row-products { color: var(--muted); font-size: 11px; }
.preset-gear { padding: 0 !important; width: 28px; display: inline-flex; align-items: center; justify-content: center; }

/* Pipeline ghost bars */
.pipeline-bar-wrap { position: relative; }
.pipeline-ghost-bar {
  position: absolute; top: 0; left: 0; height: 100%; border-radius: 4px;
  background: var(--muted); opacity: 0.15; pointer-events: none;
}
.pipeline-was { color: var(--muted); font-size: 10px; }

/* ARR comparison — side-by-side mini pie */
.arr-comparison { color: var(--muted); }
.arr-comparison:empty { display: none; }
.arr-comparison .arr-cmp-up { color: var(--green); font-weight: 600; }
.arr-comparison .arr-cmp-down { color: #ef4444; font-weight: 600; }
/* Gauge delta */
.gauge-delta { font-size: 10px; margin-top: 2px; text-align: center; }

.arr-hist-header { font-size: 12px; text-align: center; margin-bottom: 4px; }
.arr-pie-mini { max-width: 100%; }
.arr-pie-mini svg { max-height: 180px; }

/* Make ARR panel flex side-by-side when comparison active */
.arr-pie-panel + .arr-comparison:not(:empty) { margin-top: 8px; }
.arr-charts-wrap {
  width: 100%;
  display: flex; flex-direction: column; align-items: center;
}
.arr-charts-wrap.arr-side-by-side {
  flex-direction: row; align-items: flex-start; gap: 12px;
}
.arr-charts-wrap.arr-side-by-side > .arr-pie-panel { flex: 2; }
.arr-charts-wrap.arr-side-by-side > .arr-comparison { flex: 1; min-width: 0; }

.tt-date-input {
  padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 11px;
  font-family: inherit; width: 105px; height: 28px;
}
.tt-date-input::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

/* Delta indicators on KPI cards */
.kpi-delta { font-size: 11px; margin-top: 4px; line-height: 1.3; }
.kpi-delta .delta-vs { color: var(--muted); }
.kpi-delta .delta-val { font-weight: 600; }
.kpi-delta .delta-up { color: var(--green); }
.kpi-delta .delta-down { color: #ef4444; }
.kpi-delta .delta-neutral { color: var(--muted); }

/* ─── Collapsible Sidebar ─────────────────────────────────────── */
.sidebar { transition: width .22s cubic-bezier(.4,0,.2,1); }
.sidebar.collapsed { width: 56px; overflow: hidden; }
.sidebar.collapsed .sidebar-logo { overflow: hidden; }
.sidebar.collapsed .nav-section,
.sidebar.collapsed .logo-name,
.sidebar.collapsed .logo-sub,
.sidebar.collapsed .nav-item .nav-label,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .nav-dot { display: none; }
.sidebar.collapsed .nav-item {
  padding: 10px 0; justify-content: center;
  border-left: none; font-size: 0; overflow: hidden;
}
.sidebar.collapsed .nav-item svg { font-size: 0; }
.sidebar.collapsed .nav-item .nav-dot { font-size: 0; width: 0; height: 0; margin: 0; }
.sidebar.collapsed .nav-item.active { background: rgba(255,255,255,.08); }
.sidebar.collapsed .nav-item svg { margin: 0; }
.sidebar.collapsed .sidebar-logo { padding: 14px 0; justify-content: center; }
.sidebar.collapsed .logo-mark { margin: 0; }

/* Topbar toggle button */
/* Sidebar collapse button */
.sidebar-collapse-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 18px;
  background: none; border: none;
  border-top: 1px solid rgba(255,255,255,.06);
  color: var(--sidebar-m);
  font-family: var(--font); font-size: 12.5px;
  cursor: pointer;
  transition: color .12s, background .12s;
  text-align: left;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover {
  color: var(--sidebar-t);
  background: rgba(255,255,255,.04);
}
.sidebar-collapse-btn .icon-collapse { display: block; flex-shrink: 0; }
.sidebar-collapse-btn .icon-expand   { display: none;  flex-shrink: 0; }

/* Collapsed state */
.sidebar.collapsed .sidebar-collapse-btn {
  justify-content: center;
  padding: 9px 0;
}
.sidebar.collapsed .sidebar-collapse-btn .icon-collapse { display: none; }
.sidebar.collapsed .sidebar-collapse-btn .icon-expand   { display: block; }
.sidebar.collapsed .sidebar-collapse-btn .nav-label { display: none; }

/* Tooltip for collapsed nav items */
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 8px); top: 50%;
  transform: translateY(-50%);
  background: var(--surface2); color: var(--text);
  font-family: var(--mono); font-size: 11px;
  padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--border2);
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .15s;
  z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
═══════════════════════════════════════════════════════════════════ */

/* Mobile-only menu button (hidden on desktop) */
.sidebar-mobile-close {
  display: none;
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; padding: 0;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%; cursor: pointer; color: var(--sidebar-t);
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-mobile-close:hover { background: rgba(255,255,255,.15); }
@media (max-width: 768px) {
  .sidebar-mobile-close { display: flex; }
}

.mobile-menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; flex-shrink: 0;
  border-radius: var(--r); border: 1px solid var(--border2);
  background: var(--surface2); color: var(--text);
  cursor: pointer; transition: background .12s, color .12s;
}
.mobile-menu-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Overlay */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,.5);
}
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
  /* ── Layout ── */
  body { flex-direction: column; }

  /* Sidebar becomes a fixed drawer, hidden off-screen */
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 200;
    height: 100dvh; height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1) !important;
    width: 260px !important;
    overflow-y: auto;
  }
  .sidebar.mobile-open { transform: translateX(0) !important; }

  /* When sidebar is open as drawer, always show full nav (ignore collapsed state) */
  .sidebar.mobile-open .nav-section,
  .sidebar.mobile-open .logo-name,
  .sidebar.mobile-open .logo-sub,
  .sidebar.mobile-open .nav-item .nav-label,
  .sidebar.mobile-open .sidebar-footer,
  .sidebar.mobile-open .nav-dot { display: revert !important; }
  .sidebar.mobile-open .nav-item {
    padding: 9px 18px !important;
    justify-content: flex-start !important;
    font-size: 13px !important;
  }
  .sidebar.mobile-open .sidebar-logo { padding: 20px 18px 16px !important; justify-content: flex-start !important; }
  .sidebar.mobile-open .logo-mark { margin: unset !important; }
  /* Hide collapse btn on mobile (not needed since sidebar is a drawer) */
  .sidebar-collapse-btn { display: none !important; }

  /* ── Main wrap fills screen ── */
  .main-wrap { width: 100%; min-width: 0; }

  /* ── Topbar ── */
  .topbar { padding: 0 12px; height: 52px; }
  .page-title { font-size: 14px; }
  .page-title em { display: none; }
  .refresh-pill { display: none; }
  .topbar-right { gap: 6px; }
  .sidebar-mobile-close {
  display: none;
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; padding: 0;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%; cursor: pointer; color: var(--sidebar-t);
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-mobile-close:hover { background: rgba(255,255,255,.15); }
@media (max-width: 768px) {
  .sidebar-mobile-close { display: flex; }
}

.mobile-menu-btn { display: flex; }

  /* ── Compare bar ── */
  .compare-bar { padding: 0 12px; overflow-x: auto; white-space: nowrap; }
  .compare-bar-inner { flex-wrap: nowrap; gap: 6px; }
  .cmp-btn { font-size: 11px; padding: 3px 8px; }

  /* ── Main content ── */
  .main-content { padding: 14px 12px 56px; }

  /* ── KPI grids → 2 columns ── */
  .kpi-row-5, .kpi-row-4 { grid-template-columns: 1fr 1fr; }
  .kpi-row-3 { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 22px; }
  .kpi-value.big { font-size: 28px; }

  /* ── Panels/grids → single column ── */
  .grid-2, .charts-2, .charts-3 { grid-template-columns: 1fr; }

  /* ── Tables: scroll horizontally ── */
  .panel { overflow: hidden; }
  .panel table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }

  /* ── Section headers ── */
  .section-header { flex-wrap: wrap; gap: 6px; }

  /* ── Activity person grid ── */
  .person-grid { grid-template-columns: 1fr !important; }
  .person-metrics { grid-template-columns: repeat(3, 1fr) !important; }

  /* ── LinkedIn person cards ── */
  .li-person-grid { grid-template-columns: 1fr !important; }

  /* ── Settings grid ── */
  .settings-grid { grid-template-columns: 1fr !important; }

  /* ── Hide some desktop-only chrome ── */
  .topbar .btn:not(.mobile-menu-btn):not(.theme-toggle):not(.btn-accent) { display: none; }
}

@media (max-width: 480px) {
  .kpi-row-5, .kpi-row-4 { grid-template-columns: 1fr; }
  .person-metrics { grid-template-columns: 1fr 1fr !important; }
  .topbar .btn-accent { display: none; }
}

/* ─── Login Page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-family: var(--font);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 6px;
  color: var(--text);
}
.login-card .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}
.login-field {
  margin-bottom: 16px;
}
.login-field label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.login-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color .12s;
}
.login-field input:focus {
  border-color: var(--accent);
}
.login-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s;
  margin-top: 4px;
}
.login-btn:hover { background: var(--accent2); }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }
.login-error {
  background: var(--red-bg);
  color: var(--red);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--r);
  margin-bottom: 16px;
  display: none;
}
.login-error.visible { display: block; }

/* ─── Loading states ─────────────────────────────────────────── */
.loading-placeholder {
  background: var(--surface2);
  border-radius: 4px;
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { opacity: .5; }
  50% { opacity: .8; }
}
.kpi-value .loading-placeholder {
  width: 80px;
  height: 28px;
  display: inline-block;
}

/* ─── Settings page ──────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
}
.settings-card h3 {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 400;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-field {
  margin-bottom: 14px;
}
.settings-field label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.settings-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
}
.settings-field input:focus { border-color: var(--accent); }
.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
}
.conn-ok { background: var(--green-bg); color: var(--green); }
.conn-err { background: var(--red-bg); color: var(--red); }
.conn-pending { background: var(--amber-bg); color: var(--amber); }

/* ─── Workforce view ─────────────────────────────────────────── */
.wf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .wf-grid { grid-template-columns: 1fr; }
}

/* Headcount bar chart */
.hc-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  padding-top: 8px;
}
.hc-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 4px;
}
.hc-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  line-height: 1;
}
.hc-bar {
  width: 100%;
  max-width: 40px;
  border-radius: 4px 4px 0 0;
  background: var(--personio-bg);
  border: 1px solid var(--personio);
  border-bottom: none;
  transition: height .3s ease;
  min-height: 4px;
}
.hc-bar-current {
  background: var(--personio);
  opacity: .85;
}
.hc-label {
  font-size: 9px;
  color: var(--muted);
  line-height: 1;
  margin-top: 2px;
  white-space: nowrap;
}

/* Workforce tables */
.wf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.wf-table thead th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 500;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.wf-table tbody td {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.wf-table tbody tr:last-child td {
  border-bottom: none;
}
.wf-table tfoot td {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  color: var(--text);
}

/* Bar tracks in tables */
.wf-bar-track {
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.wf-bar-fill {
  height: 100%;
  background: var(--personio);
  border-radius: 3px;
  transition: width .3s ease;
}

/* Type indicator dots */
.wf-type-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* ── Sidebar greeting ─────────────────────────────────────────── */
.sidebar-greeting {
  padding: 16px 18px 14px;
  font-family: Fraunces, serif;
  font-weight: 400;
  font-size: 18px;
  color: var(--sidebar-fg, #f0f6ff);
  border-bottom: 1px solid var(--sidebar-border, #1a2330);
  margin-bottom: 12px;
}

/* ── Presence status dots + labels ───────────────────────────── */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
}
.status-dot.online   { background: #22c55e; box-shadow: 0 0 0 2px #22c55e22; }
.status-dot.sleeping { background: #fbbf24; box-shadow: 0 0 0 2px #fbbf2422; }
.status-dot.offline  { background: #475569; }

.status-online   { color: #22c55e; font-weight: 500; }
.status-sleeping { color: #fbbf24; font-weight: 500; }
.status-offline  { color: #94a3b8; font-weight: 500; }
.status-never    { color: #64748b; font-style: italic; }

/* ── Users view ──────────────────────────────────────────────── */
.users-filterbar {
  display: flex; gap: 8px; margin: 0 0 14px; align-items: center;
}
.users-filterbar input { flex: 1; }

.users-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
.users-table th, .users-table td { padding: 10px 12px; }
.users-table thead tr { background: var(--bg, #0e1419); border-bottom: 1px solid var(--border, #2a3441); }
.users-table th {
  color: var(--muted, #64748b); font-weight: 500; text-transform: uppercase;
  font-size: 10.5px; letter-spacing: .04em; text-align: left;
}
.users-table tbody tr { border-bottom: 1px solid var(--row-border, #1a2330); }
.users-table tbody tr:last-child { border-bottom: none; }
.users-table .col-status { text-align: center; }

/* ── Role pills (admin Users page) ────────────────────────── */
.role-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.role-pill.role-admin         { background: #7c3aed33; color: #a78bfa; }
.role-pill.role-leadership    { background: #06b6d433; color: #22d3ee; }
.role-pill.role-head_of_sales { background: #fbbf2433; color: #fbbf24; }
.role-pill.role-sales_rep     { background: #22c55e33; color: #22c55e; }

/* Users view — inputs adopt the settings-field look */
.users-filterbar input,
.users-filterbar select,
.users-table input:not([type=checkbox]),
.users-table select {
  padding: 7px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
}
.users-filterbar input:focus,
.users-filterbar select:focus,
.users-table input:not([type=checkbox]):focus,
.users-table select:focus { border-color: var(--accent); }

/* Users view — row hover */
.users-table tbody tr:hover { background: var(--surface2); }

/* Users view — keep the row-action buttons on one line */
.users-table td:last-child { white-space: nowrap; }

/* Users view — recent audit log sub-card header */
.audit-preview header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.audit-preview h3 {
  font-family: var(--serif); font-size: 15px; font-weight: 400; margin: 0;
}
.audit-preview header a {
  font-family: var(--mono); font-size: 11px;
  color: var(--accent); text-decoration: none;
}

/* ── Permission grid (role + user editor modals) ───────────── */
.perm-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.perm-group {
  border: 1px solid var(--border, #2a3441);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--surface, #0e1419);
}
.perm-group-header {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 4px 0 8px;
  font-weight: 600;
}
.perm-row {
  display: flex;
  align-items: center;
  padding: 4px 0;
  gap: 8px;
}
.perm-row label {
  flex: 1;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.perm-row label code {
  font-size: 11px;
  opacity: 0.55;
  font-family: 'DM Mono', monospace;
}
.perm-row input[type=checkbox] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ── Tri-state per-permission override control ───────────────── */
.perm-tristate {
  display: inline-flex;
  border: 1px solid var(--border, #2a3441);
  border-radius: 5px;
  overflow: hidden;
  font-size: 12px;
}
.perm-tristate label {
  padding: 4px 10px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  user-select: none;
  border-right: 1px solid var(--border, #2a3441);
  transition: background 0.1s, color 0.1s;
}
.perm-tristate label:last-child { border-right: none; }
.perm-tristate input[type=radio] { display: none; }
.perm-tristate input[type=radio]:checked + label {
  background: var(--accent, #ff7d3c);
  color: white;
}
.perm-row.with-tristate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}
.perm-row.with-tristate .perm-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.perm-row.with-tristate .perm-info code {
  font-size: 11px;
  opacity: 0.55;
  font-family: 'DM Mono', monospace;
}
.perm-row.with-tristate .role-hint {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Audit log view ──────────────────────────────────────── */
.audit-filterbar { display:flex; gap:8px; margin:12px 0; }
.audit-table {
  width:100%; border-collapse:collapse; font-size:12.5px;
  background:var(--card-bg, #11181f); border-radius:8px; overflow:hidden;
}
.audit-table th, .audit-table td { padding:8px 12px; }
.audit-table thead tr {
  background:var(--bg, #0e1419);
  border-bottom:1px solid var(--border, #2a3441);
}
.audit-table th {
  color:var(--muted, #64748b); font-weight:500;
  text-transform:uppercase; font-size:10.5px;
  letter-spacing:.04em; text-align:left;
}
.audit-table tbody tr { border-bottom:1px solid var(--row-border, #1a2330); }
.audit-table tbody tr:last-child { border-bottom:none; }
.audit-pagination {
  display:flex; gap:12px; align-items:center; margin-top:12px;
}
.audit-pagination button {
  background:#1a2330; border:1px solid #2a3441; color:#cbd5e1;
  padding:6px 12px; border-radius:5px; cursor:pointer; font-size:12px;
}
.audit-pagination button:disabled { opacity:.4; cursor:not-allowed; }

/* ══════════════════════════════════════════════════════════
   FUNNEL SECTION
   spec: docs/specs/2026-05-19-funnel-section-design.md §11
   ══════════════════════════════════════════════════════════ */

/* Per-phase sync banner */
.funnel-sync-banner {
  background: var(--bg, #0e1419);
  border: 1px solid var(--border, #2a3441);
  border-left: 3px solid var(--accent, #ff7043);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.funnel-sync-banner .sync-banner-label {
  color: var(--muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10.5px;
  font-weight: 600;
}
.funnel-sync-banner .sync-phase {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11.5px;
}
.funnel-sync-banner .sync-phase.done    { background: #22c55e33; color: #22c55e; }
.funnel-sync-banner .sync-phase.running { background: #ff704333; color: #ff7043; }
.funnel-sync-banner .sync-phase.pending { background: #64748b22; color: #64748b; }
.funnel-sync-banner .sync-phase.skipped { background: #fbbf2433; color: #fbbf24; }
.funnel-sync-banner .sync-phase.error   { background: #ef444433; color: #f87171; }

/* Warning variant — used when last sync had skipped/errored phases. */
.funnel-sync-banner.funnel-sync-banner-warn {
  border-left-color: #fbbf24;
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
}
.funnel-sync-banner-warn .sync-banner-label { color: #fbbf24; }
.sync-hint-list { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.sync-hint {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 12px; color: var(--text, #cbd5e1);
  line-height: 1.4;
}
.sync-hint-warning .sync-hint-icon { color: #fbbf24; }
.sync-hint-error   .sync-hint-icon { color: #f87171; }
.sync-hint-icon { flex-shrink: 0; font-size: 13px; }

/* Timeframe control bar */
.funnel-timeframe-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 8px 12px;
  background: var(--bg, #0e1419);
  border: 1px solid var(--border, #2a3441);
  border-radius: 6px;
}
.funnel-timeframe-bar .tf-label {
  color: var(--muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10.5px;
  font-weight: 600;
  margin-right: 4px;
}
.funnel-timeframe-bar .tf-preset {
  background: transparent;
  border: 1px solid var(--border, #2a3441);
  color: var(--text, #cbd5e1);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  min-width: 38px;
}
.funnel-timeframe-bar .tf-preset:hover {
  border-color: var(--accent, #ff7043);
  color: var(--accent, #ff7043);
}
.funnel-timeframe-bar .tf-preset.active {
  background: var(--accent, #ff7043);
  border-color: var(--accent, #ff7043);
  color: #fff;
}
.funnel-timeframe-bar .tf-custom-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}
.funnel-timeframe-bar .tf-date-input {
  background: var(--card-bg, #11181f);
  border: 1px solid var(--border, #2a3441);
  color: var(--text, #cbd5e1);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.funnel-timeframe-bar .tf-asof-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255, 112, 67, 0.15);
  border: 1px solid var(--accent, #ff7043);
  color: var(--accent, #ff7043);
  font-size: 12px;
  font-weight: 500;
  cursor: help;
}

/* Big funnel diagram */
.funnel-flow-toggle .pf-btn { font-size: 11px; padding: 3px 10px; }
.funnel-flow-svg { padding: 16px 8px 8px; }
.funnel-groupings { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.grouping-pill {
  background: var(--card-bg, #11181f);
  border: 1px solid var(--border, #2a3441);
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--muted, #94a3b8);
}
.grouping-pill.grouping-sql {
  border-color: var(--accent, #ff7043);
  color: var(--accent, #ff7043);
}
.grouping-pill.grouping-total { font-weight: 600; color: var(--text, #cbd5e1); }

.funnel-flow-row { display: flex; align-items: stretch; gap: 4px; flex-wrap: wrap; }
.funnel-seg {
  flex: 1 1 0;
  min-width: 90px;
  background: var(--card-bg, #11181f);
  border: 1px solid var(--border, #2a3441);
  border-radius: 6px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.funnel-seg:hover { border-color: var(--accent, #ff7043); transform: translateY(-1px); }
.funnel-seg.funnel-seg-dim { opacity: 0.45; }
.funnel-seg-badge {
  display: inline-block;
  width: 22px; height: 22px; line-height: 22px;
  border-radius: 50%;
  background: var(--accent, #ff7043);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
}
.funnel-seg-label {
  font-size: 11px;
  color: var(--muted, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  line-height: 1.2;
}
.funnel-seg-count {
  font-size: 18px;
  font-weight: 600;
  color: var(--text, #cbd5e1);
  font-family: var(--serif, 'Fraunces'), serif;
}
/* Folded-in scorecard details */
.funnel-seg-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 4px;
}
.funnel-seg-head .funnel-seg-badge { margin-bottom: 0; }
.funnel-seg-owner {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 600;
  line-height: 1;
}
.funnel-seg-owner-marketing { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.funnel-seg-owner-sales     { background: rgba(34, 197, 94, 0.15);  color: #4ade80; }
.funnel-seg-deltas {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 10px;
}
.seg-delta-up   { color: #22c55e; }
.seg-delta-down { color: #f87171; }
.funnel-seg-conv {
  font-size: 10px;
  color: var(--muted, #94a3b8);
  margin-top: 3px;
  font-weight: 500;
}
.funnel-seg-arrow {
  display: flex; align-items: center;
  color: var(--muted, #64748b);
  font-size: 14px;
  padding: 0 2px;
}
.funnel-terminals { display: flex; flex-direction: column; gap: 4px; margin-left: 4px; }
.funnel-terminal {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 11px;
  text-align: center;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.funnel-terminal span { display: block; font-size: 16px; font-weight: 700; margin-top: 2px; }
.funnel-terminal-won  { background: #22c55e22; color: #22c55e; border: 1px solid #22c55e55; }
.funnel-terminal-lost { background: #ef444422; color: #f87171; border: 1px solid #ef444455; }

/* Per-stage scorecards */
.funnel-cards-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 8px;
}
@media (max-width: 1400px) { .funnel-cards-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1100px) { .funnel-cards-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px)  { .funnel-cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .funnel-cards-grid { grid-template-columns: 1fr; } }
.funnel-card {
  background: var(--card-bg, #11181f);
  border: 1px solid var(--border, #2a3441);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  transition: border-color .15s;
}
.funnel-card:hover { border-color: var(--accent, #ff7043); }
.funnel-card.funnel-card-empty { opacity: 0.55; }
.funnel-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.funnel-card-num {
  display: inline-block;
  width: 18px; height: 18px; line-height: 18px;
  border-radius: 50%;
  background: var(--accent, #ff7043);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
}
.funnel-card-title { font-size: 12px; color: var(--text, #cbd5e1); font-weight: 500; flex: 1; }
.card-owner {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 3px;
}
.card-owner-marketing { background: #06b6d433; color: #22d3ee; }
.card-owner-sales     { background: #fbbf2433; color: #fbbf24; }
.funnel-card-count {
  font-size: 24px;
  font-weight: 600;
  color: var(--text, #cbd5e1);
  font-family: var(--serif, 'Fraunces'), serif;
  line-height: 1.1;
  margin-bottom: 6px;
}
.funnel-card-deltas { display: flex; gap: 8px; font-size: 11px; margin-bottom: 4px; }
.card-delta-up   { color: #22c55e; }
.card-delta-down { color: var(--muted, #64748b); }
.funnel-card-conv { font-size: 10.5px; color: var(--muted, #94a3b8); }

/* Empty / stub states */
.funnel-empty {
  padding: 16px;
  text-align: center;
  color: var(--muted, #64748b);
  font-size: 12px;
  font-style: italic;
}
.funnel-empty-positive { color: #22c55e; font-style: normal; }

/* ─── Pipeline flow reports (funnel follow-on) ──────────────────────── */
.pf-pipeline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
.pf-toggle { display: inline-flex; border: 1px solid var(--border, #2a3441); border-radius: 5px; overflow: hidden; }
.pf-toggle .pf-btn { font-size: 11px; padding: 4px 12px; }
.pf-slicer {
  background: var(--card-bg, #11181f);
  border: 1px solid var(--border, #2a3441);
  color: var(--text, #cbd5e1);
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 12px;
}
.pf-flow { padding: 18px 8px 6px; }
.pf-flow-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-wrap: nowrap;
}
.pf-stage {
  flex: 1 1 0;
  min-width: 0;
  background: var(--card-bg, #11181f);
  border: 1px solid var(--border, #2a3441);
  border-radius: 8px;
  padding: 14px 10px;
  text-align: center;
}
.pf-stage-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #cbd5e1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pf-stage-count {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent, #ff7043);
  font-family: var(--mono, monospace);
  margin-top: 6px;
}
.pf-stage-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted, #94a3b8);
}
.pf-stage-median {
  font-size: 11px;
  color: var(--muted, #94a3b8);
  margin-top: 8px;
  font-family: var(--mono, monospace);
}
.pf-conn {
  flex: 0 0 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
}
.pf-conn::before {
  content: "\2192";
  color: var(--muted, #64748b);
  font-size: 16px;
}
.pf-conn-metric {
  font-size: 11px;
  font-family: var(--mono, monospace);
  color: var(--text, #cbd5e1);
  cursor: help;
  white-space: nowrap;
}
.pf-conn-cohort { color: var(--accent, #ff7043); }
.pf-flow-detail { padding: 8px 0 4px; }
.pf-detail-table { margin-top: 8px; }
@media (max-width: 768px) {
  .pf-flow-row { flex-wrap: wrap; }
  .pf-stage { flex: 1 1 100%; }
  .pf-conn { flex: 1 1 100%; flex-direction: row; padding: 4px 0; }
  .pf-conn::before { content: "\2193"; }
  .pf-pipeline-controls { width: 100%; margin-top: 8px; }
}

/* Activity block */
.activity-totals {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 10px;
}
@media (max-width: 600px) { .activity-totals { grid-template-columns: repeat(2, 1fr); } }
.activity-tot {
  background: var(--card-bg, #11181f);
  border: 1px solid var(--border, #2a3441);
  border-radius: 6px;
  padding: 12px 8px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--text, #cbd5e1);
}
.activity-tot .act-icon { display: block; font-size: 16px; color: var(--accent, #ff7043); margin-bottom: 4px; }
.activity-tot small { display: block; font-size: 10.5px; color: var(--muted, #64748b); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; margin-top: 2px; }

.activity-section { padding: 10px; }
.activity-section-head { font-size: 11px; color: var(--muted, #64748b); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; margin-bottom: 8px; }
.activity-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.activity-table thead tr { background: var(--bg, #0e1419); }
.activity-table th { padding: 6px 10px; text-align: left; color: var(--muted, #64748b); text-transform: uppercase; font-size: 10px; letter-spacing: 0.04em; font-weight: 500; }
.activity-table th:not(:first-child) { text-align: right; width: 50px; }
.activity-table td { padding: 5px 10px; color: var(--text, #cbd5e1); border-top: 1px solid var(--row-border, #1a2330); }
.activity-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

.activity-heatmap { width: 100%; border-collapse: collapse; font-size: 11px; }
.activity-heatmap th { padding: 4px 6px; text-align: center; color: var(--muted, #64748b); font-weight: 500; font-size: 10px; }
.activity-heatmap th:first-child { text-align: left; width: 170px; }
.activity-heatmap .hm-stage-label { padding: 4px 8px; color: var(--text, #cbd5e1); font-size: 11px; white-space: nowrap; }
.activity-heatmap .hm-cell {
  text-align: center; padding: 3px 6px; min-width: 28px;
  color: var(--text, #cbd5e1); font-variant-numeric: tabular-nums;
  border: 1px solid var(--row-border, #1a2330);
  font-size: 10.5px;
}

/* Win/loss anatomy */
.winloss-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 10px;
}
@media (max-width: 800px) { .winloss-cols { grid-template-columns: 1fr; } }
.winloss-col {
  background: var(--card-bg, #11181f);
  border: 1px solid var(--border, #2a3441);
  border-radius: 6px;
  padding: 14px;
}
.winloss-col-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.winloss-won .winloss-col-head  { color: #22c55e; }
.winloss-lost .winloss-col-head { color: #f87171; }
.winloss-col-meta { font-size: 11.5px; color: var(--muted, #94a3b8); margin-bottom: 10px; }
.winloss-subhead {
  font-size: 11px;
  color: var(--muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 10px 0 4px;
  font-weight: 500;
}
.winloss-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.winloss-table th { text-align: left; color: var(--muted, #64748b); font-weight: 500; padding: 6px 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.winloss-table th:not(:first-child) { text-align: right; }
.winloss-table td { padding: 4px 8px; color: var(--text, #cbd5e1); border-top: 1px solid var(--row-border, #1a2330); }
.winloss-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

/* Web analytics */
.web-block-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 10px; }
@media (max-width: 800px) { .web-block-row { grid-template-columns: 1fr; } }
.web-block-col { background: var(--card-bg, #11181f); border: 1px solid var(--border, #2a3441); border-radius: 6px; padding: 14px; }
.web-block-head { font-size: 11px; color: var(--muted, #64748b); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; margin-bottom: 8px; }
.web-block-list { list-style: none; padding: 0; margin: 0; font-size: 12.5px; color: var(--text, #cbd5e1); }
.web-block-list li { padding: 3px 0; border-bottom: 1px solid var(--row-border, #1a2330); }
.web-block-list li:last-child { border-bottom: none; }

/* Horizontal bar list for web-analytics aggregates */
.web-bar-list { list-style: none; padding: 0; margin: 0; }
.web-bar-row {
  display: grid;
  grid-template-columns: minmax(60px, 1fr) minmax(40px, 3fr) auto;
  gap: 8px;
  align-items: center;
  padding: 3px 0;
  border-bottom: 1px solid var(--row-border, #1a2330);
  font-size: 11.5px;
}
.web-bar-row:last-child { border-bottom: none; }
.web-bar-label {
  color: var(--text, #cbd5e1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.web-bar-fill {
  background: linear-gradient(90deg, var(--accent, #ff7043), transparent);
  height: 6px;
  border-radius: 3px;
  min-width: 4px;
}
.web-bar-count {
  color: var(--text, #cbd5e1);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.web-bar-extra { color: var(--muted, #94a3b8); font-weight: 400; margin-left: 4px; }

.ai-trend-foot {
  font-size: 11px;
  color: var(--muted, #94a3b8);
  margin-top: 4px;
}

/* Data health */
.health-summary { padding: 10px 14px; font-size: 13px; color: var(--text, #cbd5e1); display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.health-sev-error   { color: #f87171; }
.health-sev-warning { color: #fbbf24; }
.health-sev-info    { color: #60a5fa; }
.health-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 10px; }
@media (max-width: 800px) { .health-cards { grid-template-columns: 1fr; } }
.health-card {
  background: var(--card-bg, #11181f);
  border: 1px solid var(--border, #2a3441);
  border-left-width: 3px;
  border-radius: 6px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.health-card-error   { border-left-color: #ef4444; }
.health-card-warning { border-left-color: #fbbf24; }
.health-card-info    { border-left-color: #3b82f6; }
.health-card-clean   { border-left-color: #22c55e; opacity: 0.7; }
.health-card-head { display: flex; align-items: center; gap: 8px; }
.health-card-sev { font-size: 16px; }
.health-card-title { font-size: 12.5px; color: var(--text, #cbd5e1); font-weight: 500; flex: 1; }
.health-card-count {
  font-size: 11.5px; color: var(--muted, #94a3b8);
  font-variant-numeric: tabular-nums;
}
.health-card-count strong { color: var(--text, #cbd5e1); font-size: 14px; font-weight: 600; margin-right: 4px; }
.health-card-desc { font-size: 11px; color: var(--muted, #64748b); line-height: 1.4; }
.health-card-btn {
  align-self: flex-start;
  margin-top: 4px;
  padding: 3px 10px;
  font-size: 11px;
}

/* Drill-down panel */
.health-drill-down {
  background: var(--bg, #0e1419);
  border: 1px solid var(--border, #2a3441);
  border-radius: 6px;
  margin: 6px 10px 10px;
  padding: 10px;
}
.drill-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
}
.drill-head strong { color: var(--text, #cbd5e1); font-size: 13px; }
.drill-count { color: var(--muted, #94a3b8); font-size: 11.5px; }
.drill-close { margin-left: auto; }
.drill-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.drill-table thead tr { background: var(--card-bg, #11181f); }
.drill-table th { text-align: left; padding: 6px 10px; color: var(--muted, #64748b); text-transform: uppercase; font-size: 10px; letter-spacing: 0.04em; font-weight: 500; }
.drill-table td { padding: 6px 10px; color: var(--text, #cbd5e1); border-top: 1px solid var(--row-border, #1a2330); vertical-align: top; }
.drill-table a { color: inherit; text-decoration: none; }
.drill-table a:hover { color: var(--accent, #ff7043); }
.drill-stage { font-size: 11.5px; }
.drill-owner { font-size: 10.5px; color: var(--muted, #94a3b8); }
.drill-chip {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 1px 4px 1px 0;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--card-bg, #11181f);
  border: 1px solid var(--border, #2a3441);
  font-size: 10.5px;
  text-decoration: none;
  color: var(--text, #cbd5e1);
}
.drill-chip:hover { border-color: var(--accent, #ff7043); }
.drill-open { color: var(--accent, #ff7043); font-size: 11px; white-space: nowrap; }
.drill-foot { color: var(--muted, #64748b); font-size: 11px; padding: 8px 4px 0; }

/* Transitions table */
.funnel-transitions-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.funnel-transitions-table thead tr { background: var(--bg, #0e1419); border-bottom: 1px solid var(--border, #2a3441); }
.funnel-transitions-table th { padding: 8px 12px; color: var(--muted, #64748b); font-weight: 500; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.04em; text-align: left; }
.funnel-transitions-table td { padding: 6px 12px; color: var(--text, #cbd5e1); border-top: 1px solid var(--row-border, #1a2330); }
.funnel-transitions-table code { font-family: var(--mono, 'DM Mono'), monospace; font-size: 11px; color: var(--accent, #ff7043); }
.type-chip { display: inline-block; padding: 1px 8px; border-radius: 3px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.type-chip.type-deal    { background: #fbbf2433; color: #fbbf24; }
.type-chip.type-contact { background: #06b6d433; color: #22d3ee; }
.type-chip.type-lead    { background: #a78bfa33; color: #a78bfa; }

/* Stale items */
.stale-group { margin-bottom: 14px; }
.stale-group-head { font-size: 12px; font-weight: 600; color: var(--text, #cbd5e1); padding: 6px 12px; background: var(--bg, #0e1419); border-radius: 4px 4px 0 0; }
.stale-group-head small { color: var(--muted, #64748b); font-weight: 400; margin-left: 8px; }
.stale-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.stale-table th { padding: 6px 12px; color: var(--muted, #64748b); font-weight: 500; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.04em; text-align: left; }
.stale-table td { padding: 6px 12px; color: var(--text, #cbd5e1); border-top: 1px solid var(--row-border, #1a2330); }

/* Mobile collapse to vertical */
@media (max-width: 768px) {
  .funnel-flow-row    { flex-direction: column; }
  .funnel-seg         { width: 100%; }
  .funnel-seg-arrow   { transform: rotate(90deg); padding: 4px 0; }
  .funnel-terminals   { flex-direction: row; margin-top: 8px; margin-left: 0; }
  .funnel-terminal    { flex: 1; }
}

/* Mobile tightening: hide the per-engagement-type columns in tight tables.
   Keeps Days + activity-totals readable on phones; switch to desktop for
   the per-type breakdown. */
@media (max-width: 600px) {
  /* Win/loss anatomy: hide 5 activity-type columns (cols 3–7) */
  .winloss-table th:nth-child(n+3),
  .winloss-table td:nth-child(n+3) { display: none; }
  /* Allow long stage labels to wrap */
  .winloss-table td:first-child { white-space: normal; word-break: normal; }

  /* Activity tables: hide per-type cols, keep stage/owner + total */
  .activity-table th:nth-child(2),
  .activity-table th:nth-child(3),
  .activity-table th:nth-child(4),
  .activity-table th:nth-child(5),
  .activity-table th:nth-child(6),
  .activity-table td:nth-child(2),
  .activity-table td:nth-child(3),
  .activity-table td:nth-child(4),
  .activity-table td:nth-child(5),
  .activity-table td:nth-child(6) { display: none; }

  /* Activity heatmap: tight cells + horizontal scroll wrapper if it overflows */
  .activity-heatmap { font-size: 10px; }
  .activity-heatmap .hm-stage-label { padding: 3px 4px; font-size: 10px; max-width: 110px; white-space: normal; }
  .activity-heatmap .hm-cell { padding: 2px 4px; min-width: 22px; }

  /* Drill-down table: hide the Related column (long chips chain) on small screens */
  .drill-table th:nth-child(3),
  .drill-table td:nth-child(3) { display: none; }
}

/* ── Dashboard display settings (admin-controlled visibility) ─────────────
   .dash-hidden + the body.disp-hide-* rules use !important so they win over
   gateByPermission()'s inline `style.display` on elements carrying both
   data-display and data-permission. */
.dash-hidden { display: none !important; }
body.disp-hide-cycle .col-cycle { display: none !important; }
body.disp-hide-gauge-pp .gauge-mini-delta { display: none !important; }
body.disp-hide-vert-arreoy .col-vert-arreoy { display: none !important; }

/* ── Scenarios: weight panel + delta badges ───────────────────── */
#scn-weight-panel { display:flex; flex-direction:column; gap:6px; }
.scn-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.scn-row .scn-stage { min-width:200px; font-size:13px; font-weight:600; }
.scn-row .scn-now { min-width:84px; font-size:11px; color:var(--muted); }
.scn-input { width:64px; padding:3px 6px; font-size:13px; border:1px solid var(--border);
  border-radius:6px; background:var(--surface); color:var(--text); }
.scn-input.scn-active { border-color:var(--accent); }
.scn-input-eur { width:84px; }
.scn-delta { font-size:11px; font-weight:600; white-space:nowrap; }
/* Color-only deltas (no background pill) so KPI, path-table and gauge badges match. */
.scn-delta.delta-up { background:none; color:var(--green); }
.scn-delta.delta-down { background:none; color:#ef4444; }
.scn-delta.delta-neutral { background:none; color:var(--muted); }
.kpi-sub[id^="scn-"][id$="-real"] { color:var(--muted); }
/* Scenarios: clickable KPIs + drill-down tables */
.scn-clickable { cursor:pointer; }
.scn-clickable:hover { outline:1px solid var(--accent); outline-offset:-1px; }
.scn-drill .scn-drill-title { font-size:12px; font-weight:600; margin-bottom:8px; }
.scn-drill-note { font-size:13px; color:var(--muted); }
table.scn-drill-table { width:100%; border-collapse:collapse; font-size:12px; }
table.scn-drill-table th, table.scn-drill-table td { padding:4px 8px; border-bottom:1px solid var(--border); }
table.scn-drill-table td.num, table.scn-drill-table th.num { text-align:right; white-space:nowrap; }
table.scn-drill-table tfoot td { border-top:2px solid var(--border); border-bottom:none; }
/* Scenarios: one-line metric descriptor under each KPI label */
#view-scenario .kpi-hint { font-size:10px; color:var(--muted); line-height:1.2; margin:1px 0 2px; }
/* Scenarios: group section headers between KPI rows */
.scn-group-label { font-size:11px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; margin:14px 0 6px; }

