/* ==========================================================================
   Prepr theme. Light/dark follow the system setting; every colour is a token.
   CSP is style-src 'self': no inline styles anywhere, so dynamic sizes are
   SVG attributes and all styling lives here.
   ========================================================================== */
:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Inter, Roboto, "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #f5f5f7;
  --bg-glow: rgba(0, 113, 227, .07);
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --fill: rgba(120, 120, 128, .12);
  --fill-strong: rgba(120, 120, 128, .2);
  --seg-on: #ffffff;
  --border: rgba(0, 0, 0, .08);
  --border-strong: rgba(0, 0, 0, .16);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --accent: #0066cc;
  --accent-fill: #0071e3;
  --accent-fill-hover: #0077ed;
  --accent-ink: #ffffff;
  --accent-soft: rgba(0, 113, 227, .1);
  --ok: #248a3d;
  --ok-soft: rgba(52, 199, 89, .14);
  --warn: #b25000;
  --warn-soft: rgba(255, 149, 0, .15);
  --bad: #d70015;
  --bad-soft: rgba(255, 59, 48, .12);
  --header-bg: rgba(245, 245, 247, .76);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 24px rgba(0, 0, 0, .05);
  --shadow-hi: 0 1px 2px rgba(0, 0, 0, .06), 0 12px 40px rgba(0, 0, 0, .08);

  /* Data series (validated for CVD separation and contrast on the card surface) */
  --water: #2a78d6;
  --food: #eb6834;
  --protein: #e87ba4;
  --fat: #6250d6;
  --carbs: #1baf7a;

  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --bg-glow: rgba(10, 132, 255, .13);
    --surface: #161618;
    --surface-2: #1f1f22;
    --fill: rgba(120, 120, 128, .24);
    --fill-strong: rgba(120, 120, 128, .36);
    --seg-on: #5b5b60;
    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .16);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #7c7c80;
    --accent: #2997ff;
    --accent-fill: #0071e3;
    --accent-fill-hover: #0a84ff;
    --accent-soft: rgba(10, 132, 255, .16);
    --ok: #30d158;
    --ok-soft: rgba(48, 209, 88, .14);
    --warn: #ff9f0a;
    --warn-soft: rgba(255, 159, 10, .15);
    --bad: #ff453a;
    --bad-soft: rgba(255, 69, 58, .15);
    --header-bg: rgba(18, 18, 20, .72);
    --shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
    --shadow-hi: inset 0 1px 0 rgba(255, 255, 255, .06), 0 20px 60px rgba(0, 0, 0, .5);

    --water: #3987e5;
    --food: #d95926;
    --protein: #d55181;
    --fat: #9085e9;
    --carbs: #199e70;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); min-height: 100vh;
  background: radial-gradient(1100px 520px at 50% -180px, var(--bg-glow), transparent 70%) no-repeat, var(--bg);
  font: 16px/1.47 var(--font); letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, summary:focus-visible, .button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px 64px; }

/* Header + nav: frosted bar */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .top { background: var(--bg); } }
.top .wrap { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
.brand {
  display: inline-flex; align-items: center; gap: 9px; flex: none;
  font: 700 15px/1 var(--font-display); letter-spacing: .14em; color: var(--text); text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand::before {
  content: ""; width: 24px; height: 24px; border-radius: 7px; flex: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 18V6h5.2a3.8 3.8 0 0 1 0 7.6H10.6V18z' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat,
    linear-gradient(140deg, #2997ff 0%, #0063d1 55%, #3a2ec2 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 3px rgba(0, 0, 0, .25);
}
nav.main { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; justify-content: center; }
nav.main::-webkit-scrollbar { display: none; }
nav.main a {
  color: var(--text-2); text-decoration: none; padding: 6px 13px; border-radius: 999px; white-space: nowrap;
  font-size: 14px; font-weight: 500; transition: color .15s, background-color .15s;
}
nav.main a:hover { color: var(--text); background: var(--fill); text-decoration: none; }
nav.main a[aria-current="page"] { color: var(--text); background: var(--fill-strong); font-weight: 600; }
.top form { margin: 0; flex: none; }

h1, h2, h3 { font-family: var(--font-display); color: var(--text); }
h1 { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -.028em; margin: 28px 0 6px; }
h2 { font-size: 19px; line-height: 1.25; font-weight: 600; letter-spacing: -.018em; margin: 28px 0 12px; }
h3 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin: 18px 0 8px; }
p { margin: 8px 0; }
strong { font-weight: 600; }
.muted, small { color: var(--text-2); }
.lede { color: var(--text-2); margin-top: 0; font-size: 17px; }

/* Cards and grids */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin: 14px 0; box-shadow: var(--shadow);
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.grid.two > .card { margin: 0; }
.grid + .grid { margin-top: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.stat .value { font: 600 28px/1.15 var(--font-display); letter-spacing: -.025em; margin: 6px 0 4px; }
.stat .sub { color: var(--text-2); font-size: 13px; }
.bar { display: block; width: 100%; height: 10px; margin-top: 10px; }
.bar .track { fill: var(--fill); }
.bar .est { fill: var(--accent-fill); opacity: .38; }
.bar .ver { fill: var(--accent-fill); }
.legend { font-size: 12px; color: var(--text-2); display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .v { background: var(--text-2); }
.legend .e { background: var(--text-2); opacity: .35; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; line-height: 1.5;
  padding: 1px 9px; border-radius: 999px; background: var(--fill); color: var(--text-2); white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
.badge.bad { color: var(--bad); background: var(--bad-soft); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--border); padding: 12px 0; }
.list > li:first-child { border-top: 0; }
.list.card { padding: 4px 20px; }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 0; }
.name { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

/* Tables (scroll horizontally inside the card on narrow screens) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-2); font-weight: 500; font-size: 13px; }
thead th { font-size: 12px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
tbody tr:last-child > * { border-bottom: 0; }
td.num, th.num { text-align: right; }

/* Forms */
label { display: block; color: var(--text-2); font-size: 13px; font-weight: 500; }
input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 10px 12px; width: 100%; margin-top: 6px; min-height: 44px;
  transition: border-color .15s, box-shadow .15s, background-color .15s, transform .1s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:-webkit-autofill, input:-webkit-autofill:hover {
  -webkit-text-fill-color: var(--text); caret-color: var(--text); -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset;
}
input:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset, 0 0 0 4px var(--accent-soft); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-fill); box-shadow: 0 0 0 4px var(--accent-soft);
}
select {
  -webkit-appearance: none; appearance: none; padding-right: 36px;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 12px center / 14px no-repeat;
}
textarea { min-height: 180px; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
input[type="checkbox"] {
  width: 22px; height: 22px; min-height: 0; margin: 0 10px 0 0; padding: 0; vertical-align: middle;
  accent-color: var(--accent-fill); box-shadow: none;
}
label.check { display: flex; align-items: center; color: var(--text); font-size: 15px; font-weight: 400; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px 16px; margin: 14px 0; }
legend { color: var(--text); padding: 0 6px; font-weight: 600; font-size: 14px; }
button, .button {
  background: var(--accent-fill); color: var(--accent-ink); border: 1px solid transparent; border-radius: 980px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; padding: 10px 20px; letter-spacing: -.01em;
}
button:hover, .button:hover { background: var(--accent-fill-hover); text-decoration: none; }
button:active, .button:active { transform: scale(.98); }
button.secondary, .button.secondary { background: var(--fill); color: var(--accent); border-color: transparent; }
button.secondary:hover, .button.secondary:hover { background: var(--fill-strong); }
button.danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
button.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
button.small, .button.small { min-height: 34px; padding: 6px 14px; font-size: 14px; width: auto; margin-top: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.actions button, .actions .button { width: auto; }
.inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline > * { flex: 1; min-width: 90px; }
.inline > button { flex: 0 0 auto; width: auto; }
details { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin: 10px 0; }
details > summary { cursor: pointer; list-style-position: outside; font-weight: 500; }
details[open] > summary { margin-bottom: 10px; }

/* Messages */
.flash {
  border-radius: var(--radius-sm); padding: 12px 14px; margin: 16px 0; color: var(--text);
  background: var(--ok-soft); border: 1px solid var(--border);
}
.flash.error, .errors { background: var(--bad-soft); border: 1px solid var(--border); color: var(--text); }
.errors { border-radius: var(--radius-sm); padding: 12px 14px 12px 32px; margin: 16px 0; }
.note { font-size: 13px; color: var(--text-2); border-left: 2px solid var(--border-strong); padding-left: 12px; margin-top: 18px; }

/* Segmented control */
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--fill); }
.seg a {
  padding: 6px 14px; border-radius: 8px; text-decoration: none; color: var(--text); font-size: 13px; font-weight: 500;
  font-variant-numeric: tabular-nums; transition: background-color .15s;
}
.seg a:hover { background: var(--fill); text-decoration: none; }
.seg a[aria-current="true"] { background: var(--seg-on); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .04); }

.login { max-width: 380px; margin: 14vh auto 0; }
.login h1 { color: var(--text); letter-spacing: .16em; font-size: 28px; display: flex; align-items: center; gap: 12px; }
.login h1::before {
  content: ""; width: 36px; height: 36px; border-radius: 10px; flex: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 18V6h5.2a3.8 3.8 0 0 1 0 7.6H10.6V18z' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat,
    linear-gradient(140deg, #2997ff 0%, #0063d1 55%, #3a2ec2 100%);
}
.login .card { box-shadow: var(--shadow-hi); }

pre, code { font-family: var(--mono); font-size: 13px; }
code { background: var(--fill); padding: 1px 5px; border-radius: 5px; }
pre { white-space: pre-wrap; overflow-x: auto; background: var(--surface-2); border: 1px solid var(--border); padding: 12px; border-radius: 10px; }
pre code { background: none; padding: 0; }
.line-include { opacity: 1; }
.line-excluded { opacity: .5; }

/* Utilities / Health checklists */
progress {
  display: block; width: 100%; height: 8px; margin-top: 10px; border: 0; border-radius: 4px;
  background: var(--fill); overflow: hidden; -webkit-appearance: none; appearance: none;
}
progress::-webkit-progress-bar { background: var(--fill); border-radius: 4px; }
progress::-webkit-progress-value { background: var(--accent-fill); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--accent-fill); border-radius: 4px; }
.card > .row:first-child > h2 { margin-top: 0; }
.toolbar { margin: 20px 0 8px; }
.toolbar .seg { flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chips a { font-size: 13px; font-weight: 500; padding: 4px 12px; border-radius: 999px; background: var(--fill); color: var(--text); }
.chips a:hover { background: var(--fill-strong); text-decoration: none; }
.item-note { display: block; margin-top: 2px; }
.quick { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.quick input { width: 88px; flex: 0 0 88px; min-height: 34px; margin: 0; padding: 6px 10px; }
.list > li[id^="s-"]:target { background: var(--accent-soft); border-radius: var(--radius-sm); margin: 0 -10px; padding-left: 10px; padding-right: 10px; }
[id^="s-"], [id^="sec-"] { scroll-margin-top: 110px; }

@media (max-width: 760px) {
  .top .wrap { flex-wrap: wrap; row-gap: 6px; }
  .top form { margin-left: auto; }
  nav.main { order: 3; flex-basis: 100%; margin: 0 -8px; justify-content: flex-start; }
  h1 { font-size: 28px; }
}
@media (max-width: 560px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .stat .value { font-size: 24px; }
  .card { padding: 16px; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ==========================================================================
   Dashboard
   ========================================================================== */
.eyebrow {
  margin: 0; font: 600 11px/1.3 var(--mono); letter-spacing: .09em; text-transform: uppercase; color: var(--text-2);
}
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin: 30px 0 18px; }
.dash-head h1 { margin: 6px 0 4px; }
.dash-head .lede { margin: 0; font-size: 15px; }
.dash-head .seg { margin-bottom: 2px; }

.dash .card { margin: 0; }
.dash > * + * { margin-top: 14px; }

/* Card header row: icon, title, trailing link */
.card-head { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; }
.card-head h2 { margin: 0; font-size: 17px; flex: 1; min-width: 0; }
.card-head .ico { color: var(--text-2); }
.more { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.more .ico { width: 14px; height: 14px; color: currentColor; stroke-width: 2.2; }

/* Empty state */
.dash-empty { display: flex; gap: 18px; align-items: flex-start; background: radial-gradient(500px 220px at 0 0, var(--accent-soft), transparent 70%), var(--surface); }
.dash-empty h2 { margin: 2px 0 6px; }
.dash-empty p { color: var(--text-2); margin: 0 0 14px; max-width: 60ch; }
.dash-empty form { margin: 0; }
.dash-empty button { width: auto; }
.empty-ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex: none; }
.empty-ico .ico { width: 22px; height: 22px; }

/* Hero */
.dash-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 28px 40px; align-items: center; padding: 28px;
  background: radial-gradient(640px 320px at 0 0, var(--accent-soft), transparent 65%), var(--surface);
}
.hero-fig { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 6px; }
.hero-num { font: 700 clamp(60px, 8.5vw, 88px)/.95 var(--font-display); letter-spacing: -.045em; color: var(--text); }
.hero-unit { font: 600 22px/1 var(--font-display); letter-spacing: -.02em; color: var(--text-2); }
.hero-sub { color: var(--text-2); font-size: 15px; margin: 0 0 16px; max-width: 42ch; }

.status {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: var(--fill); color: var(--text-2);
}
.status .ico { width: 16px; height: 16px; stroke-width: 2.2; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.bad { background: var(--bad-soft); color: var(--bad); }

.hero-meters { display: grid; gap: 22px; }
.mrow-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mrow-name { font-weight: 600; flex: 1; display: flex; align-items: center; gap: 8px; }
.mrow-name .ico { width: 16px; height: 16px; color: var(--text-2); }
.mrow-fig { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 14px; white-space: nowrap; }
.mrow-fig b { color: var(--text); font: 600 20px/1 var(--font-display); letter-spacing: -.02em; margin-right: 2px; }
.mrow-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.hero-meters .legend { margin-top: -6px; }

/* Series keys (identity swatch next to text; text stays in ink colours) */
.key { width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--text-3); display: inline-block; }
.key.water { background: var(--water); }
.key.food { background: var(--food); }
.key.protein { background: var(--protein); }
.key.fat { background: var(--fat); }
.key.carbs { background: var(--carbs); }

/* Meters: track is a light step of the series hue, estimate a middle step, verified solid */
.meter { display: block; width: 100%; height: 8px; overflow: visible; }
.meter.lg { height: 10px; }
.meter rect { fill: var(--text-3); }
.meter .m-track { opacity: .14; }
.meter .m-est { opacity: .4; }
.meter.water rect { fill: var(--water); }
.meter.food rect { fill: var(--food); }
.meter.accent rect { fill: var(--accent-fill); }
.meter.ok rect { fill: var(--ok); }
@media (prefers-reduced-motion: no-preference) {
  .meter .m-est, .meter .m-ver { transform-box: fill-box; transform-origin: 0 50%; animation: meter-grow .9s var(--ease) both; }
  .meter .m-ver { animation-delay: .12s; }
}
@keyframes meter-grow { from { transform: scaleX(0); } }

/* KPI tiles */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 18px; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-label .ico { width: 16px; height: 16px; }
.kpi-value { font: 600 30px/1.1 var(--font-display); letter-spacing: -.03em; margin: 8px 0 2px; display: flex; align-items: baseline; gap: 6px; }
.kpi-value small { font-size: 15px; font-weight: 500; letter-spacing: -.01em; color: var(--text-2); }
.kpi-sub { color: var(--text-2); font-size: 12px; margin-top: auto; padding-top: 6px; }
.kpi .meter { margin-top: 10px; }
.kpi-value.is-bad { color: var(--bad); }

/* Two-column card grid */
.dash-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }

/* Shopping gaps (meter list) */
.gaps { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.gap-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.gap-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gap-fig { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gap-foot { margin-top: 6px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Data quality */
.quality-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.quality-pct { font: 600 30px/1 var(--font-display); letter-spacing: -.03em; }
.quality-pct small { font-size: 14px; font-weight: 500; color: var(--text-2); letter-spacing: 0; margin-left: 4px; }
.checks { list-style: none; margin: 18px 0 0; padding: 0; }
.checks li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.checks li:first-child { border-top: 0; }
.checks .grow { flex: 1; min-width: 0; color: var(--text); }
.checks .n { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 2ch; text-align: right; }
.checks .ico { width: 16px; height: 16px; stroke-width: 2.2; }
.checks .ok { color: var(--ok); }
.checks .warn { color: var(--warn); }
.checks li.is-ok .n { color: var(--text-2); font-weight: 500; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.card-actions .button { width: auto; }

/* Nutrition */
.nutri-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.nutri-kcal { font: 600 30px/1 var(--font-display); letter-spacing: -.03em; }
.nutri-unit { color: var(--text-2); font-size: 14px; font-weight: 500; }
.segbar { display: block; width: 100%; height: 12px; border-radius: 999px; overflow: hidden; }
.segbar rect { stroke: var(--surface); stroke-width: 2; }
.segbar .s-protein { fill: var(--protein); }
.segbar .s-fat { fill: var(--fat); }
.segbar .s-carbs { fill: var(--carbs); }
.segbar .s-empty { fill: var(--fill); stroke: none; }
.macros { list-style: none; margin: 14px 0 0; padding: 0; }
.macros li { display: grid; grid-template-columns: auto 1fr auto 3.5em; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.macros li:first-child { border-top: 0; }
.macros .num { text-align: right; }
.macros .share { color: var(--text-2); }
.nutri-foot { font-size: 13px; color: var(--text-2); margin: 12px 0 0; }

/* Rotation */
.rot-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rot-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.rot-n { display: block; font: 600 26px/1.1 var(--font-display); letter-spacing: -.03em; }
.rot-l { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); margin-top: 4px; }
.rot-l .ico { width: 13px; height: 13px; stroke-width: 2.2; }
.rot-tile.is-bad .rot-n, .rot-tile.is-bad .rot-l { color: var(--bad); }
.rot-tile.is-warn .rot-n, .rot-tile.is-warn .rot-l { color: var(--warn); }
.upcoming { list-style: none; margin: 14px 0 0; padding: 0; }
.upcoming li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.upcoming li:first-child { border-top: 0; }
.upcoming .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spent { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.spent b { color: var(--text); font: 600 17px/1 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.dash .note { margin-top: 22px; }
.empty-line { color: var(--text-2); font-size: 14px; margin: 0; }

@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .dash-hero { grid-template-columns: 1fr; padding: 22px; }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .dash-head { margin-top: 20px; }
  .dash-head .seg { width: 100%; }
  .dash-head .seg a { flex: 1; text-align: center; }
  .dash-hero { padding: 18px; gap: 24px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 24px; }
  .rot-tiles { gap: 8px; }
  .rot-tile { padding: 10px 12px; }
  .rot-n { font-size: 22px; }
  .dash-empty { flex-direction: column; }
}

/* Read-only view for signed-out visitors: same fields, no editing chrome. */
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain[disabled] input,
fieldset.plain[disabled] select,
fieldset.plain[disabled] textarea {
  opacity: 1; color: var(--text); -webkit-text-fill-color: var(--text);
  background: transparent; border-color: transparent; padding-left: 0; cursor: default; appearance: none;
}
fieldset.plain[disabled] input::placeholder,
fieldset.plain[disabled] textarea::placeholder { color: var(--text-3); -webkit-text-fill-color: var(--text-3); }
fieldset.plain[disabled] input[type="checkbox"] { appearance: auto; }

.sticky-actions { position: sticky; bottom: 0; padding: 12px 0; background: var(--bg); z-index: 2; }
