/* Norwill Scorecard OS — design tokens
 * Creative North Star: "The Climbing Wall"
 * Anchored to the Norwill Healthcare logo greens, with a single warm secondary
 * (Climbing Amber) for earned momentum. See DESIGN.md for the full system.
 *
 * Variable names like --brand-700 and --good are kept stable so views that
 * have not been redesigned yet still read the new palette automatically.
 */

:root {
  /* ── Norwill brand greens (anchored to the logo) ─────────────── */
  --norwill-forest:  #355E2C;
  --norwill-leaf:    #6FA844;
  --spring-shoot:    #94C76B;
  --forest-mist:     #E5F0DC;

  /* ── Single warm secondary — Climbing Amber + Ridge Clay ─────── */
  --amber:           #E2A858;
  --amber-deep:      #B57617;
  --amber-soft:      #FBEFD3;
  --ridge-clay:      #B36F4D;

  /* ── Neutrals (warm-sage tinted, never pure black/white) ─────── */
  --ink-900: #15201A;
  --ink-800: #22302A;
  --ink-700: #374239;
  --ink-600: #525C53;
  --ink-500: #6E7A71;
  --ink-400: #94A095;
  --ink-300: #B7C0B9;
  --ink-200: #D2D9D2;
  --ink-100: #E7ECE7;
  --ink-50:  #F1F4EE;

  --surface-page:  #F7F9F5;
  --surface-card:  #FFFFFF;
  --surface-sunk:  #F1F4EE;
  --hairline:      #DEE5DA;
  --hairline-strong: #C9D2C5;

  /* ── Status (functional only, never used for identity) ───────── */
  --summit:        #3C8E4D;
  --summit-bg:     #E5F2DF;
  --caution:       #B57617;
  --caution-bg:    #FBEFD3;
  --slip:          #B83A2E;
  --slip-bg:       #F8DDD7;

  /* ── Legacy aliases — kept so untouched views still work ─────── */
  --brand-900: #1F3D1B;
  --brand-800: #2A4D24;
  --brand-700: var(--norwill-forest);
  --brand-600: #4A7E37;
  --brand-500: var(--norwill-leaf);
  --brand-400: var(--spring-shoot);
  --brand-300: #B0D689;
  --brand-200: #C9E1B0;
  --brand-100: var(--forest-mist);
  --brand-50:  #F0F7E8;

  --bg:        var(--surface-page);
  --card:      var(--surface-card);
  --card-alt:  var(--surface-sunk);
  --line:      var(--hairline);
  --line-strong: var(--hairline-strong);

  --good:      var(--summit);
  --good-bg:   var(--summit-bg);
  --warn:      var(--caution);
  --warn-bg:   var(--caution-bg);
  --bad:       var(--slip);
  --bad-bg:    var(--slip-bg);

  /* ── Geometry, type, motion ──────────────────────────────────── */
  --radius:     14px;
  --radius-md:  10px;
  --radius-sm:  6px;
  --radius-pill: 999px;

  /* Soft-Sage Shadow vocabulary — green-tinted, never pure black */
  --shadow-sm:  0 1px 2px rgba(21, 32, 26, 0.04), 0 4px 14px rgba(21, 32, 26, 0.05);
  --shadow-md:  0 2px 6px rgba(21, 32, 26, 0.06), 0 10px 28px rgba(21, 32, 26, 0.08);
  --shadow-lg:  0 10px 32px rgba(21, 32, 26, 0.12), 0 24px 64px rgba(21, 32, 26, 0.10);

  --focus-ring: 0 0 0 3px rgba(111, 168, 68, 0.38);

  --pad: 24px;
  --pad-row: 14px;
  --gap: 16px;

  --font:         'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --duration-fast: 160ms;
  --duration: 220ms;
}

[data-theme="dark"] {
  --surface-page: #131A14;
  --surface-card: #1A231C;
  --surface-sunk: #161E18;
  --hairline:     #25302A;
  --hairline-strong: #2F3A33;

  --ink-900: #ECF1EA;
  --ink-800: #DDE5DA;
  --ink-700: #C2CDC0;
  --ink-600: #A0AEA0;
  --ink-500: #7E8C7E;
  --ink-400: #5F6D60;
  --ink-300: #4A5749;
  --ink-200: #3B4839;
  --ink-100: #2C3A2D;
  --ink-50:  #21302A;

  --forest-mist:  #1F3324;
  --summit-bg:    #143C1F;
  --caution-bg:   #3A2A0E;
  --slip-bg:      #3A1714;

  --bg: var(--surface-page);
  --card: var(--surface-card);
  --card-alt: var(--surface-sunk);
  --line: var(--hairline);
  --line-strong: var(--hairline-strong);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.32), 0 4px 14px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.40), 0 10px 28px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 10px 32px rgba(0, 0, 0, 0.50), 0 24px 64px rgba(0, 0, 0, 0.42);

  --brand-100: #1F3324;
  --brand-50:  #182519;
  --brand-200: #2A4030;
}

[data-density="compact"] {
  --pad: 18px;
  --pad-row: 10px;
  --gap: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--surface-page);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  font-size: 15px;
  line-height: 1.5;
  /* Hard-stop horizontal page scroll. Anything inside that needs to scroll
     wide content (Scorecard table) does so within its own card. */
  overflow-x: hidden;
}
#root { min-width: 0; }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

/* Numeric helpers */
.mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; }
.tnum { font-variant-numeric: tabular-nums; }
.numeric { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: 'tnum', 'ss01'; }

/* Display utility */
.display { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }

/* Eyebrow / label */
.eyebrow {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-500);
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }
::-webkit-scrollbar-track { background: transparent; }

/* Shared chip — pill, paired with a label, never color-only */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--ink-100); color: var(--ink-700);
}
.chip.good  { background: var(--summit-bg);  color: var(--summit); }
.chip.bad   { background: var(--slip-bg);    color: var(--slip); }
.chip.warn  { background: var(--caution-bg); color: var(--caution); }
.chip.brand { background: var(--forest-mist); color: var(--norwill-forest); }
.chip.muted { background: var(--ink-100); color: var(--ink-600); }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}

.card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card.flat { box-shadow: none; }
.card-hover { transition: box-shadow var(--duration) var(--ease-out), transform var(--duration) var(--ease-out); }
.card-hover:hover { box-shadow: var(--shadow-md); }

.hairline { height: 1px; background: var(--hairline); }

/* ── Ambient page motion — very subtle, the "Climbing Wall" page wash
 *    Two slow-drifting radial highlights in Forest Mist + Climbing Amber.
 *    Movement is bounded to ~14px and disabled under prefers-reduced-motion. */
.page-ambient {
  position: relative;
  background: var(--surface-page);
}
.page-ambient::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 12% 8%, rgba(111, 168, 68, 0.07), transparent 62%),
    radial-gradient(720px 420px at 92% 6%, rgba(226, 168, 88, 0.05), transparent 60%),
    radial-gradient(900px 540px at 78% 96%, rgba(53, 94, 44, 0.04), transparent 64%);
  animation: norwill-drift 22s ease-in-out infinite alternate;
}
@keyframes norwill-drift {
  from { transform: translate3d(-6px, -4px, 0) scale(1); }
  to   { transform: translate3d(8px, 6px, 0) scale(1.01); }
}

/* Focus — Norwill Leaf 35% ring, sits on top of any elevation */
*:focus { outline: none; }
*:focus-visible { box-shadow: var(--focus-ring); border-radius: 6px; }
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: var(--focus-ring);
}

/* Reusable button primitives */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  min-height: 40px;
}
.btn-primary {
  background: var(--norwill-forest);
  color: #fff;
}
.btn-primary:hover { background: var(--norwill-leaf); }
.btn-ghost {
  background: var(--surface-card);
  color: var(--ink-700);
  border-color: var(--hairline);
}
.btn-ghost:hover { background: var(--surface-sunk); color: var(--ink-900); }
.btn-quiet {
  background: transparent;
  color: var(--ink-600);
  border-color: transparent;
}
.btn-quiet:hover { background: var(--surface-sunk); color: var(--ink-900); }
.btn-sm { padding: 6px 12px; min-height: 32px; font-size: 12.5px; }

/* Inputs */
.input {
  display: inline-block; width: 100%;
  padding: 10px 12px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--ink-900);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.input:focus, .input:focus-visible {
  border-color: var(--norwill-leaf);
  box-shadow: var(--focus-ring);
}
.input.numeric { text-align: right; }

/* Working / Meeting mode toggle (segmented control) */
.mode-toggle {
  display: inline-flex; align-items: center; padding: 3px;
  background: var(--surface-sunk);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  gap: 0;
}
.mode-toggle button {
  padding: 6px 14px;
  border: none; background: transparent;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
  color: var(--ink-600);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
  min-height: 32px;
}
.mode-toggle button.active {
  background: var(--surface-card);
  color: var(--ink-900);
  box-shadow: var(--shadow-sm);
}
.mode-toggle button:hover:not(.active) { color: var(--ink-800); }

/* Sparklines */
.spark { display: block; }

/* Tweak panel (legacy) */
.tweaks-panel {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  width: 280px; border-radius: 14px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-md);
  padding: 14px; font-size: 13px;
  display: none;
}
.tweaks-panel.open { display: block; }
.tweaks-panel h4 {
  margin: 0 0 10px; font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-500); font-weight: 700;
  font-family: var(--font);
}
.tweak-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid var(--hairline);
}
.tweak-row:last-child { border-bottom: none; }
.tweak-row label { color: var(--ink-700); font-weight: 500; }
.tweak-row select, .tweak-row button.tweak-toggle {
  background: var(--surface-card);
  border: 1px solid var(--hairline-strong);
  border-radius: 8px; padding: 5px 8px;
  color: var(--ink-800);
  font-size: 12px; cursor: pointer;
  font-family: inherit;
}

/* "Today" pulse on entry — Climbing Amber, the earned-momentum signal */
@keyframes norwill-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(226, 168, 88, 0.45); }
  70%  { box-shadow: 0 0 0 10px rgba(226, 168, 88, 0); }
  100% { box-shadow: 0 0 0 0 rgba(226, 168, 88, 0); }
}
.pulse-today { animation: norwill-pulse 2.4s var(--ease-out) infinite; }

/* Slide up (kept for compatibility) */
@keyframes slideUp {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes norwill-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.slide-up { animation: slideUp 0.35s var(--ease-out); }

/* ── Streak chevron — earned momentum signal on Scorecard rows ── */
.streak-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 999px;
  background: rgba(226, 168, 88, 0.18);
  color: var(--amber-deep);
  font-size: 10px;
  flex-shrink: 0;
}

/* ── Scorecard table primitives ─────────────────────────────── */
.sc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
.sc-table th, .sc-table td {
  text-align: center;
  vertical-align: middle;
  padding: 14px 10px;
  border-bottom: 1px solid var(--hairline);
}
.sc-table th {
  background: var(--surface-sunk);
  color: var(--ink-600);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  position: sticky; top: 0;
  z-index: 1;
}
.sc-table tbody tr:hover { background: var(--surface-sunk); }
.sc-table .sc-metric-cell {
  text-align: left;
  position: sticky; left: 0;
  background: var(--surface-card);
  z-index: 2;
  box-shadow: 1px 0 0 var(--hairline);
  min-width: 220px;
}
.sc-table tbody tr:hover .sc-metric-cell {
  background: var(--surface-sunk);
}
.sc-table .sc-now {
  background: var(--forest-mist);
}
.sc-table .sc-now-th {
  background: var(--forest-mist);
  color: var(--norwill-forest);
}
.sc-cell {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-weight: 500;
  font-size: 14px;
  min-width: 56px;
}
.sc-cell--good { background: rgba(60, 142, 77, 0.12); color: var(--summit); font-weight: 600; }
.sc-cell--warn { background: rgba(181, 118, 23, 0.13); color: var(--caution); font-weight: 600; }
.sc-cell--bad  { background: rgba(184, 58, 46, 0.13);  color: var(--slip);    font-weight: 600; }

/* Meeting mode: bigger type, taller rows for shared-screen legibility */
.mode-meeting .sc-table { font-size: 16px; }
.mode-meeting .sc-table th, .mode-meeting .sc-table td { padding: 18px 12px; }
.mode-meeting .sc-cell { font-size: 17px; }
.mode-meeting h2.view-title { font-size: 32px; }

/* ── Mobile Scorecard — stacked metric cards with 3-week strip ── */
.sc-stack { display: flex; flex-direction: column; gap: 12px; }
.sc-stack-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow-sm);
}
.sc-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.sc-strip-cell {
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
  background: var(--surface-card);
}
.sc-strip-cell .sc-strip-week { font-size: 10px; color: var(--ink-500); letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }
.sc-strip-cell .sc-strip-val  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 16px; margin-top: 4px; }
.sc-strip-cell.sc-strip--good { background: var(--summit-bg);  border-color: rgba(60,142,77,0.25); }
.sc-strip-cell.sc-strip--warn { background: var(--caution-bg); border-color: rgba(181,118,23,0.25); }
.sc-strip-cell.sc-strip--bad  { background: var(--slip-bg);    border-color: rgba(184,58,46,0.25); }
.sc-strip-cell.sc-strip--now  { box-shadow: 0 0 0 2px var(--norwill-forest) inset; }

/* ── Issues list (IDS) ───────────────────────────────────────── */
.iss-list { display: flex; flex-direction: column; gap: 10px; }
.iss-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-fast) var(--ease-out);
}
.iss-row:hover { box-shadow: var(--shadow-md); }
.iss-row.is-open { box-shadow: var(--shadow-md); }
.iss-handle {
  width: 18px; height: 28px;
  display: flex; flex-direction: column; gap: 3px;
  align-items: center; justify-content: center;
  cursor: grab; color: var(--ink-300);
}
.iss-handle::before, .iss-handle::after, .iss-handle span {
  content: ''; display: block;
  width: 14px; height: 2px; border-radius: 99px;
  background: currentColor;
}
.mode-meeting .iss-handle { color: var(--ink-400); }
.iss-row:not(.iss-row--ids) .iss-handle { display: none; }
.iss-stage {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--ink-100); color: var(--ink-700);
  border: none; cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  min-height: 26px;
}
.iss-stage--identified { background: var(--ink-100); color: var(--ink-700); }
.iss-stage--discussing { background: var(--caution-bg); color: var(--caution); }
.iss-stage--solved     { background: var(--summit-bg);  color: var(--summit); }
.iss-text { font-size: 14px; color: var(--ink-900); line-height: 1.45; }
.mode-meeting .iss-text { font-size: 16px; }
.iss-meta { font-size: 11.5px; color: var(--ink-500); margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.iss-capture {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px;
  background: var(--surface-card);
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius);
}
.iss-capture .input { background: transparent; border: none; padding: 6px 4px; }
.iss-capture .input:focus-visible { box-shadow: none; }

/* ── Rocks card ──────────────────────────────────────────────── */
.rocks-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 880px) {
  .rocks-grid { grid-template-columns: 1fr 1fr; }
}
.rock-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow var(--duration-fast) var(--ease-out);
}
.rock-card:hover { box-shadow: var(--shadow-md); }
.rock-progress-track {
  width: 100%; height: 6px;
  background: var(--forest-mist);
  border-radius: 99px;
  overflow: hidden;
}
.rock-progress-fill {
  height: 100%;
  background: var(--norwill-leaf);
  transition: width var(--duration) var(--ease-out), background var(--duration) var(--ease-out);
}
.rock-progress-fill.near-summit { background: var(--amber); }
.rock-slider {
  width: 100%; appearance: none; -webkit-appearance: none;
  height: 6px; background: var(--forest-mist); border-radius: 99px;
  margin: 4px 0 0;
}
.rock-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--norwill-forest); border: 2px solid var(--surface-card);
  box-shadow: var(--shadow-sm); cursor: grab;
}
.rock-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--norwill-forest); border: 2px solid var(--surface-card);
  box-shadow: var(--shadow-sm); cursor: grab;
}

/* ── Layout shell breakpoints ────────────────────────────────── */
.shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}
.shell-main {
  flex: 1;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.shell-sidebar {
  width: 232px;
  flex-shrink: 0;
}
.shell-drawer-toggle { display: none; }
.shell-bottom-tabs { display: none; }

@media (max-width: 760px) {
  /* Sidebar becomes an off-canvas drawer. Hidden by default; slides in
     from the left when the topbar hamburger is tapped. */
  .shell-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 84vw; max-width: 320px;
    z-index: 220;
    transform: translateX(-105%);
    transition: transform 240ms var(--ease-out);
    box-shadow: var(--shadow-lg);
  }
  .shell-sidebar.is-open {
    transform: translateX(0);
  }
  .shell-drawer-backdrop {
    position: fixed; inset: 0;
    background: rgba(21, 32, 26, 0.42);
    z-index: 210;
    animation: norwill-fade-in 180ms var(--ease-out);
  }
  .shell-drawer-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--surface-card);
    color: var(--ink-800);
    cursor: pointer;
    flex-shrink: 0;
  }
  .shell-drawer-toggle:hover { background: var(--surface-sunk); }
  .shell-drawer-toggle .badge-dot {
    position: absolute;
    top: 8px; right: 8px;
    width: 8px; height: 8px; border-radius: 99px;
    background: var(--caution);
  }

  /* Tighten page padding everywhere on phone */
  main > div { /* most views are <div padding=...> at the root */
    padding-left: 16px !important;
    padding-right: 16px !important;
    padding-bottom: 88px !important; /* clear the bottom tab bar */
  }

  /* ── Bottom tab bar — quick access to the 5 primary mobile views.
   *    The hamburger drawer covers everything else. */
  .shell-bottom-tabs {
    display: flex; align-items: stretch;
    position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 90;
    background: var(--surface-card);
    border-top: 1px solid var(--hairline);
    height: 64px;
    box-shadow: 0 -4px 18px rgba(21, 32, 26, 0.06);
    /* Honor iOS safe-area inset so the bar lifts above the home indicator. */
    padding-bottom: env(safe-area-inset-bottom, 0);
    height: calc(64px + env(safe-area-inset-bottom, 0));
  }
  .shell-bottom-tabs .tab {
    flex: 1;
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    background: transparent; border: none;
    color: var(--ink-500);
    font-size: 10.5px; font-weight: 600;
    cursor: pointer;
    min-width: 0;
    padding: 4px 2px;
  }
  .shell-bottom-tabs .tab span {
    max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .shell-bottom-tabs .tab.active {
    color: var(--norwill-forest);
  }
  .shell-bottom-tabs .tab.active::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    width: 28px; height: 2px;
    transform: translateX(-50%);
    background: var(--norwill-forest);
    border-radius: 0 0 2px 2px;
  }

  /* Scorecard wide-table is replaced by the stacked component on mobile,
     but defensively stop the legacy desktop card from leaking horizontal
     scroll into the layout on transitional viewports. */
  .sc-table { font-size: 13px; }

  /* View header: stack on phone, never wrap into a 3-row mess */
  .view-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .view-header > span[style*="flex: 1"] { display: none; }
  .view-title { font-size: clamp(1.4rem, 6vw, 1.75rem); }

  /* Topbar: keep the mode toggle and avatar visible, hide the impersonation
     "View as" select unless the user is admin/owner (it appears via JS,
     this is just a defensive wrap rule). */
  header[data-shell-topbar] { padding: 10px 14px; }

  /* Tweaks panel slides up from the bottom edge instead of floating */
  .tweaks-panel { left: 16px; right: 16px; bottom: 16px; width: auto; }
}

/* ── Section header ─────────────────────────────────────────── */
.view-header {
  display: flex; align-items: flex-end; gap: 14px;
  margin-bottom: 20px;
}
.view-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  letter-spacing: -0.01em;
  margin: 4px 0 0;
  color: var(--ink-900);
}
.view-sub {
  color: var(--ink-600);
  font-size: 13.5px;
  margin-top: 4px;
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .page-ambient::before { animation: none; }
  .pulse-today { animation: none; }
  .slide-up { animation: none; }
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
