/* ==========================================================================
   Glass 1.10.0 — shared admin design system for the *LiveService back-ends and
   other dashboards (ReaderLiveService, CridgetLiveService, AppStoreAnalytics).
   Master copy lives in Xcode/AdminDesignSystem — edit it there and run
   ./sync.sh, never in a project's copy. Pair with glass.js; put a project's
   own rules in its own stylesheet, loaded after this one.

   One input: --accent. Every tint, ring, focus glow and background wash is
   derived from it with color-mix(), so a back-end re-brands by setting a
   single custom property on <html>:

       <html data-theme="dark" style="--accent:#ff5a36">

   (Set it on <html>: the derived tokens are computed where they're declared,
   so an --accent set on a descendant won't re-tint them.)

   Semantic colours (good / warn / bad / info) are fixed and never derived
   from the accent, so status meaning is identical across every back-end.

   Legacy aliases (--bg, --surface, --border, --text, --muted, --green, --red,
   --yellow, --orange, --purple) keep older inline styles resolving.
   ========================================================================== */

/* ---- 1. Tokens ----------------------------------------------------------- */
:root {
  --accent: #0a84ff;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --fs-xs: 11px; --fs-sm: 12px; --fs-md: 13px; --fs-lg: 15px; --fs-xl: 22px; --fs-2xl: 28px;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 24px; --r-pill: 999px;

  --blur: 24px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 196px;
  --sidebar-w-collapsed: 64px;
  /* One gutter for the page frame (top, left, right) and every gap between
     tiles, so the layout reads as an even grid. */
  --gutter: 12px;
}

:root, [data-theme="dark"] {
  color-scheme: dark;
  --g-text: #f5f5f7;
  --g-muted: #a1a1aa;
  --g-faint: #6b6b73;
  --g-canvas: #0b0c10;
  --g-glass: rgba(255, 255, 255, .055);
  --g-glass-strong: rgba(30, 31, 37, .86);
  --g-well: rgba(255, 255, 255, .045);
  --g-line: rgba(255, 255, 255, .085);
  --g-line-strong: rgba(255, 255, 255, .16);
  --g-highlight: rgba(255, 255, 255, .09);
  --g-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
  --g-shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 30px 80px rgba(0, 0, 0, .5);
  --g-switch-off: rgba(255, 255, 255, .16);
  --g-field-solid: #23242a;   /* opaque field tone, for the autofill cover */
  --accent-ink: color-mix(in oklab, var(--accent) 70%, white);
  --wash-1: color-mix(in oklab, var(--accent) 22%, transparent);
  --wash-2: color-mix(in oklab, color-mix(in oklab, var(--accent) 50%, #3a2d8f) 20%, transparent);

  --good: #32d074; --warn: #f5b93a; --bad: #ff5c52; --info: #4aa8ff; --caution: #ff8a3d; --violet: #b18cff;
  --mono-bg: #48484e;
}

/* :root-qualified so it outranks the dark block regardless of order. */
:root[data-theme="light"] {
  color-scheme: light;
  --g-text: #1d1d1f;
  --g-muted: #6e6e73;
  --g-faint: #a1a1a6;
  --g-canvas: #f4f5f8;
  --g-glass: rgba(255, 255, 255, .64);
  --g-glass-strong: rgba(255, 255, 255, .92);
  --g-well: rgba(0, 0, 0, .035);
  --g-line: rgba(0, 0, 0, .08);
  --g-line-strong: rgba(0, 0, 0, .14);
  --g-highlight: rgba(255, 255, 255, .9);
  --g-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(20, 30, 60, .07);
  --g-shadow-lg: 0 2px 6px rgba(0, 0, 0, .05), 0 24px 60px rgba(20, 30, 60, .14);
  --g-switch-off: rgba(0, 0, 0, .09);
  --g-field-solid: #fbfbfd;
  --accent-ink: color-mix(in oklab, var(--accent) 82%, black);
  --wash-1: color-mix(in oklab, var(--accent) 16%, transparent);
  --wash-2: color-mix(in oklab, color-mix(in oklab, var(--accent) 50%, #8fb3ff) 14%, transparent);

  --good: #1f9d4c; --warn: #b7791f; --bad: #d92d20; --info: #0a6cdd; --caution: #d9620f; --violet: #7c3aed;
  --mono-bg: #8e8e93;
}

/* Derived tokens — shared by both themes. */
:root, [data-theme] {
  --accent-soft: color-mix(in oklab, var(--accent) 14%, transparent);
  --accent-softer: color-mix(in oklab, var(--accent) 8%, transparent);
  --accent-ring: color-mix(in oklab, var(--accent) 45%, transparent);
  --accent-glow: 0 0 0 4px color-mix(in oklab, var(--accent) 22%, transparent);
  --on-accent: #fff;

  --good-soft: color-mix(in oklab, var(--good) 15%, transparent);
  --warn-soft: color-mix(in oklab, var(--warn) 16%, transparent);
  --bad-soft: color-mix(in oklab, var(--bad) 14%, transparent);
  --info-soft: color-mix(in oklab, var(--info) 14%, transparent);
  --neutral-soft: color-mix(in oklab, var(--g-muted) 14%, transparent);

  /* Chart series: series 1 is always the accent; the rest are fixed hues. */
  --series-1: var(--accent); --series-2: var(--warn); --series-3: var(--good);
  --series-4: var(--violet); --series-5: var(--caution);

  /* Legacy aliases. */
  --bg: var(--g-well); --surface: var(--g-glass-strong); --border: var(--g-line);
  --text: var(--g-text); --muted: var(--g-muted);
  --green: var(--good); --red: var(--bad); --yellow: var(--warn);
  --orange: var(--caution); --purple: var(--violet);
}

/* ---- 2. Canvas ----------------------------------------------------------- */
* { box-sizing: border-box; }
html { background: var(--g-canvas); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--g-text);
  font: var(--fs-md)/1.5 var(--font); -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 700px at 8% -10%, var(--wash-1), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, var(--wash-2), transparent 60%),
    var(--g-canvas);
  background-attachment: fixed;
}
::selection { background: var(--accent-soft); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--g-muted); }
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---- 3. Glass primitive -------------------------------------------------- */
.glass {
  background: var(--g-glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
  backdrop-filter: blur(var(--blur)) saturate(170%);
  border: 1px solid var(--g-line);
  box-shadow: inset 0 1px 0 var(--g-highlight), var(--g-shadow);
}

/* ---- 4. Shell: collapsible sidebar + top bar ---------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; transition: grid-template-columns .25s var(--ease); }
.sidebar {
  /* 100dvh, not 100vh: on iPad/iPhone Safari 100vh is the viewport with the
     toolbars hidden, so a 100vh sidebar runs past the visible area and its
     footer (theme / collapse / log out) sits below the fold. dvh tracks the
     visible height; 100vh stays as the fallback for older browsers. The
     bottom padding clears the home indicator. */
  position: sticky; top: 0; height: 100vh; height: 100dvh; padding: var(--sp-4) var(--sp-3);
  padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid var(--g-line);
  background: color-mix(in oklab, var(--g-glass) 60%, transparent);
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
}
.brand { display: flex; align-items: center; gap: 10px; padding: var(--sp-1) var(--sp-2) var(--sp-4); min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none; display: block;
  background: linear-gradient(160deg, color-mix(in oklab, var(--accent) 75%, white), var(--accent));
  box-shadow: 0 4px 14px var(--accent-ring), inset 0 1px 0 rgba(255,255,255,.35);
}
img.brand-mark { background: none; object-fit: cover; }
.brand-text { min-width: 0; }
.brand-name { font: 600 var(--fs-lg)/1.15 var(--font-display); letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font-size: var(--fs-xs); color: var(--g-muted); white-space: nowrap; }
.nav-group { margin-top: var(--sp-2); display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em;
  color: var(--g-faint); padding: var(--sp-2) var(--sp-3) var(--sp-1); white-space: nowrap;
}
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px var(--sp-3); border: 0; border-radius: var(--r-sm); background: none;
  color: var(--g-muted); font: 500 var(--fs-md)/1.3 var(--font); text-align: left; cursor: pointer; white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item, .nav-item:hover { text-decoration: none; }   /* nav items may be <a> links */
.nav-item:hover { background: var(--g-well); color: var(--g-text); }
.nav-item:focus-visible { outline: none; box-shadow: var(--accent-glow); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item .nav-text { overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 2px; padding-top: var(--sp-3); border-top: 1px solid var(--g-line); }
/* Footer: glyph-only utility buttons in a row, the labelled sign-out filling the rest. */
.sidebar-foot .foot-icon { width: 34px; flex: none; justify-content: center; padding: 7px 0; }
.sidebar-foot .foot-logout { flex: 1; justify-content: flex-end; }
/* Status light beside the product name — aligned to the name's line, not the
   two-line name + version block. */
.brand .status-dot { margin-left: 2px; align-self: flex-start; margin-top: 5px; }

/* Collapsed: an icon rail. Labels hide; each item keeps its title tooltip. */
.sidebar-collapsed .shell { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.sidebar-collapsed .shell .sidebar { padding-left: var(--sp-2); padding-right: var(--sp-2); align-items: center; }
.sidebar-collapsed .shell .brand { padding: var(--sp-1) 0 var(--sp-4); justify-content: center; }
.sidebar-collapsed .shell .brand-text,
.sidebar-collapsed .shell .nav-text,
.sidebar-collapsed .shell .nav-label { display: none; }
.sidebar-collapsed .shell .nav-group { width: 100%; padding-top: var(--sp-2); border-top: 1px solid var(--g-line); }
.sidebar-collapsed .shell .nav-group:first-of-type { border-top: 0; padding-top: 0; }
.sidebar-collapsed .shell .nav-item { justify-content: center; padding: 9px 0; }
.sidebar-collapsed .shell .sidebar-foot { width: 100%; flex-direction: column; }
.sidebar-collapsed .shell .sidebar-foot .foot-icon, .sidebar-collapsed .shell .sidebar-foot .foot-logout { width: 100%; flex: none; justify-content: center; }
/* Collapsed: the status light becomes a badge on the logo's corner. */
.sidebar-collapsed .shell .brand { position: relative; }
.sidebar-collapsed .shell .brand .status-dot { position: absolute; top: 0; left: calc(50% + 10px); margin: 0; box-shadow: 0 0 0 2px var(--g-canvas); }
.sidebar-collapsed .shell .collapse-ic { transform: scaleX(-1); }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3);
  padding: var(--sp-4) var(--gutter);
  background: color-mix(in oklab, var(--g-canvas) 55%, transparent);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%); backdrop-filter: blur(var(--blur)) saturate(170%);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--g-line); }
.page-title { font: 650 var(--fs-xl)/1.15 var(--font-display); letter-spacing: -.02em; margin: 0; display: flex; align-items: center; gap: 10px; }
.page-sub { font-size: var(--fs-sm); color: var(--g-muted); }
.spacer { flex: 1; }
/* The page frame is one gutter on the top, left and right — the same as the
   gaps between tiles; the top bar uses the same inset to keep the title aligned. */
.container { max-width: 1600px; padding: var(--gutter) var(--gutter) var(--sp-8); }

/* Narrow screens: the sidebar becomes a scrolling strip above the page. */
@media (max-width: 900px) {
  /* auto/1fr rows + start alignment stop the grid's min-height stretching the
     strip; flex:none keeps strip items full size so the row scrolls instead. */
  .shell, .sidebar-collapsed .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }
  .sidebar > *, .nav-group > * { flex: none; }
  .sidebar, .sidebar-collapsed .shell .sidebar {
    position: sticky; top: 0; z-index: 60; height: auto; flex-direction: row; align-items: center;
    overflow-x: auto; overflow-y: hidden; padding: var(--sp-2) var(--sp-3); border-right: 0; border-bottom: 1px solid var(--g-line);
  }
  .brand, .sidebar-collapsed .shell .brand { padding: 0 var(--sp-2) 0 0; }
  .brand-text, .nav-label, .nav-collapse { display: none; }
  .brand .status-dot { align-self: center; margin-top: 0; }
  .nav-group, .sidebar-collapsed .shell .nav-group { display: contents; }
  .nav-item, .sidebar-collapsed .shell .nav-item { width: auto; padding: 6px var(--sp-3); border-radius: var(--r-pill); }
  .nav-item svg { display: none; }
  .sidebar-collapsed .shell .nav-text { display: inline; }
  .sidebar-foot, .sidebar-collapsed .shell .sidebar-foot { margin: 0 0 0 auto; padding: 0 0 0 var(--sp-2); border: 0; flex-direction: row; width: auto; }
  .sidebar-foot .foot-logout, .sidebar-collapsed .shell .sidebar-foot .foot-logout { flex: none; width: auto; }
  .sidebar-foot .nav-item svg { display: block; }
  .sidebar-foot .nav-text { display: none !important; }
  .topbar { position: static; padding: var(--sp-4) var(--gutter) 0; }
  .container { padding: var(--gutter) var(--gutter) var(--sp-6); }
}

/* Theme toggle (glassInitTheme): holds .ic-auto / .ic-light / .ic-dark glyphs
   and shows the one matching its data-mode. */
.theme-toggle svg { display: none; }
.theme-toggle[data-mode="auto"] .ic-auto, .theme-toggle[data-mode="light"] .ic-light, .theme-toggle[data-mode="dark"] .ic-dark { display: block; }

/* Rail tip (glassInitRailTips): the page name in a frosted pill beside the
   hovered icon while the sidebar is collapsed. One shared fixed element so a
   scrolling sidebar can't clip it. Fades and slides 4px out from the icon;
   once showing, it glides between items as the pointer skims the rail. */
#railTip {
  position: fixed; z-index: 700; left: 0; top: 0; pointer-events: none;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 6px 11px; border-radius: var(--r-pill);
  font: 500 var(--fs-md)/1.2 var(--font); color: var(--g-text);
  background: var(--g-glass-strong); border: 1px solid var(--g-line-strong); box-shadow: var(--g-shadow-lg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%); backdrop-filter: blur(var(--blur)) saturate(170%);
  opacity: 0; transform: translate(-4px, -50%);
  transition: opacity .15s var(--ease), transform .15s var(--ease);
}
#railTip.show { opacity: 1; transform: translate(0, -50%); }
#railTip.glide { transition: opacity .15s var(--ease), transform .15s var(--ease), top .14s var(--ease); }
#railTip .rt-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
#railTip .badge { margin-left: 2px; }
@media (prefers-reduced-motion: reduce) {
  #railTip, #railTip.show { transform: translate(0, -50%); }
}

/* ---- 5. Status dot ------------------------------------------------------- */
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--g-faint); flex: none; display: inline-block; }
.status-dot:not(.ok):not(.warn):not(.err) { visibility: hidden; }
.status-dot.ok { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.status-dot.err { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }

/* ---- 6. Layout grids ----------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: var(--gutter); margin-bottom: var(--gutter); }
/* Side-by-side cards stretch to the taller neighbour so a row reads as one band. */
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: var(--gutter); margin-bottom: var(--gutter); }
.pair .span-all { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: var(--gutter); min-width: 0; }
.grid .card, .pair .card, .stack .card { margin-bottom: 0; }
@media (max-width: 760px) { .pair { grid-template-columns: 1fr; } }

/* ---- 7. Card ------------------------------------------------------------- */
.card {
  background: var(--g-glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%); backdrop-filter: blur(var(--blur)) saturate(170%);
  border: 1px solid var(--g-line); border-radius: var(--r-lg);
  box-shadow: inset 0 1px 0 var(--g-highlight), var(--g-shadow);
  margin-bottom: var(--gutter); min-width: 0;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-4) 18px var(--sp-3);
}
.card-header h2 { margin: 0; font: 600 var(--fs-lg)/1.3 var(--font-display); letter-spacing: -.01em; display: inline-flex; align-items: center; gap: 6px; }
.card-header > .muted { font-size: var(--fs-sm); }
/* Icon chip leading a card title: accent-tinted, or the card's tone when set. */
.card-ic {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 26px; border-radius: 8px; margin-right: 4px;
  background: var(--accent-soft); color: var(--accent-ink);
}
.card-ic svg { width: 15px; height: 15px; }
/* Status tone (data-tone="good|warn|bad"): a faint wash down from the top edge,
   a tinted top hairline, and the icon chip in the status colour — so a card in
   trouble stands out before any number is read. Good is kept quiet. */
.card[data-tone="good"] { --tone: var(--good); --tone-wash: color-mix(in oklab, var(--good) 6%, transparent); }
.card[data-tone="warn"] { --tone: var(--warn); --tone-wash: color-mix(in oklab, var(--warn) 12%, transparent); }
.card[data-tone="bad"]  { --tone: var(--bad);  --tone-wash: color-mix(in oklab, var(--bad) 12%, transparent); }
.card[data-tone] {
  background-image: linear-gradient(180deg, var(--tone-wash), transparent 140px);
  box-shadow: inset 0 1px 0 color-mix(in oklab, var(--tone) 40%, transparent), var(--g-shadow);
}
.card[data-tone] .card-ic { background: color-mix(in oklab, var(--tone) 16%, transparent); color: var(--tone); }
.card-body { padding: var(--sp-1) 18px 18px; }
.card-body.flush { padding: 0 0 var(--sp-2); }
/* Text fields and dropdowns in a card header match the 28px pill buttons.
   .field-bar brings the same pills into a card body — a search / filter / URL
   row of fields and buttons (field flex:1 to fill, buttons stay their size). */
.card-header select, .card-header input:not([type="checkbox"]):not([type="radio"]),
.field-bar select, .field-bar input:not([type="checkbox"]):not([type="radio"]) {
  height: 28px; padding-top: 0; padding-bottom: 0; border-radius: var(--r-pill); font-size: var(--fs-sm);
}
.card-header select:not([multiple]), .field-bar select:not([multiple]) { padding-left: 12px; }
.field-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.hdr-right { display: flex; align-items: center; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap; justify-content: flex-end; }

/* ---- 8. Stats ------------------------------------------------------------ */
/* A stat row is one tinted, rounded panel of cells divided by hairlines.
   Cells share the row equally (flex-basis 0) but never shrink below their own
   content (min-width:max-content), so a row wraps only when the values truly
   can't fit. Each cell draws its divider as an outer shadow on its left and
   top edge; the panel's overflow clips the ones on the outer edge, so the
   grid lines stay right however the cells wrap. */
.stat-row, .stat-row.fit {
  display: flex; flex-wrap: wrap; gap: 0; overflow: hidden;
  background: var(--g-well); border: 1px solid var(--g-line); border-radius: var(--r-md);
}
.stat-row > *, .stat-row.fit > * {
  flex: 1 1 0; min-width: max-content; padding: 10px 10px 9px;
  box-shadow: -1px 0 0 var(--g-line), 0 -1px 0 var(--g-line);
}
.stat-row + .stat-row { margin-top: 10px; }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat .v {
  font: 600 17px/1.15 var(--font-display); letter-spacing: -.015em; min-height: 21px;
  display: flex; align-items: flex-end; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat .v.small { font-size: var(--fs-md); }
.stat .l { font-size: var(--fs-xs); color: var(--g-muted); font-weight: 500; white-space: nowrap; }
.stat .v.good { color: var(--good); } .stat .v.warn { color: var(--warn); } .stat .v.bad { color: var(--bad); }

/* Proportion bar: how a total splits (healthy/stale/dead, read/unread…), with a
   legend carrying each part's share. Segments carry data-tip for hover. */
.seg { margin-top: 12px; }
.seg-bar { display: flex; gap: 2px; height: 8px; border-radius: var(--r-pill); overflow: hidden; background: var(--g-well); }
.seg-bar > span { min-width: 3px; }
.seg-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: var(--fs-xs); color: var(--g-muted); }
.seg-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: -.5px; }
.seg-legend b { color: var(--g-text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- 9. Buttons ---------------------------------------------------------- */
.action-btn, .save-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 28px; padding: 4px 12px; border-radius: var(--r-pill);
  font: 500 var(--fs-sm)/1.2 var(--font); white-space: nowrap; cursor: pointer; text-align: center;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .1s, filter .15s;
}
.action-btn:active:not(:disabled), .save-btn:active:not(:disabled) { transform: scale(.97); }
.action-btn:focus-visible, .save-btn:focus-visible { outline: none; box-shadow: var(--accent-glow); }
.action-btn:disabled, .save-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Secondary: a quiet glass pill. */
.action-btn { background: var(--g-well); border: 1px solid var(--g-line); color: var(--g-text); }
.action-btn:hover:not(:disabled) { background: var(--accent-softer); border-color: var(--accent-ring); color: var(--accent-ink); }
.action-btn.accent { color: var(--accent-ink); }
.action-btn.danger { color: var(--bad); }
.action-btn.danger:hover:not(:disabled) { background: var(--bad-soft); border-color: color-mix(in oklab, var(--bad) 45%, transparent); color: var(--bad); }
.action-btn svg { width: 15px; height: 15px; flex: none; }
.action-btn.icon { padding: 4px 7px; }

/* Primary: filled accent. */
.save-btn {
  border: 0; color: var(--on-accent);
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 88%, white), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 4px 14px color-mix(in oklab, var(--accent) 30%, transparent);
}
.save-btn:hover:not(:disabled) { filter: brightness(1.07); }
.save-btn.lg { min-height: 40px; font-size: var(--fs-md); padding: 0 var(--sp-5); width: 100%; }

/* ---- 10. Segmented control (reporting windows) -------------------------- */
.window-filters {
  display: inline-flex; flex-wrap: wrap; padding: 2px; gap: 2px; border-radius: 14px;
  background: var(--g-well); border: 1px solid var(--g-line);
}
.window-btn {
  border: 0; background: none; color: var(--g-muted); cursor: pointer;
  height: 22px; padding: 0 9px; border-radius: var(--r-pill); font: 500 var(--fs-xs)/1 var(--font);
  transition: background .15s, color .15s;
}
.window-btn:hover { color: var(--g-text); }
.window-btn.active { background: var(--g-glass-strong); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(0,0,0,.14), inset 0 0 0 1px var(--g-line); }
select.window-select {
  height: 28px; padding: 0 26px 0 11px; border-radius: var(--r-pill); border: 1px solid var(--g-line);
  background: var(--g-well) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
  -webkit-appearance: none; appearance: none; color: var(--g-muted); font: 500 var(--fs-xs)/1 var(--font); cursor: pointer;
}
select.window-select:hover { color: var(--g-text); }
select.window-select.active { color: var(--accent-ink); border-color: var(--accent-ring); background-color: var(--accent-softer); }

/* ---- 11. Pills & badges -------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; line-height: 16px;
  border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
  background: var(--neutral-soft); color: var(--g-muted);
}
/* Status pills (good/warn/bad/neutral) lead with a dot; data pills don't. */
.pill.good::before, .pill.warn::before, .pill.bad::before, .pill.neutral::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none;
}
.pill.good, .pill.s2 { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .pill.s4, .pill.s5 { background: var(--bad-soft); color: var(--bad); }
.pill.info, .pill.s3 { background: var(--info-soft); color: var(--info); }
.pill.neutral { background: var(--neutral-soft); color: var(--g-muted); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 500; background: var(--g-well); border: 1px solid var(--g-line); color: var(--g-muted);
}
.chip b { color: var(--g-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- 12. Banner ---------------------------------------------------------- */
.banner {
  display: block; line-height: 1.45;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); margin-bottom: var(--gutter);
  font-size: var(--fs-md); font-weight: 500;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid color-mix(in oklab, var(--warn) 30%, transparent);
}
.banner.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in oklab, var(--bad) 30%, transparent); }
.banner.good { background: var(--good-soft); color: var(--good); border-color: color-mix(in oklab, var(--good) 30%, transparent); }
.banner.neutral { background: var(--neutral-soft); color: var(--g-muted); border-color: var(--g-line); }
/* Info uses the fixed --info hue, not the accent: a red/orange accent would
   otherwise make a neutral notice read as an error. */
.banner.info { background: var(--info-soft); color: var(--info); border-color: color-mix(in oklab, var(--info) 30%, transparent); }

/* ---- 13. Tables ---------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; font-size: var(--fs-md); border-bottom: 1px solid var(--g-line); }
th { font-size: var(--fs-xs); font-weight: 600; color: var(--g-muted); border-bottom-color: var(--g-line-strong); padding-top: 7px; padding-bottom: 7px; }
th[onclick], th.sortable { cursor: pointer; user-select: none; }
th[onclick]:hover, th.sortable:hover { color: var(--g-text); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--accent-softer); }
tbody tr:last-child > td { border-bottom: 0; }

/* ---- 14. Forms ----------------------------------------------------------- */
input, select, textarea {
  font: inherit; color: var(--g-text); background: var(--g-well);
  border: 1px solid var(--g-line); border-radius: var(--r-sm); padding: 7px 11px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--g-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--accent-glow); }

/* Search fields (type="search") get a clear ✕ inside the right edge, shown
   only once something is typed. It's the browser's own cancel button,
   restyled as a filled circle-✕ in the muted text colour — so it survives a
   field being re-rendered, needs no script, and clearing fires the field's
   usual input event. Escape clears too. (Firefox draws no cancel button.) */
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; margin: 0 -4px 0 6px; flex: none; cursor: pointer;
  align-self: center; /* Safari otherwise pins it to the top of a short field */
  opacity: 1; pointer-events: auto; /* Chrome otherwise shows it only on hover/focus */
  background: var(--g-faint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zm2.47 4.47L8 6.94 5.53 4.47 4.47 5.53 6.94 8l-2.47 2.47 1.06 1.06L8 9.06l2.47 2.47 1.06-1.06L9.06 8l2.47-2.47z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zm2.47 4.47L8 6.94 5.53 4.47 4.47 5.53 6.94 8l-2.47 2.47 1.06 1.06L8 9.06l2.47 2.47 1.06-1.06L9.06 8l2.47-2.47z'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: background-color .15s;
}
input[type="search"]::-webkit-search-cancel-button:hover { background: var(--g-muted); }

/* Autofill: browsers force their own fill (Safari's pale yellow) behind any
   field a password manager fills, ignoring our background. Cover it with an
   inset shadow in an opaque accent tint — opaque, or the yellow shows through
   — and give the field a thin accent edge, so "filled for you" still reads,
   in the product's colour and theme. Each selector gets its own rule: one a
   browser doesn't know would invalidate a combined list. The long transition
   stops Chrome flashing its colour before the cover paints. */
:root, [data-theme] { --g-autofill: color-mix(in oklab, var(--accent) 9%, var(--g-field-solid)); }
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--g-autofill) inset; box-shadow: 0 0 0 1000px var(--g-autofill) inset;
  -webkit-text-fill-color: var(--g-text); caret-color: var(--g-text); border-color: var(--accent-ring);
  transition: background-color 600000s 0s, color 600000s 0s;
}
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--g-autofill) inset, var(--accent-glow); box-shadow: 0 0 0 1000px var(--g-autofill) inset, var(--accent-glow);
  border-color: var(--accent);
}
input:autofill {
  box-shadow: 0 0 0 1000px var(--g-autofill) inset; -webkit-text-fill-color: var(--g-text); caret-color: var(--g-text); border-color: var(--accent-ring);
}
input:autofill:focus { box-shadow: 0 0 0 1000px var(--g-autofill) inset, var(--accent-glow); border-color: var(--accent); }
/* Safari's obscured-password and strong-password variants paint their own band. */
input:-webkit-autofill-and-obscured { -webkit-box-shadow: 0 0 0 1000px var(--g-autofill) inset; -webkit-text-fill-color: var(--g-text); border-color: var(--accent-ring); }
input:-webkit-autofill-strong-password { -webkit-box-shadow: 0 0 0 1000px var(--g-autofill) inset; -webkit-text-fill-color: var(--g-text); border-color: var(--accent-ring); }
input:-webkit-autofill-strong-password-viewable { -webkit-box-shadow: 0 0 0 1000px var(--g-autofill) inset; -webkit-text-fill-color: var(--g-text); border-color: var(--accent-ring); }
input[type="checkbox"]:not(.setting-toggle), input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; padding: 0; vertical-align: middle; }
select { cursor: pointer; }
/* Selects get the same chevron everywhere instead of the native control. */
select:not([multiple]):not([size]) {
  -webkit-appearance: none; appearance: none; padding-right: 26px; text-align: left;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

/* Switch — macOS 27 proportions: a ~2.4:1 track with a capsule-shaped knob. */
.setting-toggle {
  -webkit-appearance: none; appearance: none; margin: 0; padding: 0; border: 0; flex: none; cursor: pointer;
  width: 44px; min-width: 44px; height: 18px; border-radius: var(--r-pill); position: relative;
  background: var(--g-switch-off); box-shadow: inset 0 0 0 .5px rgba(0,0,0,.06);
  transition: background .25s var(--ease);
}
.setting-toggle::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 14px; border-radius: var(--r-pill);
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.28), 0 0 0 .5px rgba(0,0,0,.05);
  transition: transform .25s var(--ease);
}
.setting-toggle:checked { background: var(--accent); }
.setting-toggle:checked::before { transform: translateX(14px); }
.setting-toggle:focus-visible { box-shadow: var(--accent-glow); }
.setting-toggle:disabled { opacity: .45; cursor: not-allowed; }

/* Settings rows: label (+ optional ⓘ and hint) on the left, control right. */
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); padding: 11px 0; border-bottom: 1px solid var(--g-line); min-width: 0; }
.setting-row:last-child { border-bottom: 0; }
.setting-row > div:first-child { min-width: 0; }
.setting-label { font-size: var(--fs-md); font-weight: 500; }
.setting-title { display: inline-flex; align-items: center; gap: 6px; }
.setting-desc { font-size: var(--fs-sm); color: var(--g-muted); margin: 2px 0 0; line-height: 1.45; }
.setting-hint { font-size: var(--fs-xs); color: var(--g-muted); margin-top: 1px; }
.setting-input { width: 84px; text-align: right; padding: 5px 10px; font-variant-numeric: tabular-nums; flex: none; }
.setting-unit { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.setting-unit > span { font-size: var(--fs-sm); color: var(--g-muted); min-width: 34px; }

/* Grouped list (System Settings style): rows inside a tinted rounded well. */
.group { background: var(--g-well); border: 1px solid var(--g-line); border-radius: var(--r-md); padding: 0 var(--sp-4); }
.group + .group, .group-title + .group { margin-top: var(--sp-3); }
.group-title { font-size: var(--fs-sm); font-weight: 600; color: var(--g-muted); margin: var(--sp-5) 0 var(--sp-2) var(--sp-1); }
.group-title:first-child { margin-top: 0; }

/* ⓘ info glyph — hover, focus or click shows its data-info text in #infoTip. */
.info-i {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 15px; height: 15px; border-radius: 50%; padding: 0; cursor: help;
  border: 1px solid var(--g-line-strong); background: none; color: var(--g-muted);
  font: italic 600 10px/1 Georgia, "Times New Roman", serif; vertical-align: middle;
  transition: color .15s, border-color .15s, background .15s;
}
.info-i:hover, .info-i:focus-visible, .info-i.on { outline: none; color: var(--accent-ink); border-color: var(--accent-ring); background: var(--accent-softer); }
#infoTip {
  position: fixed; z-index: 600; display: none; max-width: 340px; padding: 10px 12px;
  border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.5; color: var(--g-text); white-space: pre-line;
  background: var(--g-glass-strong); border: 1px solid var(--g-line-strong); box-shadow: var(--g-shadow-lg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%); backdrop-filter: blur(var(--blur)) saturate(170%);
}

/* Floating save bar — appears while a form has unsaved changes. */
.savebar {
  position: fixed; left: 50%; bottom: 24px; z-index: 400; transform: translate(-50%, 140%); opacity: 0;
  display: flex; align-items: center; gap: var(--sp-3); padding: 8px 8px 8px 18px; border-radius: var(--r-pill);
  background: var(--g-glass-strong); border: 1px solid var(--g-line-strong); box-shadow: var(--g-shadow-lg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%); backdrop-filter: blur(var(--blur)) saturate(170%);
  transition: transform .3s var(--ease), opacity .3s var(--ease); pointer-events: none; white-space: nowrap;
}
.savebar.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.savebar .msg { font-size: var(--fs-md); font-weight: 500; }
.savebar .msg.err { color: var(--bad); }

/* Section sub-navigation inside a page (e.g. Settings). */
.subnav { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; margin-bottom: var(--gutter); border-radius: var(--r-pill);
  background: var(--g-well); border: 1px solid var(--g-line); width: fit-content; max-width: 100%; }
.subnav button {
  border: 0; background: none; color: var(--g-muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 14px; border-radius: var(--r-pill); font: 500 var(--fs-md)/1 var(--font); transition: background .15s, color .15s;
}
.subnav button svg { width: 15px; height: 15px; }
.subnav button:hover { color: var(--g-text); }
.subnav button.active { background: var(--g-glass-strong); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(0,0,0,.14), inset 0 0 0 1px var(--g-line); }

/* ---- 15. Bars, charts, legends ------------------------------------------ */
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 6px; border-radius: var(--r-pill); background: var(--g-well); overflow: hidden; box-shadow: inset 0 0 0 1px var(--g-line); }
.bar-fill { height: 100%; border-radius: var(--r-pill); background: linear-gradient(90deg, color-mix(in oklab, var(--accent) 65%, white), var(--accent)); }
.legend { display: flex; flex-wrap: wrap; gap: 4px var(--sp-4); font-size: var(--fs-xs); color: var(--g-muted); align-items: center; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--sp-2); }
.chart .yax { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; font-size: 10px; color: var(--g-faint); font-variant-numeric: tabular-nums; }
.chart .plot { grid-column: 2; grid-row: 1; min-width: 0; }
.chart .xax { grid-column: 2; grid-row: 2; display: flex; justify-content: space-between; font-size: 10.5px; color: var(--g-faint); margin-top: 6px; }
.chart [data-tip] { cursor: crosshair; }
#chartTip {
  position: fixed; pointer-events: none; z-index: 500; display: none; white-space: nowrap;
  padding: 6px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: var(--g-text);
  background: var(--g-glass-strong); border: 1px solid var(--g-line); box-shadow: var(--g-shadow-lg);
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
}
/* Shared floating panel (popovers anchored to a control). */
.popover {
  background: var(--g-glass-strong); border: 1px solid var(--g-line-strong); border-radius: var(--r-md);
  box-shadow: var(--g-shadow-lg); -webkit-backdrop-filter: blur(var(--blur)) saturate(170%); backdrop-filter: blur(var(--blur)) saturate(170%);
}

/* ---- 16. Auth (splash, sign-in) ----------------------------------------- */
#authSplash { display: none; position: fixed; inset: 0; align-items: center; justify-content: center; z-index: 1001; background: var(--g-canvas); }
body.auth-checking #authSplash { display: flex; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--g-line-strong); border-top-color: var(--accent); animation: g-spin .8s linear infinite; }
@keyframes g-spin { to { transform: rotate(360deg); } }
.auth-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.auth-card {
  width: min(400px, 100%); padding: var(--sp-8); border-radius: var(--r-xl);
  display: flex; flex-direction: column; gap: var(--sp-2); box-shadow: inset 0 1px 0 var(--g-highlight), var(--g-shadow-lg);
}
.auth-card .brand-mark { width: 44px; height: 44px; border-radius: 13px; margin-bottom: var(--sp-3); }
.auth-card h2 { margin: 0; font: 650 var(--fs-xl)/1.2 var(--font-display); letter-spacing: -.02em; }
.auth-card p { margin: 0 0 var(--sp-3); color: var(--g-muted); }
.auth-card > label { font-size: var(--fs-sm); color: var(--g-muted); font-weight: 500; margin-top: var(--sp-2); }
.auth-card input:not([type="checkbox"]) { padding: 9px 12px; }
.auth-card .save-btn { margin-top: var(--sp-4); }

/* ---- 18. Dialog + file drop --------------------------------------------- */
/* A modal panel on the native <dialog> (top layer, focus trap, Escape), opened
   with glassDialog() in glass.js: .dialog-head (title + close), .dialog-body
   (scrolls; .flush for edge-to-edge tables), .dialog-foot (actions, right-
   aligned; a .spacer pushes items left). .wide for review tables. */
dialog.dialog {
  width: min(560px, calc(100vw - 2 * var(--gutter))); max-width: none;
  max-height: calc(100vh - 2 * var(--sp-8)); max-height: calc(100dvh - 2 * var(--sp-8));
  margin: auto; padding: 0; border: 1px solid var(--g-line-strong); border-radius: var(--r-xl);
  color: var(--g-text); background: var(--g-glass-strong);
  box-shadow: inset 0 1px 0 var(--g-highlight), var(--g-shadow-lg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%); backdrop-filter: blur(var(--blur)) saturate(170%);
  flex-direction: column; overflow: hidden;
}
dialog.dialog:focus { outline: none; }
dialog.dialog[open] { display: flex; animation: g-dialog-in .18s var(--ease); }
dialog.dialog.wide { width: min(1240px, calc(100vw - 2 * var(--gutter))); }
dialog.dialog::backdrop { background: rgba(8, 10, 18, .38); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes g-dialog-in { from { opacity: 0; transform: translateY(6px) scale(.985); } }
.dialog-head { display: flex; align-items: center; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap; padding: var(--sp-4) 18px var(--sp-3); border-bottom: 1px solid var(--g-line); }
.dialog-head h2 { margin: 0; font: 600 var(--fs-lg)/1.3 var(--font-display); letter-spacing: -.01em; display: inline-flex; align-items: center; gap: 6px; }
.dialog-head .dialog-close { margin-left: auto; }
.dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--sp-4) 18px; }
.dialog-body.flush { padding: 0; }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3) 18px var(--sp-4); border-top: 1px solid var(--g-line); }
.dialog-foot .save-btn { min-height: 28px; }
/* A click-or-drop target for a file (glassFileDrop() wires it up). */
.drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: var(--sp-6) var(--sp-4); text-align: center; cursor: pointer; color: var(--g-muted);
  border: 1.5px dashed var(--g-line-strong); border-radius: var(--r-md); background: var(--g-well);
  transition: background .15s, border-color .15s, color .15s;
}
.drop-zone b { color: var(--g-text); font-weight: 600; }
.drop-zone:hover, .drop-zone.over { border-color: var(--accent-ring); background: var(--accent-softer); color: var(--accent-ink); }
.drop-zone:focus-visible { outline: none; box-shadow: var(--accent-glow); }

/* ---- 17. Accessibility preferences -------------------------------------- */
@media (prefers-reduced-motion: reduce) { *, *::before { transition: none !important; animation: none !important; } }
@media (prefers-reduced-transparency: reduce) {
  .card, .glass, .sidebar, .topbar, .savebar, .popover, dialog.dialog, #chartTip, #infoTip { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--g-glass-strong); }
}

/* ---- 18. Touch ----------------------------------------------------------- */
/* Fingers, not pointers: every rule here is gated on a coarse pointer, so a
   mouse or trackpad sees no change at any window size (width can't tell a
   1000px desktop window from an iPhone Duo's inner screen; input can). */
@media (pointer: coarse) {
  /* Controls up to ~32px tall: the header and field-bar pills, segmented
     controls, buttons, sidebar items, checkboxes. */
  .action-btn, .save-btn { min-height: 34px; }
  .action-btn.icon { min-width: 34px; }
  .window-btn { height: 30px; padding: 0 12px; }
  select.window-select,
  .card-header select, .card-header input:not([type="checkbox"]):not([type="radio"]),
  .field-bar select, .field-bar input:not([type="checkbox"]):not([type="radio"]) { height: 34px; }
  .subnav button { height: 34px; }
  :root .sidebar .nav-item { padding-top: 10px; padding-bottom: 10px; }
  input[type="checkbox"]:not(.setting-toggle), input[type="radio"] { width: 20px; height: 20px; }
  /* Small round glyphs keep their look; only the hit area grows. */
  .info-i { position: relative; }
  .info-i::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; }
}

/* Pinned first column (opt-in): put .pin-first on a table, or on the scroller
   around it. On a touch screen held landscape, the first cell of every row
   stays put while a wide table scrolls sideways, so the row keeps its label.
   Pinned cells need an opaque fill or the scrolled columns show through. */
@media (pointer: coarse) and (orientation: landscape) {
  .pin-first tr > :first-child {
    position: sticky; left: 0; z-index: 1; background: var(--g-field-solid);
    box-shadow: inset -1px 0 0 var(--g-line);
  }
  .pin-first tbody tr:hover > :first-child { background: color-mix(in oklab, var(--accent) 8%, var(--g-field-solid)); }
}
