/* ============================================================
   FLARE — public anonymised demo
   Tokens mirror GIT_PROJECTS/DASHBOARDS/dashboard_theme/tokens.py
   Visual language mirrors the real FLARE Streamlit app:
   - Inter type, heavy headings
   - Big-radius cards, pill buttons
   - Scorecard-style coloured KPI tiles
   - Grouped collapsible left sidebar
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,300..700,0..1,-25..200&display=swap');

:root {
  /* Ground */
  --void:         #061C2A;
  --bg:           #0A2535;
  --surface:      #133142;
  --surface-alt:  #1C3D50;

  /* Hairlines */
  --rule:         rgba(232, 236, 242, 0.08);
  --rule-strong:  rgba(232, 236, 242, 0.18);

  /* Text */
  --white:        #FFFFFF;
  --instrument:   #E8ECF2;
  --read:         #B8C0D0;
  --mute:         #8792A6;
  --dim:          #5B657A;

  /* International Orange */
  --accent:       #FF4F00;
  --accent-hot:   #FF7A2E;
  --accent-deep:  #C93A00;
  --accent-dim:   rgba(255, 79, 0, 0.12);

  /* Status — strong saturated; used as card backgrounds with white text */
  --positive:     #16a34a;
  --warning:      #eab308;
  --critical:     #d4001a;
  --neutral:      #8792A6;

  /* Type */
  --f-sans:  'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-mono:  ui-monospace, "SF Mono", Menlo, "Cascadia Code", monospace;

  /* Layout */
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 60px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--instrument);
  font-family: var(--f-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Apple HIG-leaning heading hierarchy — matches dashboard_theme/template.py */
h1, h2, h3, h4, h5, h6 { font-family: var(--f-sans); margin: 0; color: var(--instrument); }
h1 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
h2 { font-weight: 800; letter-spacing: -0.015em; line-height: 1.15; }
h3 { font-weight: 700; letter-spacing: -0.005em; line-height: 1.25; }
p { color: var(--instrument); }

/* Numeric data — tabular figures so columns/metrics align cleanly */
[data-num], table, code, pre, .metric-value, .kpi-card h1, .kpi-card p { font-variant-numeric: tabular-nums; }

/* Selection + focus rings — orange */
::selection { background: rgba(255, 79, 0, 0.30); color: #fff; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
  box-shadow: none !important;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hot); }

/* Material Symbols Rounded — used everywhere FLARE uses them */
.ms {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}
.ms.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.ms-sm { font-size: 16px; }
.ms-lg { font-size: 28px; }

/* ============================================================
   PILL BUTTONS — the FLARE pattern
   ============================================================ */
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 18px;
  height: 44px;
  border-radius: 9999px;
  border: 3px solid rgba(232,236,242,0.18);
  background: var(--surface);
  color: var(--read);
  font-family: var(--f-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
  text-decoration: none;
}
.pill-btn:hover {
  background: var(--surface-alt);
  border-color: var(--instrument);
  color: var(--instrument);
}
.pill-btn.primary {
  background: var(--accent);
  border-color: var(--white);
  color: var(--white);
  font-weight: 700;
}
.pill-btn.primary:hover { background: var(--accent-hot); color: var(--white); }

/* ============================================================
   FLARE WORDMARK
   ============================================================ */
.flare-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--f-sans);
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 1rem;
  color: var(--instrument);
  text-decoration: none;
}
.flare-wordmark .glyph { width: 32px; height: 28px; flex: 0 0 auto; }

/* ============================================================
   LANDING PAGE (/flare/)
   ============================================================ */
.landing {
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(255,79,0,0.10), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(43,141,255,0.06), transparent 55%),
    var(--bg);
}
.landing-inner { max-width: 960px; margin: 0 auto; padding: 4.5rem 2rem 6rem; }
.landing header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4rem;
}
.landing h1 {
  font-size: 3rem;
  line-height: 1.1;
  margin: 0 0 1.25rem;
  color: var(--instrument);
}
.landing h1 .accent { color: var(--accent); }
.landing .lede {
  color: var(--read);
  font-size: 1.15rem;
  max-width: 60ch;
  margin-bottom: 2.5rem;
  font-weight: 400;
}
.landing .eyebrow {
  font-family: var(--f-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--mute);
}
.landing .cta-row { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 4rem; flex-wrap: wrap; }
.landing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 3rem;
}
.landing-grid .cell {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 1.5rem 1.4rem;
}
.landing-grid .cell .ms-lg { color: var(--accent); margin-bottom: 0.8rem; display: block; }
.landing-grid .cell h3 { font-size: 1.05rem; margin-bottom: 0.5rem; color: var(--instrument); }
.landing-grid .cell p { font-size: 0.92rem; color: var(--read); margin: 0; line-height: 1.55; }

.behind {
  padding: 1.5rem 1.7rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 12px;
  font-size: 0.95rem;
  color: var(--read);
  margin-bottom: 3rem;
  line-height: 1.6;
}
.behind strong { color: var(--instrument); font-weight: 600; }
.landing footer {
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  color: var(--dim);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
}

/* ============================================================
   LOGIN PAGE — Microsoft Entra mock
   ============================================================ */
.login-bg {
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at 50% 0%, rgba(255,79,0,0.10), transparent 60%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 16px;
  padding: 2.5rem 2.25rem;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}
.login-card .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; }
.login-card .demo-chip {
  font-family: var(--f-sans); font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--accent);
  border: 2px solid var(--accent);
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
}
.login-card h2 { font-size: 1.5rem; margin: 0 0 0.45rem; color: var(--instrument); }
.login-card .sub { color: var(--mute); font-size: 0.9rem; margin-bottom: 1.75rem; }
.login-card label {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--mute); display: block; margin-bottom: 0.4rem;
}
.login-card input[type="email"] {
  width: 100%;
  padding: 0.75rem 0.85rem;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--instrument);
  border: 1px solid var(--rule-strong);
  font-family: var(--f-sans);
}
.ms-button {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 0.7rem;
  padding: 0.85rem;
  background: var(--white);
  color: #1f1f1f;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: "Segoe UI", var(--f-sans);
  margin-bottom: 0.7rem;
}
.ms-button:hover { background: #f3f3f3; }
.ms-logo {
  width: 20px; height: 20px; display: inline-block;
  background:
    linear-gradient(to bottom right, #f25022 50%, transparent 50%) top left / 50% 50% no-repeat,
    linear-gradient(to bottom left, #7fba00 50%, transparent 50%) top right / 50% 50% no-repeat,
    linear-gradient(to top right, #00a4ef 50%, transparent 50%) bottom left / 50% 50% no-repeat,
    linear-gradient(to top left, #ffb900 50%, transparent 50%) bottom right / 50% 50% no-repeat;
}
.login-card .alt-sso { text-align: center; font-size: 0.85rem; color: var(--mute); margin: 0.9rem 0; }
.login-card .disclaimer {
  margin-top: 1.75rem; font-size: 0.8rem; color: var(--dim); text-align: center; line-height: 1.6;
}
.login-card .disclaimer a { color: var(--mute); border-bottom: 1px dotted var(--mute); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
  transition: grid-template-columns 0.2s ease;
}
.app-shell.collapsed { grid-template-columns: var(--sidebar-collapsed-w) 1fr; }

/* ---- Top bar ---- */
.topbar {
  grid-area: topbar;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.25rem;
}
.topbar .crumbs {
  font-size: 0.85rem;
  color: var(--mute);
  font-weight: 500;
}
.topbar .crumbs .sep { color: var(--dim); margin: 0 0.45rem; }
.topbar .crumbs .current { color: var(--instrument); font-weight: 600; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 0.85rem; }

/* Business switcher */
.business-switcher {
  position: relative;
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.45rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 9999px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--instrument);
  transition: all 0.12s;
}
.business-switcher:hover { background: var(--surface-alt); border-color: var(--rule-strong); }
.business-switcher .swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.business-switcher .ms-sm { color: var(--mute); }
.switcher-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  min-width: 220px;
  padding: 0.4rem;
  z-index: 50;
  display: none;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}
.switcher-menu.open { display: block; }
.switcher-menu .item {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--read);
}
.switcher-menu .item:hover { background: var(--surface-alt); color: var(--instrument); }
.switcher-menu .item.active { color: var(--accent); font-weight: 600; }
.switcher-menu .item .swatch { width: 9px; height: 9px; border-radius: 50%; }

/* User badge */
.user-badge {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.35rem 0.7rem 0.35rem 0.35rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 9999px;
  font-size: 0.83rem;
  color: var(--read);
}
.user-badge .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 0.72rem; font-weight: 700;
}

/* ---- Sidebar ---- */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex; flex-direction: column;
}
.sidebar .sb-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}
.sidebar .sb-toggle {
  background: transparent; border: none; color: var(--instrument);
  cursor: pointer; padding: 6px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.sidebar .sb-toggle:hover { color: var(--accent); background: var(--surface-alt); }
.sidebar .sb-body { flex: 1; padding: 1rem 0; }
/* When collapsed: hide the wordmark entirely (image + text), only show the toggle */
.app-shell.collapsed .sidebar .sb-header { padding: 0; justify-content: center; }
.app-shell.collapsed .sidebar .sb-header .flare-wordmark { display: none; }

.nav-group { margin-bottom: 0.5rem; }
.nav-group .group-label {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 1.1rem 0.45rem 1.1rem;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--mute);
}
.nav-group .group-label .ms-sm { color: var(--mute); }
.app-shell.collapsed .group-label .label-text { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 1.1rem;
  color: var(--read);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  text-decoration: none;
  transition: all 0.1s;
}
.nav-item:hover { background: var(--surface-alt); color: var(--instrument); }
.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}
.nav-item.locked { color: var(--dim); cursor: not-allowed; }
.nav-item.locked:hover { background: transparent; color: var(--dim); }
.nav-item .ms-sm { color: inherit; opacity: 0.85; flex: 0 0 auto; }
.app-shell.collapsed .nav-item { justify-content: center; padding: 0.55rem 0; }
.app-shell.collapsed .nav-item .item-label { display: none; }

.sidebar .sb-foot {
  padding: 0.85rem 1.1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.72rem;
  color: var(--dim);
  line-height: 1.6;
}
.sidebar .sb-foot .accent { color: var(--accent); font-weight: 700; letter-spacing: 0.12em; }
.app-shell.collapsed .sb-foot { display: none; }

/* ---- Main area ---- */
.main {
  grid-area: main;
  overflow-y: auto;
  padding: 5rem 5rem 6rem;
  background: var(--bg);
}
.main-inner { max-width: 1300px; margin: 0 auto; }
.main h1.page-title { font-size: 3.4rem; margin-bottom: 0.45rem; color: var(--white); }
.main .page-subtitle { color: var(--read); font-size: 1rem; margin-bottom: 0.5rem; }
.main .data-as-of { color: var(--mute); font-size: 0.88rem; margin-bottom: 2.5rem; }
.divider { border: none; border-top: 1px solid var(--rule); margin: 2.25rem 0; }
@media (max-width: 1100px) { .main { padding: 3rem 2rem 4rem; } .main h1.page-title { font-size: 2.4rem; } }

/* ============================================================
   "WELCOME TO FLARE" HOME PAGE
   ============================================================ */
.home-intro { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; margin-bottom: 2rem; }
.home-block .home-icon {
  font-size: 2.5rem; color: var(--accent); margin-bottom: 0.6rem;
}
.home-block h2 { font-size: 1.6rem; margin-bottom: 0.3rem; }
.home-block .home-caption {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--mute); margin-bottom: 0.85rem;
}
.home-block p { color: var(--read); font-size: 0.95rem; line-height: 1.65; }

.dir-section { margin-top: 1rem; }
.dir-section h2 {
  font-size: 0.95rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--mute); margin-bottom: 1.25rem;
}
.dir-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem 4rem; }
.dir-group { padding-bottom: 0.5rem; }
.dir-group .dir-group-head {
  display: flex; align-items: center; gap: 0.55rem;
  margin-bottom: 1rem;
  color: var(--instrument);
}
.dir-item {
  display: block;
  padding: 0.7rem 0 0.85rem;
  border-top: 1px solid var(--rule);
  text-decoration: none;
}
.dir-item:hover .dir-item-name { color: var(--accent); }
.dir-item-name { font-weight: 700; font-size: 1.05rem; color: var(--white); margin-bottom: 0.25rem; }
.dir-item-desc { font-size: 0.88rem; color: var(--read); line-height: 1.55; }

/* ============================================================
   PLAIN ST.METRIC-STYLE TILE
   Small label + value + delta, white text on dark surface.
   This is the default used on most FLARE dashboards.
   ============================================================ */
.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; margin-bottom: 2rem; }
.metric { background: transparent; padding: 0; }
.metric .label {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--white);
  margin-bottom: 0.35rem;
}
.metric .value {
  font-size: 2.8rem;
  font-weight: 400;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.metric .delta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.6rem;
  padding: 0.2rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.metric .delta.positive { background: rgba(22,163,74,0.22); color: #4ade80; }
.metric .delta.negative { background: rgba(212,0,26,0.22); color: #ff6b7e; }
.metric .delta.neutral  { background: transparent; color: var(--mute); padding-left: 0; padding-right: 0; }

/* ============================================================
   ICONIC SCORECARD KPI CARDS — coloured backgrounds, white text
   ONLY used on the Executive Scorecard (and L10 scorecards in real FLARE)
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-bottom: 1.5rem; }
.kpi-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-card {
  border-radius: 12px;
  padding: 28px 24px;
  text-align: center;
  color: var(--white) !important;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid rgba(232,236,242,0.08);
  font-family: var(--f-sans);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(0,0,0,0.4); filter: brightness(106%); }
.kpi-card h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--white);
  opacity: 0.95;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.kpi-card h1 {
  margin: 0;
  font-size: 3rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.03em;
  line-height: 1;
}
.kpi-card p {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--white);
  opacity: 0.95;
  line-height: 1.45;
}
.kpi-card .detail { font-size: 0.95rem; opacity: 0.95; font-weight: 700; margin-top: 4px; color: var(--white); }
.kpi-card.positive { background: var(--positive); }
.kpi-card.warning  { background: #c79606; }
.kpi-card.critical { background: var(--critical); }
.kpi-card.neutral  { background: #4a5a6e; border-color: var(--rule-strong); }
.kpi-card.accent   { background: var(--accent); }

/* ============================================================
   SECTION + GENERIC CARD
   ============================================================ */
.section { margin-bottom: 1.75rem; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 0.85rem;
}
.section-head h2 { font-size: 1.05rem; font-weight: 700; color: var(--instrument); }
.section-head .meta { color: var(--mute); font-size: 0.85rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 1.5rem 1.6rem;
}
.card-tight { padding: 1rem 1.2rem; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 1.5rem 1.6rem;
}
.chart-card canvas { width: 100% !important; height: 260px !important; }
.chart-card.tall canvas { height: 360px !important; }

/* ============================================================
   TABLES
   ============================================================ */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.tbl thead th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--white);
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--rule);
  cursor: pointer;
  user-select: none;
  background: var(--surface);
  vertical-align: middle;
}
.tbl-flare thead th { border: 1px solid var(--rule-strong); background: var(--surface); }
.tbl-flare td { border: 1px solid var(--rule); padding: 0.7rem 0.95rem; color: var(--instrument); }
.tbl-flare td.cat-sep {
  color: #3DB6FF;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.08em;
  background: rgba(43,141,255,0.06);
  border: 1px solid var(--rule);
  padding: 0.65rem 0.95rem;
}
.tbl thead th .sort-ind { color: var(--accent); margin-left: 0.3rem; }
.tbl tbody td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--rule);
  color: var(--read);
}
.tbl tbody tr { cursor: pointer; transition: background 0.1s; }
.tbl tbody tr:hover { background: var(--surface-alt); }
.tbl tbody tr.selected { background: var(--accent-dim); }
.tbl .mono { font-family: var(--f-mono); color: var(--mute); font-size: 0.8rem; font-weight: 500; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .pos { color: var(--positive); font-weight: 600; }
.tbl .neg { color: var(--critical); font-weight: 600; }

.pill {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pill.positive { background: rgba(22,163,74,0.18); color: var(--positive); }
.pill.warning  { background: rgba(234,179,8,0.18); color: #f5cb3c; }
.pill.critical { background: rgba(212,0,26,0.18); color: #ff5a6e; }

/* ============================================================
   FILTER BAR + CHIPS
   ============================================================ */
/* Streamlit-style filter row — labels above full-width fields */
.filter-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.filter-row.cols-2 { grid-template-columns: 1fr 1fr; }
.filter-row.cols-1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; }
.field-label {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--white);
  margin-bottom: 0.4rem;
}
.st-select {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.7rem 2.4rem 0.7rem 0.95rem;
  color: var(--instrument);
  font-family: var(--f-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
}
.st-select::after {
  content: "▾"; position: absolute; right: 0.85rem; top: 50%; transform: translateY(-50%);
  color: var(--mute); font-size: 0.8rem; pointer-events: none;
}
select.st-select { appearance: none; -webkit-appearance: none; background-image: none; }
.st-select:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-multi {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
  position: relative;
}
.st-multi::after {
  content: "▾"; position: absolute; right: 0.85rem; top: 50%; transform: translateY(-50%);
  color: var(--mute); font-size: 0.8rem;
}
.st-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--accent);
  color: var(--white);
  padding: 0.18rem 0.45rem 0.18rem 0.65rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
}
.st-chip .x { opacity: 0.85; cursor: pointer; font-size: 0.95rem; line-height: 1; }

.search-input {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.7rem 0.95rem;
  color: var(--instrument);
  font-family: var(--f-sans);
  font-size: 0.95rem;
  width: 100%;
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Pill radio buttons — the FLARE signature for binary/few-option filters */
.pill-radio { display: flex; flex-wrap: wrap; gap: 0.65rem; }
.pill-radio .pill-opt {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 130px; height: 46px;
  padding: 0 18px;
  border-radius: 9999px;
  background: var(--surface);
  border: 3px solid rgba(232,236,242,0.18);
  color: var(--read);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  font-family: var(--f-sans);
  text-align: center;
}
.pill-radio .pill-opt:hover { background: var(--surface-alt); border-color: var(--instrument); color: var(--instrument); }
.pill-radio .pill-opt.active {
  background: var(--accent);
  color: var(--white);
  border: 3px solid var(--white);
  font-weight: 700;
  transform: translateY(-1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

/* Inline filter row — labels alongside pill radios (Customer Dashboard style) */
.filter-inline { display: flex; align-items: center; flex-wrap: wrap; gap: 0.85rem; margin-bottom: 1rem; }
.inline-label { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--mute); }

/* Smaller pill option used in inline rows */
.pill-radio .pill-opt.pill-sm { min-width: 80px; height: 40px; font-size: 0.9rem; padding: 0 16px; border-width: 2px; }
.pill-radio .pill-opt.pill-sm.active { border-width: 2px; }

/* View-picker grid — large outlined pills with icons (Customer Dashboard's "Choose a detailed view") */
.view-grid {
  display: grid !important;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.85rem;
}
.view-grid .pill-view {
  min-width: 0;
  width: 100%;
  border-radius: 10px;
  height: auto;
  min-height: 60px;
  padding: 0.8rem 1rem;
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 0.5rem;
  border-width: 2px;
  font-size: 0.9rem;
  text-align: center;
  white-space: normal;
  line-height: 1.25;
}
.view-grid .pill-view .ms-sm { font-size: 18px; }

/* Inline checkbox */
.checkbox-inline {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem; color: var(--read); cursor: pointer; font-weight: 500;
}
.checkbox-inline input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Customer-dashboard summary table — accent column headers */
.tbl-customer .accent-h { color: var(--accent); }
.tbl-customer .yoy { font-size: 0.78rem; font-weight: 500; margin-top: 0.15rem; }
.tbl-customer .yoy.pos { color: var(--positive); }
.tbl-customer .yoy.neg { color: var(--critical); }

/* ============================================================
   ASK FLARE — chat surface
   ============================================================ */
.ask-window {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.ask-msg { display: flex; align-items: flex-start; gap: 0.85rem; }
.ask-msg.user { justify-content: flex-end; }
.ask-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  color: var(--white);
}
.ask-bubble {
  padding: 0.95rem 1.2rem;
  border-radius: 14px;
  max-width: 80%;
  line-height: 1.6;
  font-size: 0.95rem;
}
.user-bubble {
  background: var(--accent);
  color: var(--white);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.assistant-bubble {
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--instrument);
  border-bottom-left-radius: 4px;
}
.ask-sources {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--rule);
}
.ask-source {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-family: var(--f-mono);
  font-size: 0.74rem;
  color: var(--mute);
  background: var(--surface-alt);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}
.ask-source .ms-sm { font-size: 14px; color: var(--accent); }

.ask-suggestions {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin-top: 0.5rem;
}
.suggestions-label {
  font-family: var(--f-sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 0.7rem;
}
.ask-suggestions .chip {
  font-size: 0.85rem;
  font-weight: 500;
  margin: 0.25rem 0.4rem 0.25rem 0;
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  border: 1px solid var(--rule-strong);
  background: var(--surface-alt);
  color: var(--read);
  cursor: pointer;
  font-family: var(--f-sans);
  text-align: left;
}
.ask-suggestions .chip:hover { color: var(--accent); border-color: var(--accent); }

.ask-input-row {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  padding: 0.6rem 0.7rem 0.6rem 1rem;
  margin-top: 1rem;
}
.ask-input-row:focus-within { border-color: var(--accent); }
.ask-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--instrument);
  font-family: var(--f-sans);
  font-size: 1rem;
  padding: 0.55rem 0;
}
.ask-input::placeholder { color: var(--mute); }
.ask-send { padding: 0 1.1rem; height: 40px; }
.ask-foot { font-size: 0.78rem; color: var(--dim); margin-top: 0.7rem; text-align: center; }

/* Expander — Streamlit's collapsed-by-default section */
.expander {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
}
.expander-head {
  padding: 0.85rem 1.1rem;
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--instrument);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.expander-head .ms { color: var(--mute); }

/* Default raw select still themed (used in some places) */
select {
  background: var(--surface);
  color: var(--instrument);
  border: 1px solid var(--rule);
  padding: 0.7rem 0.95rem;
  border-radius: 8px;
  font-family: var(--f-sans);
  font-size: 0.95rem;
  font-weight: 500;
}

/* ============================================================
   DRILLDOWN PANEL
   ============================================================ */
.dd-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1rem; align-items: start; }
.dd-panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 1.4rem 1.5rem;
}
.dd-panel .label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--mute);
  margin-bottom: 0.35rem;
}
.dd-panel h3 { font-size: 1.2rem; margin: 0 0 0.25rem; color: var(--instrument); }
.dd-panel .meta { color: var(--mute); font-size: 0.85rem; margin-bottom: 1rem; }
.dd-panel .stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin: 1rem 0; }
.dd-panel .stat {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
}
.dd-panel .stat .l {
  font-size: 0.66rem; color: var(--mute); letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700;
}
.dd-panel .stat .v { font-size: 1.1rem; color: var(--instrument); margin-top: 0.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.dd-panel .empty {
  color: var(--mute); font-size: 0.95rem; text-align: center; padding: 2rem 1rem; font-style: italic;
}
.dd-panel .activity { margin-top: 0.8rem; }
.dd-panel .activity-row {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--rule);
}
.dd-panel .activity-row:last-child { border-bottom: none; }
.dd-panel .activity-row .when { color: var(--dim); font-family: var(--f-mono); font-size: 0.78rem; }
.dd-panel .activity-row .what { color: var(--read); }

/* ============================================================
   WAREHOUSE HEATMAP
   ============================================================ */
.warehouse-wrap { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1rem; align-items: start; }
.warehouse-grid {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 1.5rem;
}
.warehouse-grid svg { width: 100%; height: auto; display: block; }
.warehouse-grid .legend {
  display: flex; align-items: center; gap: 0.6rem;
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--mute);
  font-weight: 500;
}
.warehouse-grid .legend-bar {
  height: 10px; flex: 1; border-radius: 5px;
  background: linear-gradient(to right, rgba(255,79,0,0.05), rgba(255,79,0,1));
}

/* ============================================================
   STATS / PRICING IMPACT DASHBOARD
   ============================================================ */
.stats-promo {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 1.1rem 1.4rem;
  border-radius: 14px;
  margin-bottom: 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
}
.stats-promo .l {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--mute);
}
.stats-promo select { min-width: 280px; }
.sig-flag {
  font-size: 0.75rem; font-weight: 700;
  padding: 0.3rem 0.85rem;
  border-radius: 9999px;
  letter-spacing: 0.08em;
}
.sig-flag.sig { background: var(--accent); color: var(--white); }
.sig-flag.nosig { background: var(--surface-alt); color: var(--mute); }
.stats-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* ============================================================
   BUNDLE / AFFINITY MATRIX
   ============================================================ */
.bundle-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1rem; align-items: start; }
.bundle-matrix {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 1.5rem;
}
.bundle-matrix svg { width: 100%; height: auto; display: block; }
.bundle-pairs {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 1.4rem 1.5rem;
}
.bundle-pairs .pair-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9rem;
}
.bundle-pairs .pair-row:last-child { border-bottom: none; }
.bundle-pairs .pair-row .skus { color: var(--read); font-family: var(--f-mono); font-size: 0.82rem; font-weight: 500; }
.bundle-pairs .pair-row .lift { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================================================
   TOOLTIP
   ============================================================ */
.flare-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--void);
  border: 1px solid var(--rule-strong);
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  font-family: var(--f-sans);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--instrument);
  z-index: 1000;
  white-space: nowrap;
  box-shadow: 0 12px 28px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.1s;
}
.flare-tooltip.visible { opacity: 1; }
.flare-tooltip .l { color: var(--mute); margin-right: 0.5rem; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }

/* ============================================================
   RESPONSIVE — desktop-first
   ============================================================ */
@media (max-width: 1200px) {
  .view-grid { grid-template-columns: repeat(3, 1fr); }
  .filter-row { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 4rem 3rem 5rem; }
}
@media (max-width: 1000px) {
  .kpi-grid, .kpi-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .metric-row { grid-template-columns: repeat(2, 1fr); }
  .two-col, .dd-layout, .warehouse-wrap, .bundle-layout, .stats-cmp, .home-intro, .dir-grid { grid-template-columns: 1fr; }
  .landing-grid { grid-template-columns: 1fr 1fr; }
  .main h1.page-title { font-size: 2.6rem; }
  .app-shell { grid-template-columns: var(--sidebar-collapsed-w) 1fr; }
  .app-shell .sidebar .sb-header { padding: 0; justify-content: center; }
  .app-shell .sidebar .sb-header .flare-wordmark { display: none; }
  .app-shell .nav-item { justify-content: center; padding: 0.55rem 0; }
  .app-shell .nav-item .item-label { display: none; }
  .app-shell .group-label .label-text { display: none; }
  .app-shell .sb-foot { display: none; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 0 1fr; grid-template-areas: "topbar topbar" "main main"; }
  .sidebar { display: none; }
  .topbar { padding: 0 0.85rem; }
  .topbar .crumbs { font-size: 0.78rem; }
  .topbar .user-badge { display: none; }
  .business-switcher { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
  .landing-grid { grid-template-columns: 1fr; }
  .main { padding: 1.5rem 1.1rem 3rem; }
  .landing-inner { padding: 2.5rem 1.25rem 4rem; }
  .landing h1 { font-size: 2.1rem; }
  .main h1.page-title { font-size: 1.9rem; }
  .kpi-grid, .kpi-grid.cols-4 { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .metric .value { font-size: 2.1rem; }
  .filter-row, .filter-row.cols-2 { grid-template-columns: 1fr; }
  .view-grid { grid-template-columns: 1fr 1fr; }
  .pill-radio .pill-opt { min-width: 70px; height: 40px; font-size: 0.85rem; padding: 0 14px; }
  .kpi-card { min-height: 160px; padding: 18px 14px; }
  .kpi-card h1 { font-size: 2rem; }
  table.tbl, table.tbl-flare { font-size: 0.78rem; }
  .tbl thead th, .tbl tbody td, .tbl-flare td { padding: 0.5rem 0.55rem; }
}
