/* ============================================================
   CKD Health App — © 2026 Mission Surrender
   Responsive, mobile & iPad-first stylesheet
   ============================================================ */

:root {
  --teal-900:#0a4f4e; --teal-700:#0e7c7b; --teal-600:#149392; --teal-50:#e6f4f4;
  --green:#2e9e5b; --green-50:#e8f6ee;
  --amber:#c77b08; --amber-50:#fdf3e2;
  --red:#c43a3a; --red-50:#fbeaea; --red-700:#a32a2a;
  --ink:#13201f; --ink-2:#3f514f; --muted:#6c7b79;
  --line:#dde6e5; --bg:#f4f7f7; --card:#ffffff;
  --shadow:0 1px 2px rgba(16,40,39,.06), 0 8px 24px rgba(16,40,39,.06);
  --radius:16px; --radius-sm:11px;
  --maxw:880px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body {
  margin:0; font-family:var(--font); color:var(--ink); background:var(--bg);
  line-height:1.55; font-size:16px; -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4 { line-height:1.25; margin:0 0 .4em; }
p { margin:0 0 .8em; }
a { color:var(--teal-700); }
button { font-family:inherit; cursor:pointer; }
[hidden] { display:none !important; }

/* ---------- Buttons ---------- */
.btn {
  border:1px solid transparent; border-radius:var(--radius-sm); font-weight:600;
  font-size:1rem; padding:.7em 1.15em; transition:.15s ease; min-height:46px;
  display:inline-flex; align-items:center; justify-content:center; gap:.4em;
  background:#eef2f2; color:var(--ink);
}
.btn:active { transform:translateY(1px); }
.btn--primary { background:var(--teal-700); color:#fff; }
.btn--primary:hover { background:var(--teal-600); }
.btn--primary:disabled { background:#a9c4c3; cursor:not-allowed; }
.btn--ghost { background:transparent; color:var(--teal-700); }
.btn--ghost:hover { background:var(--teal-50); }
.btn--outline { background:#fff; border-color:var(--line); color:var(--ink); }
.btn--outline:hover { border-color:var(--teal-600); color:var(--teal-700); }
.btn--block { width:100%; }
.btn--lg { font-size:1.08rem; padding:.85em 1.4em; min-height:54px; }
.btn--sm { min-height:40px; font-size:.92rem; padding:.5em .85em; }

/* ---------- Disclaimer gate ---------- */
.gate {
  position:fixed; inset:0; z-index:100; background:linear-gradient(160deg,var(--teal-900),var(--teal-700));
  display:flex; align-items:center; justify-content:center; padding:20px;
  padding-top:calc(20px + var(--safe-top)); padding-bottom:calc(20px + var(--safe-bottom));
  overflow:auto;
}
.gate__card {
  background:var(--card); border-radius:var(--radius); box-shadow:var(--shadow);
  max-width:540px; width:100%; padding:28px 24px; text-align:center; margin:auto;
}
.gate__icon { font-size:46px; line-height:1; }
.gate h1 { font-size:1.7rem; margin-top:.2em; color:var(--teal-900); }
.gate__tagline { color:var(--ink-2); margin-bottom:1.1em; }
.gate__notice {
  text-align:left; background:var(--amber-50); border:1px solid #f0dcb6;
  border-radius:var(--radius-sm); padding:14px 16px; margin-bottom:1.1em; font-size:.92rem;
}
.gate__notice strong { color:var(--amber); display:block; margin-bottom:.3em; }
.gate__notice p { margin:0; color:var(--ink-2); }
.gate__check {
  display:flex; gap:.65em; align-items:flex-start; text-align:left;
  font-size:.95rem; margin-bottom:1.1em; cursor:pointer;
}
.gate__check input { width:22px; height:22px; margin-top:1px; flex:none; accent-color:var(--teal-700); }
.gate__copy { font-size:.8rem; color:var(--muted); margin:1.2em 0 0; }

/* ---------- App shell ---------- */
.app { min-height:100vh; display:flex; flex-direction:column; }
.appbar {
  position:sticky; top:0; z-index:30; background:rgba(255,255,255,.92);
  backdrop-filter:saturate(180%) blur(10px); border-bottom:1px solid var(--line);
  padding-top:var(--safe-top);
}
.appbar__inner {
  max-width:var(--maxw); margin:0 auto; padding:10px 16px;
  display:flex; align-items:center; justify-content:space-between; gap:12px;
}
.appbar__brand { display:flex; align-items:center; gap:10px; }
.appbar__logo { font-size:26px; }
.appbar__title { display:block; font-weight:700; color:var(--teal-900); font-size:1.05rem; }
.appbar__sub { display:block; font-size:.72rem; color:var(--muted); }
.mode-toggle { display:flex; background:#eef2f2; border-radius:999px; padding:3px; }
.mode-toggle__btn {
  border:none; background:transparent; padding:.4em .9em; border-radius:999px;
  font-weight:600; font-size:.85rem; color:var(--ink-2);
}
.mode-toggle__btn.is-active { background:#fff; color:var(--teal-700); box-shadow:0 1px 3px rgba(0,0,0,.12); }

.main { flex:1; }
.container { max-width:var(--maxw); margin:0 auto; padding:20px 16px 40px; }

.appfoot {
  border-top:1px solid var(--line); background:#fff; text-align:center;
  padding:18px 16px calc(18px + var(--safe-bottom)); color:var(--muted); font-size:.82rem;
}
.appfoot p { margin:.15em 0; }

/* ---------- Hero ---------- */
.hero { margin-bottom:18px; }
.hero__title { font-size:1.5rem; color:var(--teal-900); }
.hero__text { color:var(--ink-2); max-width:60ch; }

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

/* ---------- Forms ---------- */
.form .fieldset { border:none; margin:0 0 8px; padding:0 0 16px; border-bottom:1px solid var(--line); }
.form .fieldset:last-of-type { border-bottom:none; padding-bottom:0; }
legend { font-weight:700; color:var(--teal-900); font-size:1.02rem; padding:0 0 10px; }
.muted { color:var(--muted); font-weight:400; font-size:.85em; }
.req { color:var(--red); }

.grid { display:grid; gap:14px; }
.grid--2 { grid-template-columns:repeat(2,1fr); }
.grid--3 { grid-template-columns:repeat(3,1fr); }

.field { display:flex; flex-direction:column; gap:6px; }
.field__label { font-size:.88rem; font-weight:600; color:var(--ink-2); }
.field input, .field select, .input-group input, .input-group select {
  width:100%; font-size:16px; padding:.7em .8em; border:1px solid var(--line);
  border-radius:var(--radius-sm); background:#fff; color:var(--ink); min-height:48px;
  -webkit-appearance:none; appearance:none;
}
.field input:focus, .field select:focus, .input-group input:focus {
  outline:none; border-color:var(--teal-600); box-shadow:0 0 0 3px var(--teal-50);
}
select { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236c7b79' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 14px center; padding-right:34px; }

.input-group { display:flex; gap:8px; align-items:stretch; }
.input-group input { flex:1 1 auto; min-width:0; }
/* Keep the unit picker a slim fixed width so the number box stays wide.
   Higher specificity (select + class) beats the generic ".field select { width:100% }". */
.input-group select.input-group__unit { flex:0 0 86px; width:86px; min-width:86px; }
.input-group__unit { flex:none; width:auto; min-width:72px; }
.input-group__unit--static {
  display:flex; align-items:center; padding:0 14px; background:#eef2f2;
  border:1px solid var(--line); border-radius:var(--radius-sm); color:var(--ink-2); font-weight:600;
}
.input-group--bp { align-items:center; }
.input-group--bp input { text-align:center; }
.input-group__slash { color:var(--muted); font-size:1.3rem; font-weight:600; }

.field--check, .chip {
  flex-direction:row; align-items:center; gap:.6em; cursor:pointer;
}
.field--check { padding-top:1.6em; }
.field--check input { width:22px; height:22px; flex:none; accent-color:var(--teal-700); }

.chips { display:flex; flex-direction:column; gap:10px; }
.chip {
  display:flex; align-items:center; gap:.65em; border:1px solid var(--line);
  border-radius:var(--radius-sm); padding:.8em .9em; background:#fff; font-size:.95rem; transition:.12s;
}
.chip:has(input:checked) { border-color:var(--teal-600); background:var(--teal-50); }
.chip input { width:22px; height:22px; flex:none; accent-color:var(--teal-700); }

.form__actions { display:flex; gap:12px; margin-top:18px; flex-wrap:wrap; }
.form__actions .btn--lg { flex:1; min-width:200px; }
.form__note { font-size:.82rem; color:var(--muted); margin-top:14px; text-align:center; }

/* ---------- Results ---------- */
.results-head { display:flex; justify-content:space-between; gap:10px; margin-bottom:16px; flex-wrap:wrap; }

/* Alerts */
.alerts:empty { display:none; }
.alert {
  border-radius:var(--radius); padding:16px 18px; margin-bottom:12px; border:1px solid;
  display:flex; gap:12px; align-items:flex-start; box-shadow:var(--shadow);
}
.alert__icon { font-size:1.4rem; line-height:1.2; flex:none; }
.alert__body { flex:1; }
.alert__title { font-weight:700; margin:0 0 .25em; }
.alert__body p { margin:0; font-size:.92rem; }
.alert--critical { background:var(--red-50); border-color:#eebcbc; color:var(--red-700); }
.alert--critical .alert__title { color:var(--red); }
.alert--high { background:var(--amber-50); border-color:#f0dcb6; color:#8a5806; }
.alert--high .alert__title { color:var(--amber); }
.alert--info { background:var(--teal-50); border-color:#bfe0df; color:var(--teal-900); }

/* Tabs / section nav */
.tabs {
  display:flex; gap:8px; overflow-x:auto; padding:4px 0 12px; margin:0 -16px 8px;
  padding-left:16px; padding-right:16px; -webkit-overflow-scrolling:touch; scrollbar-width:none;
}
.tabs::-webkit-scrollbar { display:none; }
.tab {
  flex:none; border:1px solid var(--line); background:#fff; border-radius:999px;
  padding:.5em 1em; font-weight:600; font-size:.9rem; color:var(--ink-2); white-space:nowrap;
}
.tab.is-active { background:var(--teal-700); border-color:var(--teal-700); color:#fff; }

/* Snapshot stats */
.stat-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; }
.stat {
  background:#fff; border:1px solid var(--line); border-radius:var(--radius-sm);
  padding:14px; text-align:center;
}
.stat__value { font-size:1.5rem; font-weight:700; color:var(--teal-700); line-height:1.1; }
.stat__label { font-size:.82rem; color:var(--muted); margin-top:4px; }
.stat__sub { font-size:.75rem; color:var(--ink-2); margin-top:2px; }
.stat--green .stat__value { color:var(--green); }
.stat--amber .stat__value { color:var(--amber); }
.stat--red .stat__value { color:var(--red); }

.badge {
  display:inline-block; font-size:.78rem; font-weight:700; padding:.2em .7em;
  border-radius:999px; background:var(--teal-50); color:var(--teal-900);
}
.badge--green { background:var(--green-50); color:var(--green); }
.badge--amber { background:var(--amber-50); color:var(--amber); }
.badge--red { background:var(--red-50); color:var(--red-700); }

/* Target rows */
.target-list { display:flex; flex-direction:column; gap:10px; }
.target {
  display:flex; justify-content:space-between; align-items:baseline; gap:12px;
  padding:12px 14px; background:#fbfdfd; border:1px solid var(--line); border-radius:var(--radius-sm);
}
.target__name { font-weight:600; }
.target__why { font-size:.82rem; color:var(--muted); margin-top:2px; }
.target__value { font-weight:700; color:var(--teal-700); text-align:right; white-space:nowrap; }
.target__value small { display:block; font-weight:400; color:var(--muted); font-size:.72rem; }

/* Med cards */
.med { border:1px solid var(--line); border-radius:var(--radius-sm); padding:16px; margin-bottom:12px; background:#fff; }
.med__head { display:flex; justify-content:space-between; align-items:flex-start; gap:10px; margin-bottom:8px; }
.med__name { font-weight:700; color:var(--teal-900); font-size:1.05rem; }
.med__brand { font-size:.82rem; color:var(--muted); }
.med dl { display:grid; grid-template-columns:auto 1fr; gap:6px 14px; margin:10px 0 0; font-size:.92rem; }
.med dt { font-weight:600; color:var(--ink-2); }
.med dd { margin:0; }
.taper { margin-top:12px; }
.taper__row { display:flex; align-items:center; gap:10px; font-size:.88rem; padding:6px 0; border-top:1px dashed var(--line); }
.taper__row:first-child { border-top:none; }
.taper__dot { width:10px; height:10px; border-radius:50%; background:var(--teal-600); flex:none; }

/* Tables */
.table-wrap { overflow-x:auto; margin:0 -4px; -webkit-overflow-scrolling:touch; }
table.data { width:100%; border-collapse:collapse; font-size:.9rem; min-width:520px; }
table.data th, table.data td { text-align:left; padding:10px 12px; border-bottom:1px solid var(--line); vertical-align:top; }
table.data th { background:var(--teal-50); color:var(--teal-900); font-weight:700; position:sticky; top:0; }
table.data tr:last-child td { border-bottom:none; }
table.data .meal-label { font-weight:700; color:var(--teal-700); white-space:nowrap; }

/* Generic content blocks */
.block + .block { margin-top:18px; }
.block h4 { color:var(--teal-900); font-size:1.05rem; }
.list { padding-left:1.2em; margin:0; }
.list li { margin-bottom:.5em; }
.callout {
  border-left:4px solid var(--teal-600); background:var(--teal-50);
  padding:12px 14px; border-radius:0 var(--radius-sm) var(--radius-sm) 0; font-size:.9rem; margin:12px 0;
}
.callout--warn { border-color:var(--amber); background:var(--amber-50); }
.section-title { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.section-title .ico { font-size:1.4rem; }
.section-title h3 { margin:0; color:var(--teal-900); font-size:1.25rem; }
.lede { color:var(--ink-2); }

/* Clinical-only / simple-only visibility */
body[data-mode="simple"] .clinical-only { display:none; }
body[data-mode="clinical"] .simple-only { display:none; }

/* ---------- Food check ---------- */
.food-search { display:flex; gap:8px; margin:6px 0 4px; flex-wrap:wrap; }
.food-search #food-q {
  flex:1; min-width:160px; font-size:16px; padding:.7em .8em; border:1px solid var(--line);
  border-radius:var(--radius-sm); min-height:48px; -webkit-appearance:none;
}
.food-search #food-q:focus { outline:none; border-color:var(--teal-600); box-shadow:0 0 0 3px var(--teal-50); }
.food-search .btn { min-height:48px; }

.food-scanner { margin-top:12px; border:1px solid var(--line); border-radius:var(--radius-sm); padding:12px; background:#fbfdfd; }
.food-scanner__actions { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:10px; }
.food-scanner__actions label.btn { cursor:pointer; }
#food-reader { width:100%; max-width:420px; margin:0 auto; border-radius:var(--radius-sm); overflow:hidden; }
#food-reader:empty { margin:0; }
#food-reader video { width:100% !important; height:auto !important; border-radius:var(--radius-sm); }
.food-reader__tip { font-size:.88rem; color:var(--ink-2); background:#fbfdfd; border:1px dashed var(--line); border-radius:var(--radius-sm); padding:12px 14px; }
.food-scanner__bar { display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }
.food-scanner__bar input {
  flex:1; min-width:140px; font-size:16px; padding:.6em .7em; border:1px solid var(--line);
  border-radius:var(--radius-sm); min-height:44px; -webkit-appearance:none;
}
.food-scanner__hint { font-size:.8rem; color:var(--muted); margin:.6em 0 0; }

.food-status:empty { display:none; }
.food-status { color:var(--teal-700); font-size:.9rem; padding:8px 0; font-weight:600; }

.food-resulthead, .food-suggest { font-size:.9rem; color:var(--ink-2); margin:14px 0 8px; }
.food-group { margin-bottom:14px; }
.food-group__label { font-size:.78rem; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; margin-bottom:6px; }
.food-item {
  display:flex; align-items:center; gap:10px; width:100%; text-align:left; background:#fff;
  border:1px solid var(--line); border-radius:var(--radius-sm); padding:.7em .9em; margin-bottom:8px; transition:.12s;
}
.food-item:hover { border-color:var(--teal-600); background:var(--teal-50); }
.food-item__name { font-weight:600; flex:1; }
.food-item__sub { font-size:.8rem; color:var(--muted); }
.food-item__go { font-size:.85rem; color:var(--teal-700); font-weight:600; white-space:nowrap; }

.food-suggest { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.food-chip {
  border:1px solid var(--line); background:#fff; border-radius:999px; padding:.35em .8em;
  font-size:.85rem; color:var(--teal-700); font-weight:600;
}
.food-chip:hover { background:var(--teal-50); border-color:var(--teal-600); }

.verdict { border:1px solid var(--line); border-left-width:5px; border-radius:var(--radius-sm); padding:16px; margin-top:6px; background:#fff; }
.verdict.v-good { border-left-color:var(--green); background:var(--green-50); }
.verdict.v-mid  { border-left-color:var(--amber); background:var(--amber-50); }
.verdict.v-high { border-left-color:var(--red); background:var(--red-50); }
.verdict__head { display:flex; gap:12px; align-items:center; margin-bottom:10px; }
.verdict__icon { font-size:1.8rem; line-height:1; }
.verdict__title { font-weight:700; font-size:1.1rem; }
.verdict__food { font-size:.92rem; color:var(--ink-2); }
.verdict__list { list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:6px; }
.verdict__list li { font-size:.92rem; display:flex; align-items:baseline; gap:8px; }
.dot { width:10px; height:10px; border-radius:50%; flex:none; display:inline-block; }
.dot--green { background:var(--green); } .dot--amber { background:var(--amber); }
.dot--red { background:var(--red); } .dot--grey { background:#b5c0bf; }
.label-form { border:1px solid var(--line); border-radius:var(--radius-sm); padding:16px; background:#fbfdfd; margin-top:6px; }
.label-form h4 { margin:0 0 4px; color:var(--teal-900); }
.lf-field { display:flex; flex-direction:column; gap:4px; margin:8px 0; }
.lf-field span { font-size:.82rem; font-weight:600; color:var(--ink-2); }
.lf-field input { font-size:16px; padding:.6em .7em; border:1px solid var(--line); border-radius:var(--radius-sm); min-height:44px; -webkit-appearance:none; background:#fff; }
.lf-field input:focus { outline:none; border-color:var(--teal-600); box-shadow:0 0 0 3px var(--teal-50); }
.lf-grid { display:grid; grid-template-columns:1fr 1fr; gap:0 12px; }
@media (max-width:420px){ .lf-grid { grid-template-columns:1fr; } }
.food-datanote { font-size:.82rem; color:var(--ink-2); margin:10px 0 0; }
.food-disc { font-size:.78rem; color:var(--muted); margin:12px 0 0; font-style:italic; }

/* ---------- Daily log / tracker ---------- */
.tracker-head { display:flex; justify-content:space-between; align-items:center; gap:10px; margin:4px 0 14px; flex-wrap:wrap; }
.tracker-date { font-weight:700; color:var(--teal-900); }
.trk-target { margin-bottom:12px; }
.trk-target__top { display:flex; justify-content:space-between; align-items:baseline; gap:10px; }
.trk-target__label { font-weight:600; }
.trk-target__val { font-weight:700; color:var(--ink); font-variant-numeric:tabular-nums; }
.trk-bar { height:10px; background:#eef2f2; border-radius:999px; overflow:hidden; margin:5px 0 3px; }
.trk-bar__fill { height:100%; border-radius:999px; transition:width .3s ease; min-width:2px; }
.trk-bar--green { background:var(--green); }
.trk-bar--amber { background:var(--amber); }
.trk-bar--red { background:var(--red); }
.trk-bar--grey { background:#b5c0bf; }
.trk-target__sub { font-size:.8rem; color:var(--muted); }
.trk-over { color:var(--red-700); font-weight:600; }
.trk-caveat { font-size:.8rem; color:var(--muted); margin:6px 0 14px; line-height:1.45; }

.tracker-listhead { color:var(--teal-900); font-size:1rem; margin:8px 0 10px; }
.trk-empty { color:var(--muted); font-size:.9rem; }
.trk-results { display:flex; flex-direction:column; gap:8px; margin:10px 0; }
.trk-result .food-item__go { color:var(--green); }

.trk-item {
  display:flex; align-items:center; gap:10px; padding:10px 12px; margin-bottom:8px;
  border:1px solid var(--line); border-radius:var(--radius-sm); background:#fff;
}
.trk-item__main { flex:1; min-width:0; }
.trk-item__name { display:block; font-weight:600; }
.trk-item__sub { font-size:.8rem; color:var(--ink-2); font-variant-numeric:tabular-nums; }
.trk-item__serv { display:flex; align-items:center; gap:2px; color:var(--muted); font-size:.85rem; flex:none; }
.trk-serv {
  width:56px; font-size:16px; padding:.4em .3em; text-align:center; border:1px solid var(--line);
  border-radius:8px; min-height:40px; -webkit-appearance:none;
}
.trk-del {
  flex:none; width:38px; height:38px; border:1px solid var(--line); background:#fff;
  border-radius:8px; color:var(--red); font-size:1rem; line-height:1;
}
.trk-del:hover { background:var(--red-50); border-color:#eebcbc; }
.food-add { margin-top:12px; }

/* ---------- Ask / chat ---------- */
.chat-log {
  display:flex; flex-direction:column; gap:10px; max-height:60vh; overflow-y:auto;
  padding:6px 2px; margin-bottom:12px; -webkit-overflow-scrolling:touch;
}
.chat-msg { max-width:88%; padding:11px 14px; border-radius:16px; font-size:.93rem; line-height:1.5; }
.chat-msg p { margin:0 0 .5em; } .chat-msg p:last-child { margin:0; }
.chat-msg .list { margin:.3em 0; }
.chat-msg--user { align-self:flex-end; background:var(--teal-700); color:#fff; border-bottom-right-radius:5px; }
.chat-msg--bot { align-self:flex-start; background:#fff; border:1px solid var(--line); border-bottom-left-radius:5px; }
.chat-msg--bot.is-good { border-left:4px solid var(--green); }
.chat-msg--bot.is-mid { border-left:4px solid var(--amber); }
.chat-msg--bot.is-high { border-left:4px solid var(--red); }
.chat-verdict { font-size:1rem; }
.chat-sub { font-size:.84rem; color:var(--ink-2); font-variant-numeric:tabular-nums; }
.chat-disc { font-size:.76rem; color:var(--muted); font-style:italic; }
.chat-add { margin-top:8px; }
.chat-foods { display:flex; flex-wrap:wrap; gap:6px; margin:6px 0; }
.chat-foodchip { border:1px solid var(--line); background:var(--teal-50); border-radius:999px; padding:.32em .7em; font-size:.85rem; color:var(--teal-700); font-weight:600; }
.chat-foodchip:hover { border-color:var(--teal-600); }
.chat-form { display:flex; gap:8px; }
.chat-form input {
  flex:1; font-size:16px; padding:.7em .85em; border:1px solid var(--line);
  border-radius:var(--radius-sm); min-height:48px; -webkit-appearance:none; background:#fff;
}
.chat-form input:focus { outline:none; border-color:var(--teal-600); box-shadow:0 0 0 3px var(--teal-50); }
.chat-chips { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.chat-chip { border:1px solid var(--line); background:#fff; border-radius:999px; padding:.4em .85em; font-size:.85rem; color:var(--teal-700); font-weight:600; }
.chat-chip:hover { background:var(--teal-50); border-color:var(--teal-600); }

/* Weekly trend mini-charts */
.wk-chart { margin-bottom:16px; }
.wk-top { display:flex; justify-content:space-between; align-items:baseline; gap:10px; margin-bottom:6px; }
.wk-label { font-weight:600; }
.wk-sub { font-size:.78rem; color:var(--muted); font-variant-numeric:tabular-nums; text-align:right; }
.wk-bars {
  position:relative; display:flex; align-items:flex-end; gap:6px; height:72px;
  padding:0 2px; border-bottom:1px solid var(--line);
}
.wk-bar { flex:1; border-radius:4px 4px 0 0; min-height:0; transition:height .3s ease; }
.wk-bar--green { background:var(--green); }
.wk-bar--red { background:var(--red); }
.wk-bar--empty { background:repeating-linear-gradient(45deg,#eef2f2,#eef2f2 3px,#fff 3px,#fff 6px); }
.wk-bar.is-today { outline:2px solid var(--teal-700); outline-offset:1px; }
.wk-targetline { position:absolute; left:0; right:0; border-top:2px dashed var(--amber); opacity:.8; pointer-events:none; }
.wk-labels { display:flex; gap:6px; margin-top:4px; padding:0 2px; }
.wk-dlabel { flex:1; text-align:center; font-size:.72rem; color:var(--muted); }
.wk-dlabel.is-today { color:var(--teal-700); font-weight:700; }
.wk-nav { display:flex; align-items:center; justify-content:center; gap:14px; margin-bottom:14px; }
.wk-navbtn { border:1px solid var(--line); background:#fff; border-radius:8px; width:38px; height:38px; font-size:.9rem; color:var(--teal-700); }
.wk-navbtn:disabled { opacity:.35; }
.wk-range { font-weight:600; color:var(--ink); font-variant-numeric:tabular-nums; min-width:140px; text-align:center; }
.tracker-head__btns { display:flex; gap:8px; flex-wrap:wrap; }

/* Weekly report overlay */
#report-overlay {
  position:fixed; inset:0; z-index:60; background:var(--bg); overflow:auto;
  padding:0 0 calc(24px + var(--safe-bottom));
}
.report-toolbar {
  position:sticky; top:0; z-index:2; display:flex; gap:8px; justify-content:flex-end;
  padding:12px 16px; padding-top:calc(12px + var(--safe-top));
  background:rgba(255,255,255,.95); backdrop-filter:saturate(180%) blur(8px); border-bottom:1px solid var(--line);
}
#report-body { max-width:760px; margin:0 auto; padding:20px 16px; }
.report { background:#fff; border:1px solid var(--line); border-radius:var(--radius); padding:24px; box-shadow:var(--shadow); }
.report__head { border-bottom:2px solid var(--teal-700); padding-bottom:12px; margin-bottom:16px; }
.report__brand { font-weight:700; color:var(--teal-700); font-size:.9rem; }
.report h2 { color:var(--teal-900); margin:.2em 0 .1em; font-size:1.45rem; }
.report__range { color:var(--muted); font-size:.9rem; margin:0; }
.report h3 { color:var(--teal-900); font-size:1.05rem; margin:18px 0 8px; }
.report__tblwrap { overflow-x:auto; -webkit-overflow-scrolling:touch; margin:0 -2px; }
.report__tbl { width:100%; border-collapse:collapse; font-size:.9rem; }
.report__tbl--days { min-width:420px; }
.report__tbl th, .report__tbl td { border:1px solid var(--line); padding:7px 10px; text-align:left; }
.report__tbl--kv th { width:34%; background:var(--teal-50); color:var(--teal-900); }
.report__tbl--days th { background:var(--teal-50); color:var(--teal-900); }
.report__tbl--days td { text-align:center; font-variant-numeric:tabular-nums; }
.report__tbl--days td:first-child { text-align:left; }
.rep-over { color:var(--red-700); font-weight:700; background:var(--red-50); }
.rep-avg th, .rep-avg td { background:#f4f7f7; font-weight:700; }
.rep-empty td { color:var(--muted); font-style:italic; text-align:center; }
.report__targets { font-size:.85rem; color:var(--ink-2); margin:0 0 8px; }
.report__note { font-size:.78rem; color:var(--muted); margin:8px 0 0; }
.rep-detail { display:grid; grid-template-columns:1fr 1fr; gap:10px 18px; }
.rep-day h4 { margin:6px 0 2px; color:var(--teal-700); font-size:.9rem; }
.rep-day ul { margin:0; padding-left:1.1em; font-size:.85rem; }
.report__disc { font-size:.8rem; color:var(--ink-2); background:var(--amber-50); border:1px solid #f0dcb6; border-radius:var(--radius-sm); padding:10px 12px; margin-top:18px; }
.report__copy { text-align:center; color:var(--muted); font-size:.78rem; margin:14px 0 0; }
@media (max-width:540px){ .rep-detail { grid-template-columns:1fr; } }

.disclaimer-foot { background:var(--amber-50); border-color:#f0dcb6; }
.disclaimer-foot h3 { color:var(--amber); font-size:1.05rem; }
.disclaimer-foot p { margin:0; font-size:.9rem; color:var(--ink-2); }

/* ---------- Responsive ---------- */
@media (max-width:560px) {
  .grid--2, .grid--3 { grid-template-columns:1fr; }
  .hero__title { font-size:1.3rem; }
  .appbar__sub { display:none; }
  .results-head .btn { flex:1; }
}

/* iPad / tablet: two-column dashboard feel */
@media (min-width:760px) {
  .container { padding:28px 24px 56px; }
  .results-two-col { display:grid; grid-template-columns:1fr 1fr; gap:18px; align-items:start; }
  .results-two-col > .card { margin-bottom:0; }
}

/* ---------- Print ---------- */
@media print {
  .appbar, .appfoot, .tabs, .results-head, .mode-toggle, .gate { display:none !important; }
  body { background:#fff; }
  .card { box-shadow:none; border:1px solid #ccc; break-inside:avoid; }
  .clinical-only, .simple-only { display:block !important; }
  #results-content > * { display:block !important; }
}
/* When the weekly report is open, print ONLY the report. */
@media print {
  body.report-open > *:not(#report-overlay) { display:none !important; }
  body.report-open #report-overlay { position:static !important; overflow:visible !important; background:#fff !important; padding:0 !important; }
  body.report-open .report-toolbar { display:none !important; }
  body.report-open #report-body { max-width:none; padding:0; }
  body.report-open .report { border:none; box-shadow:none; padding:0; }
  .rep-over { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}
