/* ============================================================
   Juventus Portal — Stylesheet (Phase 3 design system)
   Editorial luxury — warm stone-black + gold accent.
   Palette: logo extraction + ui-ux-pro-max recommendation.
   Typography: Playfair Display (display) + Jost (body).
   See docs/dashboard-spec.md §2 for full design rationale.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&family=Jost:wght@300;400;500;600;700&display=swap');

:root {
  /* Brand — gold (from logo extraction) */
  --brand-gold:        #AB8121;
  --brand-gold-dark:   #906210;
  --brand-gold-light:  #D8C060;
  --brand-gold-glow:   #F1DA69;
  --brand-anchor:      #906000;
  --brand-accent-rich: #A16207;     /* uupm "Premium black + gold" alt accent */
  --brand-gradient:    linear-gradient(135deg,
                         #906210 0%,
                         #AB8121 35%,
                         #D8C060 70%,
                         #F1DA69 100%);

  /* Neutrals — warm stone-black + ivory (editorial luxury, not blue-tech) */
  --ink-noir:          #1C1917;     /* Sidebar, primary headings */
  --ink-charcoal:      #0C0A09;     /* Body text */
  --ink-muted:         #64748B;     /* Secondary text */
  --surface-ivory:     #FAFAF9;     /* Page background */
  --surface-card:      #FFFFFF;     /* Card surfaces */
  --surface-line:      #D6D3D1;     /* Borders, dividers */

  /* States */
  --state-success:     #0E9F6E;
  --state-danger:      #DC2626;
  --state-warning:     #FF8A4C;
  --state-info:        #3B82F6;

  /* Layout */
  --sidebar-width:     220px;
  --topbar-height:     64px;
  --radius-sm:         6px;
  --radius-md:         10px;
  --radius-lg:         14px;
  --shadow-sm:         0 1px 2px rgba(28, 25, 23, 0.06);
  --shadow-md:         0 4px 12px rgba(28, 25, 23, 0.08);
  --shadow-lg:         0 12px 32px rgba(28, 25, 23, 0.14);

  /* Type — Playfair Display for display, Jost for body */
  --font-display:      "Playfair Display", "Cormorant Garamond", Georgia, serif;
  --font-body:         "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:         ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ── Base ──────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-charcoal);
  background: var(--surface-ivory);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--brand-gold-dark);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--brand-anchor);
  text-decoration: underline;
}

h1, h2 {
  font-family: var(--font-display);
  color: var(--ink-noir);
  font-weight: 500;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.015em;
}
h3, h4 {
  /* Use Jost for small headings — Playfair Display gets too narrow + hard to read below 22px */
  font-family: var(--font-body);
  color: var(--ink-noir);
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.005em;
}
h1 { font-size: 1.875rem; line-height: 1.15; }   /* 30px Playfair Display */
h2 { font-size: 1.5rem;   line-height: 1.2;  }   /* 24px Playfair Display */
h3 { font-size: 1.0625rem; line-height: 1.35; } /* 17px Jost 600 */
h4 { font-size: 0.9375rem; line-height: 1.4; }  /* 15px Jost 600 */

/* Tabular numerals for KPI displays and tables */
.num-tabular { font-variant-numeric: tabular-nums; }

/* Playfair Display numerals for KPI hero numbers */
.kpi-number {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

p { margin: 0 0 0.75rem 0; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--surface-line);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* ── Layout: sidebar + topbar + main ───────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  background: var(--ink-noir);
  color: #E5E7EB;
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar__logo {
  padding: 0 1.25rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.sidebar__logo a { display: block; flex: 1; min-width: 0; }
.sidebar__logo img {
  display: block;
  width: 100%;
  height: auto;
  /* Logo is gold-on-transparent — sits beautifully on the noir background */
}
.sidebar__close {
  display: none;     /* hidden on desktop, shown on mobile */
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
}
.sidebar__close:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.sidebar__nav a {
  display: block;
  padding: 0.55rem 0.85rem;
  color: rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar__nav a:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
}
.sidebar__nav a.is-active {
  background: rgba(216, 192, 96, 0.16); /* tinted gold */
  color: var(--brand-gold-glow);
  font-weight: 600;
}
.sidebar__group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  padding: 1rem 0.85rem 0.4rem 0.85rem;
}

/* Mobile-only user footer in the sidebar (hidden on desktop) */
.sidebar__user {
  display: none;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: auto;
}
.sidebar__user-id {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.sidebar__user-name { color: #fff; font-weight: 600; font-size: 0.95rem; }
.sidebar__user-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.sidebar__user-actions .btn {
  flex: 1 1 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12);
}
.sidebar__user-actions .btn:hover {
  background: rgba(255, 255, 255, 0.14);
  text-decoration: none;
}

/* Mobile-only scrim/backdrop (hidden by default) */
.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.55);
  backdrop-filter: blur(2px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sidebar-scrim.is-active {
  opacity: 1;
  pointer-events: auto;
}

.topbar {
  grid-area: topbar;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--surface-line);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Hamburger (mobile only) */
.topbar__hamburger {
  display: none;     /* hidden on desktop */
  background: transparent;
  border: 1px solid var(--surface-line);
  color: var(--ink-noir);
  cursor: pointer;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
}
.topbar__hamburger:hover { background: var(--surface-ivory); }
.topbar__hamburger:focus-visible {
  outline: 2px solid var(--brand-gold);
  outline-offset: 2px;
}
.topbar__title {
  font-family: var(--font-display);
  color: var(--ink-noir);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.topbar__user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.92rem; }
.topbar__user .user-name { color: var(--ink-noir); font-weight: 600; }
.topbar__user .user-role {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--brand-gold-light);
  color: var(--brand-gold-dark);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-weight: 600;
}

.main {
  grid-area: main;
  padding: 1.75rem;
  overflow-y: auto;
}

/* ── Cards ─────────────────────────────────────────────────── */

.card {
  background: var(--surface-card);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.card__title {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--ink-noir);
}

/* ── Buttons ───────────────────────────────────────────────── */

.btn {
  display: inline-block;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
              box-shadow 0.15s ease;
  text-decoration: none;
}
.btn:focus-visible {
  outline: 2px solid var(--brand-gold);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brand-gold);
  color: #FFFFFF;
  border-color: var(--brand-gold);
}
.btn-primary:hover {
  background: var(--brand-gold-dark);
  border-color: var(--brand-gold-dark);
  color: #FFFFFF;
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface-card);
  color: var(--ink-noir);
  border-color: var(--surface-line);
}
.btn-secondary:hover {
  background: var(--surface-ivory);
  border-color: var(--ink-muted);
  text-decoration: none;
}

.btn-danger {
  background: var(--surface-card);
  color: var(--state-danger);
  border-color: var(--state-danger);
}
.btn-danger:hover {
  background: var(--state-danger);
  color: #FFFFFF;
  text-decoration: none;
}

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.82rem; }

/* ── Forms ─────────────────────────────────────────────────── */

.form-row { margin-bottom: 1rem; }
.form-row label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-noir);
  margin-bottom: 0.35rem;
  letter-spacing: 0.01em;
}

.form-input,
.form-select {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--ink-charcoal);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 3px rgba(171, 129, 33, 0.15);
}

.form-help {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 0.25rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ── Alerts / banners ──────────────────────────────────────── */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-error    { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.alert-success  { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.alert-info     { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }
.alert-warning  { background: #FFFBEB; color: #92400E; border-color: #FDE68A; }

/* ── Tables ────────────────────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface-card);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.table th, .table td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--surface-line);
}
.table th {
  background: var(--surface-ivory);
  color: var(--ink-noir);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(216, 192, 96, 0.06); }

/* ── Badges ────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}
.badge-gold    { background: var(--brand-gold-light); color: var(--brand-gold-dark); }
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-muted   { background: var(--surface-line); color: var(--ink-muted); }

/* ════════════════════════════════════════════════════════════════
   DASHBOARD (Phase 3)
   ════════════════════════════════════════════════════════════════ */

/* ── Hero ────────────────────────────────────────────────────── */

.dash-hero { margin-bottom: 1.5rem; }
.dash-hero__eyebrow {
  font-family: var(--font-body);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--brand-gold-dark);
  margin: 0 0 0.4rem 0;
  font-weight: 600;
}
.dash-hero__title {
  font-family: var(--font-display);
  font-size: 2.75rem;
  line-height: 1.05;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink-noir);
  margin: 0 0 0.4rem 0;
}
.dash-hero__subhead {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--ink-muted);
  font-weight: 400;
  margin: 0;
  max-width: 60ch;
}

/* ── Banner ──────────────────────────────────────────────────── */

.dash-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #FEF9E7 0%, #FDF6D6 100%);
  border: 1px solid var(--brand-gold-light);
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
  color: var(--ink-charcoal);
}
.dash-banner__icon {
  flex: 0 0 auto;
  color: var(--brand-gold-dark);
  margin-top: 0.1rem;
}
.dash-banner a { color: var(--brand-gold-dark); font-weight: 600; }
.dash-banner em { font-style: italic; }

/* ── Filter row + Live Mode toggle ───────────────────────────── */

.dash-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.dash-pills {
  display: inline-flex;
  background: var(--surface-card);
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.dash-pill {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink-muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.dash-pill:hover { color: var(--ink-noir); text-decoration: none; }
.dash-pill.is-active {
  background: var(--ink-noir);
  color: var(--brand-gold-glow);
}

.dash-live-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.dash-live-mode__updated {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.dash-live-mode__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.dash-live-mode__toggle input { position: absolute; opacity: 0; pointer-events: none; }
.dash-live-mode__track {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  background: var(--surface-line);
  border-radius: 999px;
  transition: background 0.2s ease;
}
.dash-live-mode__thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}
.dash-live-mode__toggle input:checked + .dash-live-mode__track {
  background: var(--brand-gold);
}
.dash-live-mode__toggle input:checked + .dash-live-mode__track .dash-live-mode__thumb {
  transform: translateX(16px);
}
.dash-live-mode__toggle input:focus-visible + .dash-live-mode__track {
  outline: 2px solid var(--brand-gold);
  outline-offset: 2px;
}
.dash-live-mode__label { font-weight: 500; color: var(--ink-noir); }

/* ── Section spacing ─────────────────────────────────────────── */

.dash-section { margin-bottom: 1.75rem; }
.dash-section__header { margin-bottom: 1rem; }
.dash-section__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--ink-noir);
  margin: 0 0 0.25rem 0;
  letter-spacing: -0.01em;
}
.dash-section__subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* ── KPI grid ────────────────────────────────────────────────── */

.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
}
@media (max-width: 1280px) { .dash-kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .dash-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .dash-kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--surface-card);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}
.kpi-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.kpi-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.2s ease;
}
.kpi-card--gold::before    { background: var(--brand-gold); }
.kpi-card--success::before { background: var(--state-success); }
.kpi-card--warning::before { background: var(--state-warning); }
.kpi-card--danger::before  { background: var(--state-danger); }

.kpi-card__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.kpi-card__value {
  font-size: 2.25rem;
  color: var(--ink-noir);
  margin-bottom: 0.25rem;
  line-height: 1;
}
.kpi-card__caption {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* ── 2-column row (funnel + status) ──────────────────────────── */

.dash-2col {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}
@media (max-width: 1024px) { .dash-2col { grid-template-columns: 1fr; } }

/* Cards inside .dash-2col: stretch to equal height + flex column so their
   inner content fills the available vertical space. */
.dash-2col > .card {
  display: flex;
  flex-direction: column;
}
.dash-2col > .card > .card__header { flex: 0 0 auto; }
.dash-2col > .card > .funnel-chart { flex: 1 1 auto; display: flex; align-items: stretch; }
.dash-2col > .card > .funnel-chart > .funnel-chart__svg { width: 100%; height: 100%; }
.dash-2col > .card > .status-bars {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;   /* spread the bars to fill card height */
}
.dash-2col > .card > .status-bars > .status-bar { margin-bottom: 0; }

/* ── Card refinements (header) ───────────────────────────────── */

.card__header {
  margin-bottom: 1rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.card__subtitle {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* ── Funnel chart (integrated SVG: stage name | trapezoid w/ in-bar text | step-over %) ─── */

.funnel-chart {
  /* Soft warm wash behind the whole funnel for depth */
  background: radial-gradient(ellipse at 50% 30%, rgba(216, 192, 96, 0.08) 0%, transparent 70%);
  border-radius: var(--radius-md);
  padding: 0.5rem 0;
}
.funnel-chart__svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Trapezoid behavior */
.funnel-chart__segment {
  transition: opacity 0.2s ease;
  cursor: default;
}
.funnel-chart__svg:hover .funnel-chart__segment { opacity: 0.6; }
.funnel-chart__svg:hover .funnel-chart__segment:hover { opacity: 1; }
.funnel-chart__segment.is-leak {
  filter: drop-shadow(0 2px 4px rgba(220, 38, 38, 0.28));
}
.funnel-chart__segment.is-win {
  filter: drop-shadow(0 3px 6px rgba(14, 159, 110, 0.35));
}

/* SVG text styles. Sized in viewBox units (1 vbu ≈ container_width / 720 px). */

/* Stage name — left side, right-aligned, dark */
.funnel-svg__label {
  fill: var(--ink-charcoal);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.funnel-svg__label.is-leak { fill: var(--state-danger); }
.funnel-svg__label.is-win  { fill: var(--state-success); }

/* In-trapezoid count — large, white */
.funnel-svg__count {
  fill: #FFFFFF;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.18);
  stroke-width: 0.6px;
}

/* In-trapezoid sub-label — percentage on its own line. Softer white. */
.funnel-svg__pct {
  fill: rgba(255, 255, 255, 0.95);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* In-trapezoid third line — "of total" caption. Smaller, more muted. */
.funnel-svg__total {
  fill: rgba(255, 255, 255, 0.75);
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

/* Outside-the-trapezoid variant — used for narrow stages where the count
   wouldn't fit inside the polygon. Dark colors on the ivory page background. */
.funnel-svg__count.is-outside {
  fill: var(--ink-charcoal);
  stroke: none;
}
.funnel-svg__pct.is-outside {
  fill: var(--ink-charcoal);
}
.funnel-svg__total.is-outside {
  fill: var(--ink-muted);
}

/* Step-over % — right side, gray/red/green by tone */
.funnel-svg__step {
  fill: var(--ink-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.funnel-svg__step.is-leak {
  fill: var(--state-danger);
  font-weight: 600;
}
.funnel-svg__step.is-win {
  fill: var(--state-success);
  font-weight: 600;
}
.funnel-svg__step.is-muted { fill: var(--surface-line); }

/* ── Live status bars ────────────────────────────────────────── */

.status-bars { list-style: none; padding: 0; margin: 0; }
.status-bar {
  margin-bottom: 0.8rem;
}
.status-bar:last-child { margin-bottom: 0; }
.status-bar__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.2rem;
}
.status-bar__label { font-size: 0.85rem; color: var(--ink-noir); font-weight: 500; }
.status-bar__count { font-size: 0.85rem; color: var(--ink-noir); font-weight: 600; }
.status-bar__track {
  height: 8px;
  background: rgba(214, 211, 209, 0.45);
  border-radius: 999px;
  overflow: hidden;
}
.status-bar__fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 4px;
}
.status-bar__fill--info     { background: var(--state-info); }
.status-bar__fill--gold     { background: var(--brand-gold); }
.status-bar__fill--warning  { background: var(--state-warning); }
.status-bar__fill--success  { background: var(--state-success); }
.status-bar__fill--danger   { background: var(--state-danger); }
.status-bar__fill--muted    { background: var(--ink-muted); }
.status-bar__pct {
  margin-top: 0.15rem;
  font-size: 0.7rem;
  color: var(--ink-muted);
}

/* ── Charts ──────────────────────────────────────────────────── */

.chart-wrap { position: relative; }
.chart-wrap--trend { height: 320px; }
.chart-wrap--donut { height: 220px; }

/* ── Donut grid + share takeaways ────────────────────────────── */

.donut-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) { .donut-grid { grid-template-columns: 1fr; } }
.donut-cell { text-align: center; }
.donut-cell__title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.share-takeaways {
  list-style: none;
  padding: 0.75rem 0 0 0;
  margin: 0;
  border-top: 1px dashed var(--surface-line);
}
.share-takeaways li {
  padding: 0.35rem 0;
  font-size: 0.85rem;
  color: var(--ink-charcoal);
}
.share-takeaways strong { color: var(--ink-noir); font-weight: 600; }

/* ── Campaign table ──────────────────────────────────────────── */

.table-scroll { overflow-x: auto; }
.table--sortable th[data-sort] {
  user-select: none;
  position: relative;
  padding-right: 1.2rem;
}
.table--sortable th[data-sort]::after {
  content: "↕";
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.3;
  font-size: 0.7rem;
}
.table--sortable th[data-sort-dir="asc"]::after {
  content: "↑";
  opacity: 1;
  color: var(--brand-gold-dark);
}
.table--sortable th[data-sort-dir="desc"]::after {
  content: "↓";
  opacity: 1;
  color: var(--brand-gold-dark);
}
.table tr.row--best   { box-shadow: inset 3px 0 0 var(--brand-gold); }
.table tr.row--worst  { box-shadow: inset 3px 0 0 var(--state-danger); }
.campaign-name-full {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 0.1rem;
}

/* ── Insight cards ───────────────────────────────────────────── */

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.insight-card {
  display: flex;
  gap: 0.85rem;
  background: var(--surface-card);
  border: 1px solid var(--surface-line);
  border-left: 3px solid var(--ink-muted);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.insight-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.insight-card--success { border-left-color: var(--state-success); }
.insight-card--warning { border-left-color: var(--state-warning); }
.insight-card--danger  { border-left-color: var(--state-danger); }
.insight-card--info    { border-left-color: var(--state-info); }
.insight-card--muted   { border-left-color: var(--ink-muted); }

.insight-card__icon {
  flex: 0 0 auto;
  color: var(--brand-gold-dark);
  padding-top: 0.1rem;
}
.insight-card--success .insight-card__icon { color: var(--state-success); }
.insight-card--warning .insight-card__icon { color: var(--state-warning); }
.insight-card--danger  .insight-card__icon { color: var(--state-danger); }
.insight-card--info    .insight-card__icon { color: var(--state-info); }

.insight-card__body { flex: 1 1 auto; min-width: 0; }
.insight-card__headline {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-noir);
  margin: 0 0 0.3rem 0;
}
.insight-card__copy {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink-charcoal);
  margin: 0;
}

/* ════════════════════════════════════════════════════════════════
   MOBILE BREAKPOINTS
   ════════════════════════════════════════════════════════════════ */

/* Tablet & below — sidebar collapses to a slide-in drawer, hamburger
   appears in the topbar, user controls migrate to the sidebar bottom. */
@media (max-width: 1023px) {
  /* Layout: drop the sidebar grid column; main content takes full width. */
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }

  /* Sidebar becomes a fixed off-screen drawer */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;       /* top: 0; bottom: 0; left: 0 */
    width: var(--sidebar-width);
    max-width: 86vw;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar__close { display: inline-flex; }
  .topbar__hamburger { display: inline-flex; }

  /* Topbar: title takes most space, hide desktop user-info widget */
  .topbar { padding: 0 0.85rem; gap: 0.5rem; }
  .topbar__title {
    flex: 1 1 0;
    min-width: 0;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar__user { display: none; }     /* moved into sidebar on mobile */

  /* Sidebar user footer is now visible on mobile */
  .sidebar__user { display: block; }

  /* Main content padding tighter */
  .main { padding: 1rem; }
}

/* Phones — extra layout fixes */
@media (max-width: 700px) {
  /* Donut trio: ensure cells can shrink so canvases don't overflow */
  .donut-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .donut-cell { min-width: 0; }

  /* Funnel: stage names get tight on phones — slightly smaller hero text */
  .funnel-svg__count { font-size: 15px; }
  .funnel-svg__pct   { font-size: 9px; }
  .funnel-svg__total { font-size: 8px; }

  /* Hero band already collapses to 2-up at 768px and 1-up at 480px */

  /* Cards: a bit less padding */
  .card { padding: 1rem; }

  /* Filter row: pills wrap, live mode stacks */
  .dash-filter-row { gap: 0.5rem; }
  .dash-pills { flex-wrap: wrap; }

  /* Hero text scales down */
  .dash-hero__title { font-size: 2rem; }
  .dash-hero__subhead { font-size: 0.95rem; }

  /* Table: allow horizontal scroll inside its scroll wrap */
  .campaign-name-full { display: none; }   /* save vertical room */
}

/* Chart canvases must never overflow their wrap (defensive fallback) */
.chart-wrap { position: relative; width: 100%; min-width: 0; }
.chart-wrap canvas { max-width: 100% !important; }


/* ── Reduced motion ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Login screen ──────────────────────────────────────────── */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(216, 192, 96, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(27, 42, 78, 0.08) 0%, transparent 60%),
    var(--surface-ivory);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  border-top: 4px solid transparent;
  border-image: var(--brand-gradient) 1;
}

.login-card__logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-card__logo img {
  max-width: 220px;
  height: auto;
}
.login-card__subtitle {
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  margin-bottom: 1.5rem;
}
.login-card .btn { width: 100%; }

/* ────────────────────────────────────────────────────────────────
   ETL Admin pages (Session 7)
   /etl-dashboard, /etl-jobs, /run-logs
   ──────────────────────────────────────────────────────────────── */

.etl-job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.etl-job-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

.etl-job-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.etl-job-card__table {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.etl-job-card__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 1rem;
  font-size: 0.82rem;
  color: var(--ink-charcoal);
}

.etl-job-card__meta--empty {
  display: block;
  color: var(--ink-muted);
  font-style: italic;
}

.etl-job-card__label {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.1rem;
}

.etl-job-card__controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.25rem;
}

.etl-job-card__controls .form-select {
  margin: 0;
}

.etl-job-card__backfill {
  border-top: 1px dashed var(--surface-line);
  padding-top: 0.6rem;
}

.etl-run-btn {
  white-space: nowrap;
}
.etl-run-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Confirmation modal */
.etl-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.etl-modal[hidden] { display: none; }
.etl-modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, 0.6);
  backdrop-filter: blur(2px);
}
.etl-modal__panel {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--surface-line);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  max-width: 460px;
  width: calc(100% - 2rem);
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.etl-modal__panel h3 {
  margin: 0 0 0.5rem 0;
  font-family: 'Playfair Display', serif;
}
.etl-modal__panel p {
  color: var(--ink-muted);
  margin: 0;
}

/* KPI row reuse (dashboard already defines .kpi-card; just add the row container if missing) */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

/* ────────────────────────────────────────────────────────────────
   Sales Dashboard: campaign multi-select filter
   ──────────────────────────────────────────────────────────────── */

.campaign-filter {
  position: relative;
  margin-left: auto;
}
.campaign-filter__summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: var(--surface-card);
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-charcoal);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.campaign-filter__summary::-webkit-details-marker { display: none; }
.campaign-filter__summary:hover { border-color: var(--brand-gold); }
.campaign-filter[open] .campaign-filter__summary {
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-gold) 18%, transparent);
}
.campaign-filter__label {
  color: var(--ink-muted);
  font-weight: 400;
}
.campaign-filter__value {
  font-weight: 600;
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.campaign-filter__more {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 0.4rem;
  border-radius: 11px;
  background: var(--brand-gold-light);
  color: var(--brand-gold-dark);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Custom date range form — only shown when "Date Range" pill is active */
.dash-custom-range {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0 1rem;
  background: var(--surface-card);
  border: 1px solid var(--surface-line);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.dash-custom-range__caption {
  color: var(--ink-muted);
  font-size: 0.82rem;
  margin-right: auto;
}
.dash-custom-range__caption strong {
  color: var(--ink-charcoal);
  font-weight: 600;
}
.dash-custom-range__field {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.dash-custom-range__field input[type="date"] {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--surface-line);
  border-radius: 6px;
  background: var(--surface-card);
  color: var(--ink-charcoal);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.dash-custom-range__field input[type="date"]:focus-visible {
  outline: none;
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-gold) 18%, transparent);
}
@media (max-width: 640px) {
  .dash-custom-range { gap: 0.5rem; }
  .dash-custom-range__caption { flex-basis: 100%; margin-right: 0; }
  .dash-custom-range__field { flex: 1 1 calc(50% - 0.25rem); }
  .dash-custom-range__field input[type="date"] { width: 100%; }
}

.campaign-filter__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 50;
  width: min(360px, calc(100vw - 2rem));
  background: var(--surface-card);
  border: 1px solid var(--surface-line);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.15);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.campaign-filter__head {
  display: flex;
  gap: 0.4rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--surface-line);
}
.campaign-filter__list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  max-height: 280px;
  overflow-y: auto;
  margin: 0 -0.25rem;
}
.campaign-filter__row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ink-charcoal);
  transition: background-color 100ms ease;
}
.campaign-filter__row:hover { background: var(--surface-ivory); }
.campaign-filter__row input[type="checkbox"] {
  accent-color: var(--brand-gold);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.campaign-filter__row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.campaign-filter__actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--surface-line);
}

@media (max-width: 640px) {
  .campaign-filter { margin-left: 0; margin-top: 0.5rem; width: 100%; }
  .campaign-filter__summary { width: 100%; justify-content: space-between; }
  .campaign-filter__panel { right: auto; left: 0; width: 100%; }
}

/* ── "Include Today" checkbox (dashboard toolbar) ──────────────────── */
.dash-include-today {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-charcoal);
  background: var(--surface-card);
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
  user-select: none;
}
.dash-include-today:hover { border-color: var(--brand-gold); }
.dash-include-today input[type="checkbox"] {
  accent-color: var(--brand-gold);
  margin: 0;
  cursor: inherit;
}
.dash-include-today.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  border-color: var(--surface-line);
}
.dash-include-today.is-disabled:hover { border-color: var(--surface-line); }
.dash-include-today.is-disabled input[type="checkbox"] { cursor: not-allowed; }

@media (max-width: 640px) {
  .dash-include-today { margin-left: 0; margin-top: 0.5rem; }
}

/* ── Sales-team table: expand/collapse sub-rows ────────────────────── */
.card__header--toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.dash-bulk-toggle {
  display: inline-flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.table--agents .th-toggle { width: 32px; padding-right: 0; }
.table--agents tr.agent-row { cursor: pointer; }
.table--agents tr.agent-row.agent-row--no-children { cursor: default; }
.table--agents tr.agent-row.is-open {
  background: color-mix(in srgb, var(--brand-gold) 6%, var(--surface-card));
}
.agent-row__toggle {
  width: 32px;
  padding-right: 0;
  text-align: center;
}
.agent-row__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: transform 180ms ease, color 160ms ease, background 160ms ease;
}
.agent-row__chevron:hover { color: var(--brand-gold); background: rgba(0,0,0,0.04); }
.agent-row__chevron.is-open { transform: rotate(90deg); color: var(--brand-gold); }

.agent-sub-row { background: var(--surface-ivory); }
.agent-sub-row.is-hidden { display: none; }
.agent-sub-row__cell {
  padding: 0 !important;          /* let the inner table own the padding */
  border-bottom: 1px solid var(--surface-line);
}
.agent-sub-row__inner {
  padding: 0.75rem 1rem 0.85rem 3.25rem;   /* indent under the agent name */
  background: linear-gradient(180deg,
                              rgba(171, 129, 33, 0.04) 0%,
                              rgba(171, 129, 33, 0.00) 100%);
}
.agent-sub-row__inner .table--inner {
  width: 100%;
  font-size: 0.8rem;
  margin: 0;
}
.agent-sub-row__inner .table--inner th {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  background: transparent;
  border-bottom: 1px solid var(--surface-line);
}
.agent-sub-row__inner .table--inner td {
  padding: 0.35rem 0.6rem;
  color: var(--ink-charcoal);
}
.agent-sub-row__inner .table--inner tr:last-child td { border-bottom: 0; }

@media (max-width: 640px) {
  .card__header--toolbar { flex-direction: column; align-items: stretch; }
  .dash-bulk-toggle { justify-content: flex-end; }
  .agent-sub-row__inner { padding-left: 1rem; }
}
