/* GGS Digital MRV Platform -- brand palette and component styles,
   matched to the reference dashboard designs (expert/GGS_81_*.html,
   expert/GGS_83_*.html) so the whole app -- not just the two reference
   pages -- shares one look. */
:root {
  --ink: #1A1D1A;
  --ink-soft: #565B54;
  --ink-softer: #8A8F86;
  --bg: #FFFFFF;
  --panel: #FFFFFF;
  --panel-alt: #FAF8F4;
  --border: #DAD5C9;
  --border-soft: #ECE8DF;

  --brand-dark: #1F3D2F;   /* header bar, table headers */
  --brand: #2E5A43;        /* primary green */
  --brand-line: #3F6552;
  --brand-soft: #DCEBE1;
  --accent: #B5703C;       /* bronze -- KPI card top border, focus ring */
  --accent-soft: #F3D9C4;

  --vc1: #31859C;
  --vc1-soft: #E6F2F5;
  --vc2: #B8860B;
  --vc2-soft: #F6E5D6;
  --compliance: #7030A0;
  --compliance-soft: #F2E9FA;

  --ok: #17502E;
  --ok-soft: #CFE6D7;
  --ok-soft-b: #DDE7E1;
  --warn: #7A4520;
  --warn-soft: #F6E5D6;
  --warn-soft-b: #F2EBCF;
  --warn-ink: #5E4B0E;
  --danger: #7A1F1F;
  --danger-soft: #F5DADA;
  --muted-soft: #ECEAE4;
  --muted-ink: #43473F;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(26, 29, 26, 0.05), 0 1px 8px rgba(26, 29, 26, 0.04);
}

* { box-sizing: border-box; }

/* Visually hidden but still reachable by screen readers -- for form
   labels/table captions whose text is redundant for sighted users (a
   placeholder or a column header already carries it) but which an
   accessible name still needs, since placeholders aren't reliably
   announced and aren't a substitute for a real label. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Keyboard-only "skip to content" -- hidden until it receives focus (the
   first Tab stop on every page), then pinned on top of the header so a
   keyboard/screen-reader user can jump straight past the sidebar/nav
   rather than tabbing through every nav link on every single page. */
.skip-link {
  position: absolute;
  left: 8px; top: -48px;
  z-index: 1000;
  background: var(--brand-dark);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 8px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: 'Archivo', Arial, sans-serif;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.4em 0;
  letter-spacing: -0.01em;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; font-weight: 600; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--brand-dark);
  color: var(--ok-soft-b);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.18s ease, padding 0.18s ease;
}
html.sidebar-collapsed .sidebar { width: 0; padding-left: 0; padding-right: 0; border: none; }
html.sidebar-collapsed .sidebar * { opacity: 0; }
.sidebar-backdrop { display: none; }

.brand { display: flex; align-items: center; padding: 6px 8px 20px; }
.brand a { display: flex; align-items: center; }
.brand img { height: 34px; width: auto; display: block; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { margin-top: 6px; }
.nav-group:first-child { margin-top: 0; }
.nav-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Archivo', Arial, sans-serif;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #8FAE9B;
  margin: 0;
  padding: 10px 10px;
  border-radius: 6px;
}
.nav-group-label:hover { color: #C7DBCE; background: rgba(255,255,255,0.05); }
.nav-group-chevron { transition: transform 0.15s ease; opacity: 0.8; flex-shrink: 0; }
.nav-group.open .nav-group-chevron { transform: rotate(180deg); }
/* CSS-grid accordion: animates to content's natural height with no JS
   measuring -- .nav-group-items is the 0fr/1fr track, its -inner child
   carries the overflow:hidden so content never leaks during the
   collapsed state or the transition. */
.nav-group-items {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s ease;
}
.nav-group.open .nav-group-items { grid-template-rows: 1fr; }
.nav-group-items-inner {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #DCEBE1;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.87rem;
  font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; }
.nav-link.small { font-size: 0.8rem; color: #B7CBBF; gap: 8px; }
.nav-icon { flex-shrink: 0; display: flex; opacity: 0.75; }
.nav-link:hover .nav-icon, .nav-link.active .nav-icon { opacity: 1; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 12px; margin-top: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: 'Archivo', sans-serif;
}
.user-name { font-size: 0.85rem; font-weight: 600; color: #fff; }
.user-role { font-size: 0.72rem; color: #A9C1B2; }
.logout-link { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 0.8rem; color: #A9C1B2; }
/* Without this, the generic `a:hover` rule below applies --brand-dark on
   hover -- the exact colour of this sidebar's own background, so the
   link's text turns invisible the instant a user hovers it to click. */
.logout-link:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }

.main { flex: 1; width: 100%; min-width: 0; }
.main-pad { padding: 24px 32px 60px; }

/* ---- One unified header, every page: sidebar toggle, brand, page title,
   Slack-style search, audience/status badges, user avatar. Fills the full
   width of .main (its parent) -- no separate hero bar underneath. ---- */
.app-header {
  width: 100%;
  min-height: 72px;
  background: var(--brand-dark);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
  box-sizing: border-box;
}
/* The sidebar's own .brand logo already carries the wordmark when the
   sidebar is expanded -- showing it again in the header is a redundant
   second logo on screen. It only earns its place once the sidebar (and
   its logo) is collapsed away. */
.app-header-logo-link { display: none; align-items: center; flex-shrink: 0; }
html.sidebar-collapsed .app-header-logo-link { display: flex; }
.app-header-logo { height: 36px; width: auto; display: block; }
.app-header-divider { width: 1px; height: 34px; background: var(--brand-line); flex-shrink: 0; }
.app-header-titles { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.app-header-titles .t { font-family: 'Archivo', Arial, sans-serif; font-weight: 700; font-size: 1.2rem; color: #E8E4DB; white-space: nowrap; }
.app-header-titles .s { font-size: 0.78rem; color: #BCCAC0; white-space: nowrap; }
.app-header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px; border: none;
  background: transparent; color: var(--ink-soft); cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: var(--panel-alt); color: var(--ink); }
.icon-btn-light { color: #DCEBE1; }
.icon-btn-light:hover { background: rgba(255,255,255,0.1); color: #fff; }

.topbar-search {
  flex: 1 1 260px; max-width: 440px;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 14px;
  height: 34px;
  color: var(--ink-softer);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.topbar-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181, 112, 60, 0.15); }
.topbar-search input {
  border: none; background: transparent; outline: none; font-family: 'Inter', sans-serif;
  font-size: 0.85rem; color: var(--ink); flex: 1; min-width: 0;
}
.topbar-search input::placeholder { color: var(--ink-softer); }
.user-avatar-sm { width: 28px; height: 28px; font-size: 0.78rem; }

.flash-stack { display: flex; flex-direction: column; gap: 8px; margin: 16px 32px 0; }
.flash { padding: 10px 14px; border-radius: 8px; font-size: 0.86rem; }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--brand-soft); color: var(--brand-dark); }

.page-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 8px; }
.page-subtitle { color: var(--ink-soft); font-size: 0.9rem; margin-top: -8px; margin-bottom: 18px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

/* ---- Dashboard chrome: matches expert/GGS_81 & GGS_83 header exactly ---- */
.pill-audience { padding: 6px 12px; border-radius: 4px; background: var(--brand); color: #E8E4DB; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.pill-status { padding: 6px 12px; border: 1px solid var(--accent); border-radius: 4px; color: var(--accent-soft); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; white-space: nowrap; }

.dash-filterbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 32px;
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.dash-filterbar label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 0.68rem; color: var(--ink-soft); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
.dash-filterbar select {
  font-family: 'Inter', Arial, sans-serif; font-size: 0.82rem; color: var(--ink);
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--panel);
  min-width: 140px; text-transform: none; letter-spacing: 0; font-weight: 400;
}

.dash-legend {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 32px;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
}
.dash-legend .lbl { font-size: 0.75rem; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.dash-legend .sep { width: 1px; height: 16px; background: var(--border); }
.origin-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.69rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.origin-mrv { background: var(--ok-soft); color: var(--brand-dark); }
.origin-synthetic { background: var(--warn-soft); color: var(--warn); }
.origin-new { background: var(--warn-soft-b); color: var(--warn-ink); }
.dq-pill { display: inline-block; width: 22px; text-align: center; padding: 2px 0; border-radius: 4px; font-size: 0.75rem; font-weight: 700; }
.dq-A { background: var(--ok-soft); color: var(--ok); }
.dq-B { background: var(--ok-soft-b); color: var(--brand); }
.dq-C { background: var(--warn-soft-b); color: var(--warn-ink); }
.dq-D { background: var(--warn-soft); color: var(--warn); }
.dq-E { background: var(--danger-soft); color: var(--danger); }

.dash-main { padding: 22px 32px 32px; display: flex; flex-direction: column; gap: 20px; }
.dash-eyebrow { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand); font-weight: 600; }

/* Two dashboard panels side by side (matches expert/84 & 85's own two-column
   panel pairs) -- stacks to one column once the sidebar leaves too little
   room, same breakpoint as every other dashboard grid in this app. */
.dash-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
/* Grid items default to min-width:auto, which lets a wide table inside
   grow the whole column (and the page) to fit it instead of the
   table's own .table-wrap{overflow-x:auto} scrolling in place. */
.dash-cols-2 > .panel { margin-bottom: 0; min-width: 0; }
@media (max-width: 900px) { .dash-cols-2 { grid-template-columns: 1fr; } }

/* "Express results" unit toggle (Carbon & LCA dashboard) */
.unit-toggle { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; width: fit-content; }
.unit-toggle button {
  background: var(--panel); border: none; border-right: 1px solid var(--border); cursor: pointer;
  padding: 8px 18px; font-family: 'Archivo', sans-serif; font-weight: 600; font-size: 0.82rem; color: var(--ink);
}
.unit-toggle button:last-child { border-right: none; }
.unit-toggle button.active { background: var(--brand-dark); color: #fff; }

/* Simple floating-bar waterfall chart, no chart library -- bars positioned
   by server-computed top/height percentages (see dashboards.py). */
/* Scrolls horizontally in its own box on a narrow screen rather than
   forcing the page wider -- same pattern as .table-wrap. */
.waterfall-wrap { overflow-x: auto; }
.waterfall { display: flex; align-items: flex-end; gap: 18px; height: 260px; padding: 0 8px; min-width: 480px; }
.waterfall-col { flex: 1; min-width: 64px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.waterfall-bar-track { position: relative; width: 100%; height: 100%; }
.waterfall-bar { position: absolute; left: 10%; width: 80%; border-radius: 2px 2px 0 0; }
.waterfall-bar.kind-start { background: var(--brand); }
.waterfall-bar.kind-delta { background: var(--ink-soft); opacity: 0.55; }
.waterfall-bar.kind-total { background: var(--accent); }
.waterfall-value { font-family: 'Archivo', sans-serif; font-weight: 700; font-size: 0.82rem; margin-bottom: 4px; }
.waterfall-label { font-size: 0.68rem; color: var(--ink-soft); text-align: center; margin-top: 8px; line-height: 1.3; }
.waterfall-method { font-size: 0.64rem; color: var(--ink-soft); text-align: center; }

.dash-footer { padding: 16px 32px 28px; font-size: 0.75rem; color: var(--ink-soft); border-top: 1px solid var(--border); background: var(--bg); }

/* Executive overview: per-chain flow lane (forest -> final market) +
   per-project ring gauges. Each chain gets its own row -- unlike a real
   lat/long map, VC1 and VC2 never visually "meet" even though both
   physically pass through the same Mozambique port. */
.project-flow { display: flex; flex-direction: column; gap: 26px; }
.flow-lane-label { font-family: 'Archivo', sans-serif; font-weight: 700; font-size: 0.86rem; margin-bottom: 14px; }
/* Same "scrolls in its own box on a narrow screen" pattern as
   .table-wrap/.waterfall-wrap -- a left-to-right flow reads oddly
   reflowed to a vertical stack, so it scrolls horizontally instead of
   forcing the page wider or restructuring on mobile. */
.flow-row-wrap { overflow-x: auto; padding-bottom: 2px; }
.flow-row { display: flex; align-items: flex-start; min-width: 460px; }
.flow-node { display: flex; flex-direction: column; align-items: center; text-align: center; flex-shrink: 0; width: 92px; }
.flow-dot { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid; background: var(--panel); flex-shrink: 0; }
.flow-dot-end { width: 16px; height: 16px; box-shadow: 0 0 0 4px var(--panel-alt); }
.flow-node-stage { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 10px; }
.flow-node-place { font-size: 0.78rem; color: var(--ink); font-weight: 600; margin-top: 2px; line-height: 1.3; }
.flow-node-place span { display: block; font-size: 0.7rem; color: var(--ink-soft); font-weight: 400; }
.flow-connector {
  flex: 1 1 auto; height: 3px; min-width: 20px; margin: 5px -2px 0;
  background-size: 28px 3px; border-radius: 2px;
  animation: flow-move 1.1s linear infinite;
}
@keyframes flow-move { to { background-position: -28px 0; } }
@media (prefers-reduced-motion: reduce) { .flow-connector { animation: none; } }

.stat-ring { display: flex; align-items: center; gap: 12px; }
.ring-gauge { flex-shrink: 0; }
.stat-ring-label { font-size: 0.82rem; font-weight: 600; color: var(--ink); }
.stat-ring-sub { font-size: 0.74rem; color: var(--ink-soft); margin-top: 2px; }

.project-hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.project-hero {
  background: var(--panel); border: 1px solid var(--border); border-top: 4px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.project-hero.chain-vc1 { border-top-color: var(--vc1); }
.project-hero.chain-vc2 { border-top-color: var(--vc2); }
.project-hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.project-hero-head h3 { margin: 2px 0 2px; font-size: 1.15rem; }
.project-hero-head .sub { font-size: 0.8rem; color: var(--ink-soft); }
.project-hero-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.project-hero-rings { display: flex; gap: 18px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--border-soft); }
.project-hero-link { font-size: 0.82rem; font-weight: 600; margin-left: auto; }

@media (max-width: 900px) {
  .project-hero-stats, .project-hero-rings { gap: 16px; }
}

/* KPI card -- sharp corners, bronze top accent (matches reference exactly) */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 0;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.kpi-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kpi-label { font-size: 0.76rem; color: var(--ink-soft); font-weight: 500; }
.kpi-value { font-family: 'Archivo', sans-serif; font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1.15; word-break: break-word; }
.kpi-value-sm { font-size: 1.15rem; line-height: 1.3; }
.kpi-value .unit { font-size: 0.76rem; color: var(--ink-soft); font-weight: 400; margin-left: 4px; }
.kpi-sub { font-size: 0.74rem; color: var(--ink-soft); line-height: 1.4; }

/* Panel -- rounded card used for tables/detail blocks within a dashboard */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.panel-head { position: relative; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; padding-right: 32px; }
.panel-head .title { font-family: 'Archivo', sans-serif; font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.panel-head .source { font-size: 0.68rem; color: var(--ink-soft); margin-left: auto; overflow-wrap: anywhere; max-width: 100%; }

/* Per-card export menu, injected by card_export.js into every
   .panel-head / .project-hero-head -- one generic control rather than a
   bespoke export route per dashboard card. Pinned to the corner with
   absolute positioning (rather than left as a plain flex child) so it
   can never get pushed onto its own line when a long title + source
   wraps in a narrow, multi-column panel. */
.panel-head .export-menu { position: absolute; top: 0; right: 0; }
.export-menu { position: relative; display: inline-flex; }
.export-menu-list {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 20;
  display: flex; flex-direction: column; min-width: 120px; padding: 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
/* [hidden] and this rule have equal specificity, and this one comes
   later in the cascade -- without this override, `display: flex` above
   wins and the menu renders open on every page load regardless of the
   `hidden` attribute the JS toggles. */
.export-menu-list[hidden] { display: none; }
.export-menu-list button, .export-menu-list a {
  display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 6px;
  font-size: 0.82rem; font-weight: 500; color: var(--ink); background: none; border: none; cursor: pointer; text-decoration: none;
}
.export-menu-list button:hover, .export-menu-list a:hover { background: var(--panel-alt); text-decoration: none; }

.card-export-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel); color: var(--ink-soft); cursor: pointer; flex-shrink: 0;
  align-self: center;
}
.card-export-btn:hover { background: var(--panel-alt); color: var(--brand-dark); border-color: var(--brand-line); }
.card-export-btn:disabled { opacity: 0.5; cursor: wait; }
.note-box { font-size: 0.76rem; color: #4A4536; line-height: 1.5; background: var(--panel-alt); border: 1px solid #E6DFCC; border-radius: 6px; padding: 8px 12px; }

/* Scheme-view tab strip (Auditor dashboard) -- matches expert/84_Dash_CertAuditor's own tab row */
.scheme-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.scheme-tab {
  background: none; border: none; cursor: pointer; padding: 8px 2px 10px;
  font-family: 'Archivo', sans-serif; font-weight: 600; font-size: 0.85rem; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.scheme-tab.active { color: var(--ink); border-bottom-color: var(--brand-dark); }
.scheme-panel[hidden] { display: none; }
.scheme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.scheme-grid .panel { margin-bottom: 0; min-width: 0; overflow-wrap: anywhere; }
.scheme-grid dl { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.scheme-grid dt { font-size: 0.76rem; color: var(--ink-soft); }
.scheme-grid dd { margin: 0; font-weight: 600; font-size: 0.9rem; }
.scheme-grid ul { margin: 0; padding-left: 18px; font-size: 0.82rem; line-height: 1.6; }
@media (max-width: 900px) { .scheme-grid { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th { text-align: left; font-weight: 600; color: var(--ink-soft); padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* Generic record-detail table (browse/record_detail.html, used by all 88
   tables): a fixed label column reads fine on desktop but forces every
   single field to scroll horizontally on a phone. Below 640px it stacks
   into label-then-value blocks instead -- no horizontal scroll needed to
   read a value. */
.detail-table th { width: 260px; }
@media (max-width: 640px) {
  .detail-table, .detail-table tbody, .detail-table tr, .detail-table th, .detail-table td { display: block; width: auto; }
  .detail-table tr { padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
  .detail-table tr:last-child { border-bottom: none; }
  .detail-table th { padding: 0 0 4px; border: none; }
  .detail-table td { padding: 0; border: none; }
}

/* Dark-header table variant, matching the reference COA/shipment tables */
table.dark-head th { background: var(--brand-dark); color: #E8E4DB; text-transform: none; letter-spacing: 0; font-size: 0.76rem; }
table.dark-head tbody tr:nth-child(even) td { background: var(--panel-alt); }
table.dark-head td { border-bottom: 1px solid var(--border-soft); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft-b); color: var(--warn-ink); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--muted-soft); color: var(--muted-ink); }
.badge-vc1 { background: var(--vc1-soft); color: var(--vc1); }
.badge-vc2 { background: var(--vc2-soft); color: #8a6a10; }
.badge-compliance { background: var(--compliance-soft); color: var(--compliance); }

.severity-Critical { color: var(--danger); font-weight: 700; }
.severity-High { color: var(--warn); font-weight: 600; }
.severity-Medium { color: var(--ink-soft); font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-dark);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.btn .nav-icon { opacity: 0.9; }
.btn:hover { background: #16301f; text-decoration: none; }
.btn-secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--panel-alt); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger); filter: brightness(0.9); }

.layer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.layer-tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: block; }
.layer-tile:hover { border-color: var(--brand); text-decoration: none; }
.layer-tile h3 { margin-bottom: 8px; color: var(--ink); }
.layer-tile-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.layer-tile-desc { font-size: 0.82rem; color: var(--ink-soft); line-height: 1.45; margin: 0 0 10px; }
.table-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 3px; }
.table-list a { font-size: 0.84rem; }

/* Browse records: two project tiles (VC1/VC2) up top, real-named shared
   layers below -- same "own chain + shared, never a blended bucket"
   grouping already used and tested by the Load data nav (see
   schema_registry.py::chain_group_for's own docstring on why). */
.section-heading { font-size: 1rem; margin: 26px 0 14px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 8px; }
.project-tile {
  display: block; background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); color: var(--ink);
}
.project-tile:hover { text-decoration: none; box-shadow: 0 4px 16px rgba(26,29,26,0.09); }
.project-tile.chain-vc1 { border-left-color: var(--vc1); }
.project-tile.chain-vc2 { border-left-color: var(--vc2); }
.project-tile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.project-tile h3 { margin-bottom: 6px; }
.project-tile p { font-size: 0.86rem; color: var(--ink-soft); line-height: 1.5; margin: 0 0 12px; }
.project-tile-count { font-size: 0.72rem; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.project-tile-cta { font-size: 0.8rem; font-weight: 600; color: var(--brand); }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 14px; }
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--brand-dark); }
.breadcrumb .sep { color: var(--border); }

/* ---- Load data: persistent nav (left) + single clear workspace (right) ---- */
.import-layout { display: flex; gap: 24px; align-items: flex-start; }
.import-nav-col { flex: 0 0 290px; min-width: 0; position: sticky; top: 16px; }
.import-workspace { flex: 1; min-width: 0; }

.import-search {
  width: 100%; padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-family: 'Inter', Arial, sans-serif; font-size: 0.85rem; background: var(--panel); color: var(--ink);
  margin-bottom: 12px;
}
.import-search:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.import-nav { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 150px); overflow-y: auto; padding-right: 4px; }
.import-nav-group { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.import-nav-group[hidden] { display: none; }
.import-nav-group-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer;
  list-style: none; font-weight: 600; font-size: 0.82rem; border-left: 4px solid transparent;
}
.import-nav-group-head::-webkit-details-marker { display: none; }
.import-nav-group-head.chain-vc1 { border-left-color: var(--vc1); }
.import-nav-group-head.chain-vc2 { border-left-color: var(--vc2); }
.import-nav-group-head.chain-shared { border-left-color: var(--border); color: var(--ink-soft); }
.import-nav-group-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.import-nav-count { margin-left: auto; font-size: 0.68rem; font-weight: 600; color: var(--ink-soft); background: var(--panel-alt); border-radius: 10px; padding: 1px 7px; }
.import-nav-group-head .chevron-toggle svg { transition: transform 0.15s; }
details[open] > .import-nav-group-head .chevron-toggle svg { transform: rotate(180deg); }

.import-nav-group-body { padding: 2px 8px 8px; }
.import-nav-stage[hidden] { display: none; }
.import-nav-stage-label { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-softer); padding: 8px 8px 3px; }
.import-nav-item { display: block; padding: 6px 8px; border-radius: 6px; font-size: 0.8rem; color: var(--ink); text-decoration: none; }
.import-nav-item:hover { background: var(--panel-alt); text-decoration: none; }
.import-nav-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.import-nav-item[hidden] { display: none; }

.import-empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 60px 24px; color: var(--ink-soft); border: 1.5px dashed var(--border); border-radius: var(--radius);
  background: var(--panel-alt);
}
.import-empty-state svg { color: var(--ink-softer); }
.import-empty-state h2 { margin: 0; color: var(--ink); font-size: 1.1rem; }
.import-empty-state p { max-width: 440px; }

.dropzone {
  width: 100%; box-sizing: border-box; min-height: 130px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px dashed var(--border); border-radius: 8px; padding: 28px 16px; text-align: center;
  cursor: pointer; transition: border-color 0.12s, background 0.12s; background: var(--panel-alt);
}
.dropzone:hover, .dropzone.dropzone-active { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.dropzone-loading { opacity: 0.6; pointer-events: none; }
.dropzone input[type="file"] { display: none; }
.dropzone-icon { color: var(--ink-soft); display: flex; justify-content: center; }
.dropzone-text { font-size: 0.82rem; color: var(--ink-soft); line-height: 1.4; }

/* Below 900px, the workspace (the actual task once a table is picked)
   must be reachable immediately -- not buried below ~120 nav links, one
   accordion per chain, both open. The nav collapses behind a one-tap
   toggle instead, same off-canvas-on-mobile idea as the app's own
   primary sidebar. */
.import-nav-toggle {
  display: none;
  align-items: center; gap: 8px; width: 100%; box-sizing: border-box; padding: 10px 14px; margin-bottom: 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  font-family: 'Archivo', sans-serif; font-weight: 600; font-size: 0.86rem; color: var(--ink); cursor: pointer;
}
.import-nav-toggle .chevron-toggle { margin-left: auto; display: flex; }
.import-nav-toggle .chevron-toggle svg { transition: transform 0.15s; }
.import-nav-toggle[aria-expanded="true"] .chevron-toggle svg { transform: rotate(180deg); }

@media (max-width: 900px) {
  .import-layout { flex-direction: column; }
  .import-nav-toggle { display: flex; }
  .import-nav-col { position: static; width: 100%; flex-basis: auto; order: 1; }
  .import-nav-col:not(.open) { display: none; }
  .import-workspace { order: 2; }
  .import-nav { max-height: none; }
}

.chain-hop { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.chain-hop:last-child { border-bottom: none; }
.hop-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.hop-dot.resolved { background: var(--ok); }
.hop-dot.missing { background: var(--border); }

form.inline { display: inline; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: 0.86rem;
}
.readonly {
  padding: 8px 10px; background: var(--panel-alt); border-radius: 6px; color: var(--ink-soft); font-size: 0.86rem;
  /* A long unbroken value (a CSV header row, a joined ID list, ...) must
     wrap inside its own box rather than forcing the whole page wider --
     white-space:pre-wrap alone only breaks at existing spaces, so a
     comma-joined string with none would otherwise overflow the layout. */
  overflow-wrap: anywhere;
  max-width: 100%;
  box-sizing: border-box;
}

/* Page ground is the app's own off-white background (not the brand-dark
   green) so the white card reads as a distinct, elevated surface instead
   of one green box sitting on another. Two faint brand-tinted glows keep
   it from looking bare without competing with the card itself. */
.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 10%, var(--brand-soft) 0%, transparent 40%),
    radial-gradient(circle at 88% 90%, var(--accent-soft) 0%, transparent 35%);
}
.login-card { background: #fff; padding: 0; overflow: hidden; border-radius: 14px; width: 400px; max-width: 100%; border: 1px solid var(--border); box-shadow: 0 20px 50px rgba(26,29,26,0.14), 0 2px 6px rgba(26,29,26,0.06); }
/* The wordmark's dark ring is nearly the same tone as --brand-dark (its own
   contrast against this banner is ~1.2:1 -- effectively invisible), so a
   light halo is added via drop-shadow to separate the ring from the banner
   without touching the asset or losing the cream/green text, which already
   reads fine on the dark band. */
.login-brand { background: var(--brand-dark); padding: 28px 40px 24px; display: flex; align-items: center; justify-content: center; }
.login-brand img { height: 56px; width: auto; display: block; filter: drop-shadow(0 0 9px rgba(255,255,255,0.35)) drop-shadow(0 2px 5px rgba(0,0,0,0.3)); }
.login-card-body { padding: 28px 40px 40px; }
.login-card h1 { font-size: 1.35rem; margin-bottom: 4px; }
.login-sub { color: var(--ink-soft); font-size: 0.85rem; margin-bottom: 24px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; padding: 10px; margin-top: 6px; }

/* ---- Public marketing landing page (logged-out root "/") -- minimal,
   hero-only: a mark, a headline, a one-line subhead, one CTA. The full
   logo wordmark is light-on-dark (built for the app's dark-green header
   bands) and unreadable on this page's cream background, so this uses
   the icon mark alone, which reads fine on either. ---- */
.landing-minimal { min-height: 100vh; position: relative; }

.landing-signin-link {
  position: absolute; top: 28px; right: 28px;
  font-size: 0.85rem; font-weight: 600; color: var(--ink-soft);
}
.landing-signin-link:hover { color: var(--brand-dark); }

.landing-hero-full {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 40px 24px;
  max-width: 940px;
  margin: 0 auto;
}
.landing-mark { height: 56px; width: auto; margin-bottom: 28px; }
.landing-hero-full h1 { font-size: 2.2rem; line-height: 1.25; margin: 0 auto 18px; max-width: 640px; }
.landing-lede { font-size: 1.05rem; color: var(--ink-soft); line-height: 1.6; margin: 0 auto 40px; max-width: 560px; }
.landing-cta { padding: 12px 26px; font-size: 0.95rem; }
.landing-walkthrough-link { display: block; margin-top: 16px; font-size: 0.85rem; color: var(--ink-soft); }
.landing-walkthrough-link:hover { color: var(--brand-dark); }

/* Measurement -> Reporting -> Verification, tied to this app's own
   features (not a generic acronym diagram) -- the one visual centerpiece
   this "hero only" page earns, not a second content section. */
.landing-mrv { display: flex; align-items: flex-start; justify-content: center; gap: 18px; width: 100%; margin-bottom: 40px; }
.landing-mrv-step { flex: 1; max-width: 230px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.landing-mrv-step svg { color: var(--brand); opacity: 1; }
.landing-mrv-step h3 { font-size: 0.95rem; margin: 6px 0 0; }
.landing-mrv-step p { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.5; margin: 0; }
.landing-mrv-arrow { color: var(--ink-softer); font-size: 1.2rem; padding-top: 34px; flex-shrink: 0; }

@media (max-width: 640px) {
  .landing-hero-full h1 { font-size: 1.6rem; }
  .landing-signin-link { top: 18px; right: 18px; }
  .landing-mrv { flex-direction: column; align-items: center; gap: 20px; }
  .landing-mrv-step { max-width: 320px; }
  .landing-mrv-arrow { padding-top: 0; transform: rotate(90deg); }
}

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  /* Below 900px the sidebar becomes an off-canvas drawer (fixed, full-
     screen, above everything) instead of a static block that shoves the
     whole page down below the nav -- toggled by the same button/class
     the desktop collapse already uses, so no separate mobile-only
     control is needed. Collapsed is the mobile default (see base.html's
     inline script); expanding it opens the drawer over the content. */
  .sidebar {
    position: fixed; inset: 0; z-index: 60; width: 280px; max-width: 85vw; height: 100vh;
  }
  html.sidebar-collapsed .sidebar { display: none; }

  html:not(.sidebar-collapsed) .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(26, 29, 26, 0.45);
  }

  .main-pad { padding: 16px; }
  .app-header { padding: 10px 14px; }
  .app-header-titles .s { display: none; }
  .topbar-search { max-width: none; order: 10; flex-basis: 100%; }
  /* These two badges are demo/audience chrome repeated on every dashboard
     -- not unique per-page information -- and their nowrap text doesn't
     fit on its own wrapped line at phone widths even alone, which was
     forcing the whole page to scroll horizontally. Same treatment as the
     header subtitle just above: drop it, keep the avatar. */
  .pill-audience, .pill-status { display: none; }
  .dash-filterbar, .dash-legend, .dash-main, .dash-footer, .flash-stack { padding-left: 16px; padding-right: 16px; margin-left: 16px; margin-right: 16px; }
}

/* Perceived-performance chrome (see base.html + static/js/page_loading.js).
   The top progress bar is global -- cheap, never worth scoping. The
   skeleton only ever covers .content-region (the per-page content area
   below the header): the sidebar and header render from static/session
   data, never the domain layer, so they have nothing to wait for and
   should never visually read as "loading". */
#page-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--brand); z-index: 10000;
  opacity: 0; transition: width 0.2s ease, opacity 0.2s ease;
}
#page-progress.active { opacity: 1; }

/* While streaming (app/core/streaming.py), the real content hasn't
   reached the DOM yet when the skeleton first shows -- .content-region's
   height would otherwise come only from that (still-empty) content,
   collapsing toward zero and taking the absolutely-positioned overlay
   down with it. The min-height guarantees it always covers at least the
   visible viewport below the header, loaded or not. */
.content-region { position: relative; min-height: calc(100vh - 72px); }

#page-loading-overlay {
  position: absolute; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
}
#page-loading-overlay.active { opacity: 1; pointer-events: all; }

.skeleton-shell { width: 100%; max-width: 1100px; }
.skeleton-row { display: flex; gap: 14px; margin-bottom: 16px; }
.skeleton-block {
  background: linear-gradient(90deg, var(--border-soft) 25%, var(--panel-alt) 37%, var(--border-soft) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: 8px;
}
.skel-sm { height: 90px; flex: 1; }
.skel-lg { height: 150px; width: 100%; margin-bottom: 16px; }
@keyframes skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-block { animation: none; }
  #page-progress, #page-loading-overlay { transition: none; }
}
