/* Медкарта: calm clinical palette. Colour carries meaning only:
   amber = check / out of range, green = done / within range, red = error. */
:root {
  --bg: #edf0ec; --surface: #ffffff; --surface-2: #ffffff8c; --line: #ffffffb3; --hair: #1d2b2414;
  --text: #19231f; --muted: #66726d; --navy: #121a16; --accent: #2f6b52; --mint: #ffffffa6;
  --ok: #2f7a55; --ok-bg: #dff0e4cc; --warn: #94531c; --warn-bg: #fbe4d2cc; --warn-line: #e9a46b;
  --error: #a33a2c; --error-bg: #f9e0dbcc; --busy: #33598c; --busy-bg: #dfe9f6cc; --ai: #4f4598; --ai-bg: #ebe8fbd9;
  --radius: 26px; --shadow: 0 10px 40px #20352c12, inset 0 1px 0 #ffffffb3; --glass: #ffffff8f; --blur: blur(22px) saturate(1.4);
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text); background: var(--bg); font-synthesis: none; -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
/* The page background lives on <html>, so no margin can leave an unpainted band. */
html:root { min-height: 100%; background:
  radial-gradient(55% 45% at 8% 0%, #c9e2c2 0, transparent 70%),
  radial-gradient(50% 40% at 100% 8%, #c4dcf1 0, transparent 70%),
  radial-gradient(55% 45% at 90% 100%, #f2d6c2 0, transparent 70%),
  radial-gradient(45% 40% at 0% 100%, #d8e8c4 0, transparent 70%), var(--bg); background-attachment: fixed; }
body { margin: 0; min-height: 100vh; background: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid #d39a52; outline-offset: 2px; }
button:disabled { opacity: .55; cursor: not-allowed; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 20px; height: 20px; flex-shrink: 0; }
h1 { font-size: 30px; line-height: 1.2; letter-spacing: -.8px; margin: 0 0 6px; font-weight: 680; overflow-wrap: anywhere; }
h2 { font-size: 19px; letter-spacing: -.3px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 15px; margin: 0 0 6px; font-weight: 640; }
h4 { font-size: 14px; margin: 0; font-weight: 620; overflow-wrap: anywhere; }
p { line-height: 1.6; margin: 0 0 10px; }
.lead { color: var(--muted); font-size: 14px; margin: 0; }
.small { font-size: 12px; color: var(--muted); line-height: 1.6; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 8px; }
.center { text-align: center; justify-content: center; }
code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* Layout ------------------------------------------------------------------- */
.shell { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 30px 18px; display: flex; flex-direction: column; gap: 28px; border-right: 1px solid #ffffffb0; background: #ffffff55; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 720; letter-spacing: -.8px; color: #33484a; }
.brand b { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: #fff; color: #6f9d97; font-size: 26px; font-weight: 400; box-shadow: var(--shadow); }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav button { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px; border: 0; border-radius: 14px; background: none; color: #6c767c; font-size: 14px; text-align: left; }
.nav button:hover { background: #ffffffaa; color: var(--navy); }
.nav button.active { background: #fff; color: var(--navy); font-weight: 650; box-shadow: var(--shadow); }
.nav .nav-add { order: -1; margin-bottom: 12px; background: var(--navy); color: #fff; font-weight: 600; justify-content: center; }
.nav .nav-add:hover { background: #1b2840; color: #fff; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: #ecd8c8; color: #7f5b42; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.topbar { display: none; }
.main { padding: 34px 44px 80px; min-width: 0; max-width: 920px; }
.demo-note { font-size: 11px; letter-spacing: .4px; color: #6d8580; background: #e3eeea; display: block; width: fit-content; padding: 5px 10px; border-radius: 99px; margin: 0 0 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head .button { flex-shrink: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--accent); font-size: 14px; padding: 8px 8px 8px 0; margin-bottom: 8px; }
.back .ic { width: 18px; height: 18px; }
.offline { background: #f5e6d5; padding: 10px; text-align: center; font-size: 13px; }
.loading { padding: 80px; text-align: center; color: var(--muted); }

/* Surfaces ----------------------------------------------------------------- */
.card { background: #ffffffe6; border: 1px solid #fff; border-radius: var(--radius); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 12px; }
.section-head h2 { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14px; }
.empty .actions { margin-top: 14px; }
.disclaimer { font-size: 12px; color: var(--muted); text-align: center; margin: 18px 8px; }
.notice { border-left: 3px solid var(--warn-line); background: #fff8ea; color: #7b6243; padding: 12px 16px; border-radius: 0 12px 12px 0; font-size: 13px; margin: 14px 0; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.quiet > summary, .quiet-card > summary, .more > summary { color: var(--accent); font-size: 13px; font-weight: 550; padding: 6px 0; }
details.quiet > summary::before, .quiet-card > summary::before, .more > summary::before { content: '›'; display: inline-block; margin-right: 8px; transition: transform .15s; }
details[open].quiet > summary::before, details[open].quiet-card > summary::before, details[open].more > summary::before { transform: rotate(90deg); }
details.quiet { margin: 10px 0; }
.quiet-card, .more { padding: 16px 22px; }
.more[open] > summary { margin-bottom: 12px; }
.source { font-family: ui-monospace, Menlo, monospace; font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; background: var(--surface-2); padding: 12px; border-radius: 12px; color: #4b6057; }
.row-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
.row-line:last-child { border-bottom: 0; }
.row-line small { color: var(--muted); }

/* Controls ----------------------------------------------------------------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border: 1px solid transparent; border-radius: 14px; background: var(--navy); color: #fff; font-size: 14px; font-weight: 600; text-decoration: none; line-height: 1.2; text-align: center; }
.button:hover { filter: brightness(1.08); }
.button.secondary { background: var(--mint); color: #2f5a54; }
.button.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.button.danger { background: var(--error-bg); color: var(--error); }
.button.wide { width: 100%; }
.small-button { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 11px; }
.button .ic { width: 18px; height: 18px; }
.linkbutton { border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 550; padding: 8px 4px; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.linkbutton:hover { text-decoration: underline; }
.linkbutton .ic { width: 16px; height: 16px; }
.danger-link { color: var(--error); padding-left: 0; }
.icon-button { border: 0; background: var(--surface-2); color: var(--muted); width: 36px; height: 36px; border-radius: 10px; font-size: 20px; line-height: 1; flex-shrink: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
label { display: block; font-size: 13px; font-weight: 550; color: #56636a; margin: 12px 0 0; }
label > input, label > select, label > textarea { margin-top: 6px; }
input, select, textarea { width: 100%; min-width: 0; min-height: 46px; padding: 11px 13px; border: 1px solid #dfe6e2; border-radius: 12px; background: #f8faf8; color: var(--text); font-size: 15px; }
input:focus, select:focus, textarea:focus { border-color: #9fbdb4; background: #fff; outline: none; box-shadow: 0 0 0 3px #a5c8c533; }
textarea { min-height: 96px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 13px; line-height: 1.55; color: #5d6a70; margin: 14px 0 0; }
.check input { margin-top: 1px; }
.check.inline { margin: 0 0 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--error); font-size: 13px; margin: 10px 0 0; }
.form-error:empty { display: none; }
.hint { font-size: 13px; margin: 8px 0 0; }
.warn-text { color: var(--warn); }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.inline-form input { flex: 1 1 200px; }
.inline-form .form-error { flex-basis: 100%; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend { font-size: 13px; font-weight: 600; color: #56636a; padding: 0; margin-bottom: 8px; }

/* Segmented radio groups and filter chips */
.segmented { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.segmented.wrap { flex-wrap: wrap; background: none; padding: 0; gap: 8px; }
.segmented label { flex: 1; margin: 0; }
.segmented.wrap label { flex: 0 0 auto; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 12px; border-radius: 11px; font-size: 13px; font-weight: 550; color: #5c6a6f; cursor: pointer; text-align: center; }
.segmented.wrap span { background: var(--surface-2); border: 1px solid transparent; }
.segmented input:checked + span { background: #fff; color: var(--navy); box-shadow: 0 2px 8px #24334f14; border-color: #d5e2dc; }
.segmented input:focus-visible + span { outline: 3px solid #d39a52; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.filter { flex-shrink: 0; border: 1px solid var(--line); background: #ffffffb8; border-radius: 99px; min-height: 38px; padding: 0 14px; font-size: 13px; color: #59666c; }
.filter b { font-weight: 650; margin-left: 4px; color: var(--muted); }
.filter.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.filter.active b { color: #c9d4e8; }
.tabs { display: flex; gap: 4px; background: #ffffffa8; padding: 4px; border-radius: 14px; margin-bottom: 16px; overflow-x: auto; }
.tabs button { flex: 1; border: 0; background: none; min-height: 40px; border-radius: 11px; font-size: 14px; color: var(--muted); white-space: nowrap; padding: 0 12px; }
.tabs button.active { background: #fff; color: var(--navy); font-weight: 650; box-shadow: 0 2px 8px #24334f12; }

/* Status chips: one vocabulary everywhere */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 8px; background: var(--surface-2); color: #5b6c66; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.error { background: var(--error-bg); color: var(--error); }
.chip.busy { background: var(--busy-bg); color: var(--busy); }
.chip.muted { background: #eef0f0; color: #69757b; }
.spinner { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; vertical-align: -1px; }
.spinner.big { width: 34px; height: 34px; border-width: 3px; color: var(--busy); margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Home --------------------------------------------------------------------- */
.tasks { display: grid; gap: 12px; margin-bottom: 18px; }
.task { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-radius: var(--radius); border: 1px solid transparent; }
.task h2 { font-size: 17px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.task p { font-size: 13px; margin: 0; color: #6a6355; }
.task .button { flex-shrink: 0; }
.task.warn { background: var(--warn-bg); border-color: #f3dcae; }
.task.busy { background: var(--busy-bg); }
.task.busy p { color: #4d6380; }
.task.error { background: var(--error-bg); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.quick-item { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 18px; border-radius: var(--radius); border: 1px solid #fff; background: #ffffffd9; box-shadow: var(--shadow); text-align: left; font-size: 14px; font-weight: 600; color: var(--navy); min-height: 104px; }
.quick-item .ic { width: 26px; height: 26px; color: var(--accent); }
.quick-item:first-child { background: var(--navy); color: #fff; }
.quick-item:first-child .ic { color: #b7d6d0; }
.start { padding: 28px; }
.how { padding: 0; margin: 14px 0 20px; list-style: none; counter-reset: how; display: grid; gap: 12px; }
.how li { counter-increment: how; display: flex; align-items: center; gap: 12px; font-size: 15px; }
.how li::before { content: counter(how); width: 30px; height: 30px; border-radius: 50%; background: var(--mint); color: #2f5a54; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }

/* Tiles: latest value per indicator */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: #fbfcfb; min-height: 104px; }
.tile:hover { border-color: #c9dad3; }
.tile-name { font-size: 13px; color: #56636a; font-weight: 550; overflow-wrap: anywhere; }
.tile strong { font-size: 22px; font-weight: 650; letter-spacing: -.4px; color: var(--navy); }
.tile strong small { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.tile-meta { font-size: 12px; color: var(--muted); margin-top: auto; }
.tile.tone-warn { background: #fffaf0; border-color: #f2ddb4; }
.trend { font-style: normal; font-size: 15px; color: var(--muted); margin-left: 4px; }

/* Documents ---------------------------------------------------------------- */
.list-card { padding: 6px 12px; }
.doc-list .doc-row:last-child, .list-card .doc-row:last-child { border-bottom: 0; }
.doc-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 8px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; border-radius: 0; }
.doc-row:hover { background: #f8faf9; }
.doc-icon { width: 40px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, #edf4ee, #dcebe4); color: #6f978b; flex-shrink: 0; }
.doc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.doc-text strong { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.doc-text small { font-size: 12px; color: var(--muted); }
.doc-text .chip { align-self: flex-start; margin-top: 4px; }
.chev { color: #a7b2b0; display: flex; }
.chev .ic { width: 18px; height: 18px; }
#search { margin-bottom: 12px; }

/* One document */
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.stepper { display: flex; list-style: none; padding: 0; margin: 0 0 18px; gap: 4px; }
.stepper li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: #9aa4a8; text-align: center; position: relative; }
.stepper li::before { content: ''; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: #e1e7e4; z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper li.done::before, .stepper li.current::before { background: #9cc5b3; }
.stepper li > span, .stepper li > .ic { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #eef1ef; color: #8c979b; font-weight: 700; font-size: 12px; padding: 0; }
.stepper li.done { color: var(--ok); }
.stepper li.done > .ic { background: var(--ok); color: #fff; padding: 6px; }
.stepper li.current { color: var(--navy); font-weight: 650; }
.stepper li.current > span { background: var(--navy); color: #fff; }
.status-card { text-align: center; padding: 34px 22px; }
.status-card.error h2 { color: var(--error); }
.status-card .actions { margin-top: 12px; }
.actions.center { justify-content: center; }
.review-intro { background: #fff8ea; border-color: #f5e3bf; }
.review-intro p { font-size: 14px; color: #6f5d43; }
.warnings summary { font-size: 14px; font-weight: 600; color: var(--warn); display: flex; align-items: center; gap: 8px; }
.warnings ul { margin: 12px 0 0; padding-left: 18px; font-size: 12px; color: #6f6656; line-height: 1.6; max-height: 260px; overflow: auto; }
.ai-draft summary { font-size: 14px; font-weight: 600; color: var(--ai); display: flex; align-items: center; gap: 8px; }
.rows-title { margin: 22px 0 8px; display: flex; align-items: baseline; gap: 6px; }
.lab-row { border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin: 0 0 10px; background: #fbfcfb; }
.lab-row-head { display: flex; gap: 8px; align-items: center; }
.lab-row-head select { font-weight: 600; background: #fff; }
.lab-row-head strong { flex: 1; font-size: 14px; padding: 4px 2px; }
.lab-grid { display: grid; grid-template-columns: 1.3fr 1fr .9fr .9fr; gap: 8px; }
.lab-grid.text { grid-template-columns: 2fr 1fr; }
.lab-grid label { font-size: 11px; margin-top: 8px; color: var(--muted); }
.lab-grid input, .lab-grid select { min-height: 42px; padding: 8px 10px; font-size: 15px; }
.lab-source { font-size: 12px; color: #6d6a5f; background: #f6f3ec; border-radius: 8px; padding: 6px 9px; margin: 10px 0 0; overflow-wrap: anywhere; font-family: ui-monospace, Menlo, monospace; }
.lab-row details.quiet { margin: 6px 0 0; }
.lab-row details.quiet > summary { font-size: 12px; }
.submit-bar { position: sticky; bottom: 0; z-index: 5; background: #fffffff2; border-top: 1px solid var(--line); margin: 18px -22px -22px; padding: 14px 22px 18px; border-radius: 0 0 var(--radius) var(--radius); backdrop-filter: blur(10px); }
.submit-bar.card { margin: 0 0 16px; border-radius: var(--radius); }
.submit-bar .actions { flex-wrap: nowrap; }
.submit-bar .actions .button.wide { flex: 1; }

/* Confirmed results and explanation */
.next-up .button { white-space: nowrap; }
.explain-after { background: var(--ai-bg); border-radius: 14px; padding: 12px; margin-top: 16px; color: #463b6b; }
.explain-after span { display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.explain-after small { font-weight: 400; font-size: 12px; color: #6b6290; }
.consent-card { margin: 0 0 12px; padding: 14px 18px; }
.next-up { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--warn-bg); border-radius: 16px; padding: 10px 10px 10px 16px; margin-bottom: 14px; font-size: 14px; color: var(--warn); font-weight: 550; }
.summary-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.summary { border-radius: 16px; padding: 14px; background: #fff; border: 1px solid #fff; box-shadow: var(--shadow); }
.summary strong { display: block; font-size: 28px; font-weight: 700; letter-spacing: -.03em; }
.summary span { font-size: 12px; color: var(--muted); }
.summary.warn { background: var(--warn-bg); }
.summary.warn strong { color: var(--warn); }
.summary.ok { background: var(--ok-bg); }
.summary.ok strong { color: var(--ok); }
.summary.muted strong { color: #6b777c; }
.ai-card { border: 1px solid #e3dcf3; background: linear-gradient(180deg, #faf8ff, #fff); }
.ai-card.answer { border-radius: 16px; padding: 16px; margin-top: 14px; }
.ai-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ai-head h2, .ai-head h3 { margin: 0; }
.ai-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--ai); background: var(--ai-bg); border-radius: 8px; padding: 4px 8px; }
.ai-badge .ic { width: 14px; height: 14px; }
.ai-summary { font-size: 15px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.result-group { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.result-group:first-of-type { border-top: 0; }
.result-group > summary { padding: 6px 0 10px; }
.result-group > summary h3 { margin: 0; display: inline-flex; gap: 8px; align-items: center; }
.result-group > summary h3 span { font-size: 12px; background: var(--surface-2); color: var(--muted); border-radius: 99px; padding: 2px 8px; font-weight: 600; }
.result-group > summary small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.result-group > summary h3::after { content: '⌄'; color: #a3adaf; font-weight: 400; }
.result-group[open] > summary h3::after { content: '⌃'; }
.result { border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; background: #fff; }
.result.tone-warn { border-color: #f0d7a6; background: #fffbf3; }
.result-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.result-value { margin: 6px 0 4px; color: var(--muted); font-size: 13px; }
.result-value strong { font-size: 24px; color: var(--navy); font-weight: 650; letter-spacing: -.4px; }
.result-ai { margin: 10px 0 0; padding: 10px 12px; background: var(--ai-bg); border-radius: 12px; font-size: 13px; line-height: 1.6; color: #463b6b; }
.ai-tag { font-size: 10px; font-weight: 800; letter-spacing: .5px; color: var(--ai); background: #fff; border-radius: 6px; padding: 2px 6px; margin-right: 8px; }
.range { display: block; width: 100%; height: 12px; margin: 6px 0 6px; }
.range-track { fill: #e9edeb; }
.range-norm { fill: #a9d3bf; }
.range-dot { fill: var(--navy); stroke: #fff; stroke-width: 1.2; }
.tone-warn .range-dot { fill: #c98a1c; }
.questions ol { padding-left: 22px; margin: 10px 0 16px; }
.questions li { padding: 6px 0; line-height: 1.55; font-size: 15px; }
.big-value { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.big-value strong { font-size: 34px; color: var(--navy); letter-spacing: -1px; }

/* Charts and tables */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 11px; fill: #7c878b; }
.chart .plotline { fill: none; stroke: #5f9d8b; stroke-width: 2.5; stroke-linejoin: round; }
.chart circle { fill: #fff; stroke: #5f9d8b; stroke-width: 2.5; }
.chart circle.out { stroke: #c98a1c; fill: #fff3dc; }
.chart .axis { stroke: #e2e8e5; }
.chart .norm-band { fill: #e3f1ea; }
.chart .event-line { stroke: #c6905e; stroke-dasharray: 4 4; stroke-width: 1.5; }
.legend { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.sw { display: inline-block; width: 14px; height: 8px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.sw.norm { background: #cfe8dc; }
.sw.event { background: #e6c3a1; }
.chart-events { border-left: 3px solid #d9b089; padding-left: 10px; margin-top: 10px; }
.chart-events .linkbutton { display: block; text-align: left; padding: 4px 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: 12px; }

/* Add sheet --------------------------------------------------------------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 80; background: #1d283a55; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s; }
.sheet { width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow: auto; background: #fff; border-radius: 26px; padding: 22px; box-shadow: 0 20px 60px #1d283a33; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; }
.dropzone { border: 2px dashed #b9d2c8; background: #f4f9f6; border-radius: 20px; padding: 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dropzone > .ic { width: 34px; height: 34px; color: var(--accent); }
.dropzone p { margin: 0; }
.dropzone .button { min-width: 200px; margin: 6px 0; }
.dropzone.over { border-color: var(--accent); background: #e7f3ee; }
.dropzone.busy .button { opacity: .5; pointer-events: none; }
.sheet-or { display: flex; align-items: center; gap: 12px; color: #9aa4a8; font-size: 12px; margin: 18px 0 12px; }
.sheet-or::before, .sheet-or::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.sheet-options { display: grid; gap: 8px; }
.option { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: #fbfcfb; text-align: left; }
.option:hover { border-color: #c4d7cf; }
.option .ic { width: 24px; height: 24px; color: var(--accent); }
.option span { display: flex; flex-direction: column; gap: 2px; }
.option strong { font-size: 14px; }
.option small { font-size: 12px; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }

/* Reports and sharing */
.report-card .report-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.report-card .report-top h3 { font-size: 17px; }
.share-form { margin-top: 16px; padding: 16px; border-radius: 16px; background: var(--surface-2); }
.share-result { margin-top: 16px; padding: 16px; border-radius: 16px; background: var(--ok-bg); display: flex; gap: 16px; align-items: flex-start; }
.share-result .qr { width: 132px; height: 132px; border-radius: 12px; background: #fff; flex-shrink: 0; }
.share-result .code b { font-size: 20px; letter-spacing: 2px; font-family: ui-monospace, Menlo, monospace; }
.links { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.report-doc { border-top: 1px solid var(--line); padding: 12px 0; }
.report-doc p { white-space: pre-wrap; font-size: 13px; }

/* Profile */
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.preset { display: inline-flex; align-items: center; gap: 2px; }
.preset .icon-button { width: 30px; height: 30px; font-size: 16px; }
.picker-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 12px 0; font-size: 13px; flex-wrap: wrap; }
.picker { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: 16px; padding: 4px 14px; background: #fbfcfb; }
.picker fieldset { border-bottom: 1px solid var(--line); padding: 12px 0; margin: 0; }
.picker fieldset:last-child { border-bottom: 0; }
.picker legend { float: left; width: 100%; margin-bottom: 8px; }
.picker legend small { color: var(--muted); font-weight: 500; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 12px; clear: both; }
.pick-grid.tight { max-height: 220px; overflow: auto; }
.pick { display: flex; align-items: center; gap: 10px; margin: 0; padding: 7px 0; font-weight: 450; font-size: 14px; color: var(--text); }
.pick small { color: var(--muted); font-size: 12px; }
.event-row { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.event-row:last-child { border-bottom: 0; }
.event-row strong { font-size: 15px; }
.event-row small { font-size: 12px; color: var(--muted); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 100; max-width: min(92vw, 460px); background: var(--navy); color: #fff; border-radius: 14px; padding: 12px 18px; font-size: 14px; line-height: 1.5; box-shadow: 0 8px 26px #1d283a33; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Sign-in and doctor's view */
.login { max-width: 460px; margin: 7vh auto; padding: 24px; }
.login .brand { margin-bottom: 28px; }
.login h1 { font-size: 30px; margin-bottom: 20px; }
.login .card { padding: 24px; }
.login .linkbutton { display: block; width: 100%; margin-top: 10px; }
.login .button { margin-top: 16px; }
.shared { max-width: 820px; margin: 0 auto; padding: 32px 20px 60px; }
.shared .brand { margin-bottom: 26px; }
.shared > .button { margin-bottom: 16px; }

/* Desktop extras */
@media (min-width: 621px) {
  .sheet-options { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .main { padding: 28px 26px 80px; }
  .lab-grid { grid-template-columns: 1fr 1fr; }
}

/* Phone ------------------------------------------------------------------- */
@media (max-width: 620px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 0; background: none; border: 0; display: contents; }
  .sidebar > .brand, .side-foot { display: none; }
  .topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 0; }
  .topbar .brand { font-size: 19px; }
  .topbar .brand b { width: 32px; height: 32px; font-size: 22px; }
  .avatar-button { display: flex; align-items: center; gap: 8px; border: 0; background: #ffffffc0; border-radius: 99px; padding: 4px 12px 4px 4px; font-size: 13px; color: #56636a; }
  .main { padding: 16px 16px 120px; }
  .nav { position: fixed; z-index: 50; left: 10px; right: 10px; bottom: 10px; flex-direction: row; justify-content: space-between; align-items: center; gap: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: #ffffffee; border: 1px solid #fff; border-radius: 24px; box-shadow: 0 8px 28px #2c3e3a1f; backdrop-filter: blur(16px); }
  .nav button { flex: 1; flex-direction: column; justify-content: center; gap: 3px; min-height: 52px; padding: 4px 0; font-size: 10.5px; border-radius: 16px; min-width: 0; text-align: center; }
  .nav button.active { box-shadow: none; background: #eef3f0; }
  .nav .nav-profile { display: none; }
  .nav .nav-add { order: 0; flex: 0 0 58px; height: 52px; margin: 0 4px; border-radius: 18px; }
  .nav .nav-add span { display: none; }
  .nav .nav-add .ic { width: 26px; height: 26px; }
  .nav button[data-nav=home] { order: -2; }
  .nav button[data-nav=docs] { order: -1; }
  .nav button[data-nav=labs] { order: 1; }
  .nav button[data-nav=reports] { order: 2; }
  h1 { font-size: 26px; }
  .page-head { flex-direction: column; gap: 12px; margin-bottom: 18px; }
  .page-head .button { width: 100%; }
  .card { padding: 18px; border-radius: 18px; }
  .quiet-card, .more { padding: 14px 18px; }
  .quick { grid-template-columns: 1fr 1fr; }
  .quick-item { min-height: 92px; padding: 14px; font-size: 13px; }
  .quick-item:first-child { grid-column: span 2; flex-direction: row; align-items: center; min-height: 64px; font-size: 15px; }
  .task { flex-direction: column; align-items: stretch; }
  .task .button { width: 100%; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile strong { font-size: 19px; }
  .grid2 { gap: 10px; }
  .lab-grid { grid-template-columns: 1fr 1fr; }
  .submit-bar { margin: 18px -18px -18px; padding: 12px 18px 16px; bottom: 76px; }
  .submit-bar.card { bottom: 76px; }
  .summary { padding: 12px 10px; }
  .summary strong { font-size: 22px; }
  .summary span { font-size: 11px; }
  .share-result { flex-direction: column; align-items: center; text-align: center; }
  .share-result .actions { justify-content: center; }
  .segmented span { font-size: 12px; padding: 0 6px; }
  .doc-head { flex-direction: column; gap: 8px; }
  .sheet-backdrop { align-items: flex-end; padding: 0; }
  .sheet { border-radius: 26px 26px 0 0; max-height: 92vh; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); animation: rise .2s ease-out; }
  #toast { bottom: 92px; }
  .stepper li { font-size: 10px; }
  .login { margin: 2vh auto; }
}
@keyframes rise { from { transform: translateY(40px); } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* ── XSOMA theme: glass surfaces, system (SF-style) type, soft glowing gradients ── */
h1, h2, h3, .wordmark { font-family: var(--display); }
h1 { font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.035em; }
h2 { font-size: 21px; font-weight: 650; letter-spacing: -.02em; }
h3 { letter-spacing: -.01em; }
.brand { gap: 10px; font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: .18em; color: var(--navy); }
.brand img { width: 34px; height: 34px; display: block; filter: drop-shadow(0 4px 10px #2c5a3e33); }
.eyebrow { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; margin: 0 0 14px; }

/* Glass */
.card, .quick-item, .summary, .sheet, .tabs, .filter, .doc-row:hover, .avatar-button { -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.card { background: var(--glass); border: 1px solid var(--line); box-shadow: var(--shadow); }
.sidebar { background: #ffffff38; border-right: 1px solid #ffffff80; -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.list-card .doc-row, .event-row, .row-line { border-color: var(--hair); }
.doc-icon { background: linear-gradient(140deg, #ffffffd9, #dbeadf); color: #4d7f68; border-radius: 14px; }
input, select, textarea { background: #ffffffa6; border-color: #ffffffd9; box-shadow: inset 0 1px 2px #20352c0d; border-radius: 16px; }
input:focus, select:focus, textarea:focus { background: #fff; border-color: #9cc3ad; box-shadow: 0 0 0 4px #9cc3ad33; }

/* Pills everywhere */
.button { border-radius: 999px; min-height: 48px; padding: 0 22px; background: var(--navy); box-shadow: 0 8px 20px #121a1626; }
.button.secondary { background: #ffffffb3; color: var(--navy); border: 1px solid #fff; box-shadow: 0 4px 14px #20352c0f; }
.button.ghost { background: #ffffff4d; border-color: #ffffffcc; color: var(--navy); box-shadow: none; }
.button.danger { background: #f9e0dbcc; box-shadow: none; }
.small-button { min-height: 36px; padding: 0 14px; }
.chip { border-radius: 999px; padding: 4px 10px; font-weight: 600; background: #ffffff9e; }
.filter { border-color: #ffffffcc; background: #ffffff73; }
.filter.active { background: var(--navy); border-color: var(--navy); }
.icon-button { background: #ffffffa6; border-radius: 999px; }
.tabs { background: #ffffff59; border: 1px solid #ffffffb3; border-radius: 999px; }
.tabs button { border-radius: 999px; }
.segmented { background: #ffffff59; border: 1px solid #ffffffb3; border-radius: 999px; }
.segmented span { border-radius: 999px; }
.segmented.wrap { border: 0; background: none; }
.segmented.wrap span { background: #ffffff59; border: 1px solid #ffffffd9; min-height: 42px; padding: 0 16px; }
.segmented input:checked + span { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: 0 6px 16px #121a1626; }
.segmented:not(.wrap) input:checked + span { background: #fff; color: var(--navy); border-color: #fff; }

/* Floating dock with a glowing centre button */
.nav .nav-add { background: radial-gradient(circle at 50% 78%, #e4f77f 0, #8fcf5a 30%, #2f5a35 62%, #101a13 100%); color: #fff; box-shadow: 0 10px 26px #7bbd4a55, inset 0 1px 0 #ffffff55; border: 1px solid #ffffff40; }
.nav .nav-add:hover { filter: brightness(1.06); background: radial-gradient(circle at 50% 78%, #e4f77f 0, #8fcf5a 30%, #2f5a35 62%, #101a13 100%); }

/* Home hero with orbit lines */
.hero-x, .login-hero { position: relative; overflow: hidden; border-radius: 30px; padding: 30px 28px 28px; margin-bottom: 18px; color: #fff; isolation: isolate;
  background: radial-gradient(70% 90% at 15% 15%, #8fc2e3 0, transparent 60%), radial-gradient(65% 85% at 95% 100%, #c6e27a 0, transparent 62%), radial-gradient(50% 60% at 60% 45%, #0e1b17 0, transparent 75%), #29483f;
  box-shadow: 0 18px 44px #1d3a2f33; }
.hero-x h1, .login-hero h1 { color: #fff; font-size: 36px; margin-bottom: 10px; max-width: 520px; }
.hero-x p, .login-hero p { color: #e3efe9; max-width: 440px; font-size: 14px; position: relative; }
.hero-x .eyebrow { color: #d9ecd1; }
.orbits { position: absolute; z-index: -1; right: -60px; top: -40px; width: 340px; height: 340px; fill: none; stroke: #ffffff52; stroke-width: 1; }
.orbits path { stroke: #ffffffa8; }
.orbits .dot { fill: #fff; stroke: none; }
.hero-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero-pills span { font-size: 12px; padding: 7px 13px; border-radius: 999px; background: #ffffff26; border: 1px solid #ffffff55; color: #fff; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.hero-pills .warn { background: #f3a46a55; border-color: #ffd2ad88; }

/* Tasks and quick actions */
.task { border-radius: var(--radius); border: 1px solid #ffffffb3; -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--shadow); }
.task.warn { background: linear-gradient(135deg, #fde6d4e6, #f8d4bce6); }
.task.busy { background: linear-gradient(135deg, #e3eefbe6, #d3e3f6e6); }
.task.error { background: linear-gradient(135deg, #fbe4dfe6, #f4cfc8e6); }
.task h2 { font-size: 20px; }
.quick-item { border-radius: var(--radius); background: var(--glass); border: 1px solid var(--line); box-shadow: var(--shadow); }
.quick-item:first-child { color: #fff; border-color: #ffffff30; background: radial-gradient(90% 120% at 30% 120%, #d9f37a 0, #7dbb55 28%, #234a33 58%, #0f1813 100%); box-shadow: 0 14px 34px #3d6b3a40; }
.quick-item:first-child .ic { color: #eaffb8; }

/* Glowing gradient widgets: colour = meaning */
.summary { border-radius: 24px; color: #fff; border: 1px solid #ffffff4d; min-height: 92px; box-shadow: 0 10px 28px #20352c1f; }
.summary span { color: #ffffffd9; }
.summary strong, .summary.warn strong, .summary.ok strong, .summary.muted strong { color: #fff; }
.summary { background: radial-gradient(60% 70% at 65% 75%, #0d1424 0, transparent 70%), linear-gradient(160deg, #7f97d9, #3f5bb0); }
.summary.warn { background: radial-gradient(55% 65% at 70% 75%, #3a1709 0, transparent 70%), linear-gradient(160deg, #f0a37c, #c95a33); }
.summary.ok { background: radial-gradient(55% 65% at 70% 75%, #0c1d12 0, transparent 70%), linear-gradient(160deg, #9cc9a3, #4f8a61); }
.summary.muted { background: radial-gradient(55% 65% at 70% 75%, #0d1424 0, transparent 70%), linear-gradient(160deg, #8ea7e3, #4561b3); }
.tile { border-radius: 24px; border: 1px solid #ffffff4d; color: #fff; min-height: 116px; box-shadow: 0 10px 26px #20352c1a;
  background: radial-gradient(60% 70% at 72% 78%, #0c1d12 0, transparent 70%), linear-gradient(155deg, #a6cdae, #5a9370); }
.tile:hover { border-color: #ffffffa6; filter: brightness(1.04); }
.tile-name, .tile-meta, .tile strong small, .tile .trend { color: #ffffffd9; }
.tile strong { color: #fff; font-weight: 650; letter-spacing: -.02em; }
.tile.tone-warn { background: radial-gradient(60% 70% at 72% 78%, #3a1709 0, transparent 70%), linear-gradient(155deg, #f2ab83, #c75d35); border-color: #ffffff4d; }
.tile.tone-muted { background: radial-gradient(60% 70% at 72% 78%, #0d1424 0, transparent 70%), linear-gradient(155deg, #9cb3e8, #4864b6); }
.tile .chip.warn { background: #ffffff33; color: #fff; }

/* Results, explanation, stepper */
.result { background: #ffffffa6; border-color: #ffffffd9; border-radius: 20px; }
.result.tone-warn { background: linear-gradient(135deg, #fff3e9e6, #fde4d3e6); border-color: #f6cfb2; }
.result-value strong, .big-value strong { font-family: var(--display); font-weight: 650; font-size: 30px; letter-spacing: -.03em; }
.ai-card { background: radial-gradient(80% 120% at 100% 0%, #d9d3fb99 0, transparent 60%), radial-gradient(70% 100% at 0% 100%, #cfe6f599 0, transparent 60%), #ffffffa6; border-color: #ffffffd9; }
.ai-badge { border-radius: 999px; padding: 4px 10px; }
.result-ai { background: #ebe8fbb3; border-radius: 16px; }
.ai-summary { font-size: 17px; line-height: 1.55; letter-spacing: -.01em; }
.questions ol { counter-reset: q; list-style: none; padding: 0; }
.questions li { counter-increment: q; display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--hair); }
.questions li::before { content: counter(q, decimal-leading-zero); font-size: 12px; color: var(--muted); padding-top: 3px; min-width: 20px; }
.stepper li::before { height: 1px; background: #1d2b241f; }
.stepper li.done::before, .stepper li.current::before { background: #4f8a61; }
.stepper li > span, .stepper li > .ic { background: #ffffffb3; border: 1px solid #ffffffe6; }
.stepper li.done > .ic { background: #4f8a61; }
.review-intro { background: linear-gradient(135deg, #fdecdfe6, #fbe2cfe6); border-color: #ffffffb3; }
.lab-row { background: #ffffff8c; border-color: #ffffffd9; border-radius: 20px; }
.lab-source { background: #ffffffb3; border-radius: 10px; }
.explain-after { background: #ebe8fbb3; border-radius: 18px; }
.submit-bar { background: #ffffffd9; -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-color: #ffffffb3; }
.next-up { background: linear-gradient(135deg, #fde6d4e6, #f8d4bce6); border-radius: 999px; padding: 6px 6px 6px 18px; }
.range-track { fill: #1d2b241a; }
.range-norm { fill: #8fc59f; }
.chart .plotline { stroke: #4f8a61; }
.chart circle { stroke: #4f8a61; }
.chart .norm-band { fill: #cfe7d6aa; }

/* Sheet, dropzone, share */
.sheet { background: #ffffffd9; border: 1px solid #ffffffe6; }
.sheet-backdrop { background: #142a2240; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.dropzone { border: 1px solid #ffffffe6; border-radius: 26px; color: #fff; background: radial-gradient(70% 90% at 15% 10%, #8fc2e3 0, transparent 60%), radial-gradient(65% 85% at 95% 100%, #c6e27a 0, transparent 62%), radial-gradient(50% 60% at 55% 50%, #0e1b17 0, transparent 75%), #29483f; }
.dropzone .small { color: #e3efe9; }
.dropzone > .ic { color: #eaffb8; }
.dropzone .button { background: #fff; color: var(--navy); }
.dropzone.over { background: radial-gradient(70% 90% at 50% 50%, #c6e27a 0, #29483f 80%); }
.option { background: #ffffff8c; border-color: #ffffffd9; border-radius: 20px; }
.share-form { background: #ffffff73; border: 1px solid #ffffffb3; border-radius: 22px; }
.share-result { background: linear-gradient(135deg, #e0f1e5e6, #cfe6d7e6); border-radius: 22px; }
.share-result .code b { font-family: var(--display); font-weight: 700; letter-spacing: .12em; }
.picker { background: #ffffff73; border-color: #ffffffb3; border-radius: 20px; }
#toast { background: #121a16e6; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-radius: 999px; padding: 12px 22px; }

/* Sign-in */
.login { max-width: 480px; }
.login-hero { padding: 34px 28px; text-align: left; }
.login-logo { width: 72px; height: 72px; display: block; margin-bottom: 14px; filter: drop-shadow(0 8px 18px #0006); }
.wordmark { font-size: 14px; font-weight: 700; letter-spacing: .3em; color: #d9ecd1; margin: 0 0 18px; }
.login-hero h1 { font-size: 30px; }
.login .card h2 { font-size: 24px; }

@media (max-width: 620px) {
  h1 { font-size: 28px; }
  .hero-x { padding: 24px 20px; border-radius: 26px; }
  .hero-x h1 { font-size: 30px; }
  .orbits { right: -110px; top: -70px; width: 300px; height: 300px; }
  .nav { background: #ffffffa6; border-color: #ffffffd9; border-radius: 999px; -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); padding: 6px; }
  .nav button { border-radius: 999px; }
  .nav button.active { background: #ffffffd9; box-shadow: 0 4px 12px #20352c14; }
  .nav .nav-add { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 50%; margin: -18px 6px 0; }
  .topbar .brand img { width: 30px; height: 30px; }
  .avatar-button { background: #ffffff8c; border: 1px solid #ffffffd9; }
  .summary { min-height: 84px; border-radius: 20px; }
  .tile { min-height: 108px; border-radius: 20px; }
  .login-hero h1 { font-size: 27px; }
}

/* ── Flat 2D: no shadows, glows, inner highlights or depth blur ── */
*, *::before, *::after { box-shadow: none !important; text-shadow: none !important; }
img, .brand img, .login-logo { filter: none !important; }
.card, .quick-item, .summary, .sheet, .tabs, .filter, .avatar-button, .task, .submit-bar, .sidebar, .nav, .hero-pills span, #toast, .sheet-backdrop { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
.card, .quick-item, .result, .lab-row, .option, .picker, .share-form, .tabs, .segmented { background: #ffffffcc; border: 1px solid #1d2b2414; }
.sidebar { background: #ffffff66; border-right: 1px solid #1d2b2414; }
input, select, textarea { background: #fff; border: 1px solid #1d2b241f; }
.button.secondary { background: #fff; border: 1px solid #1d2b241f; }
.button.ghost, .filter, .segmented.wrap span, .icon-button, .chip { background: #ffffffb3; border: 1px solid #1d2b241a; }
.filter.active, .segmented input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.segmented:not(.wrap) input:checked + span { background: #fff; color: var(--navy); border: 1px solid #1d2b241f; }
.hero-x, .login-hero, .dropzone { background: linear-gradient(135deg, #2e5649 0%, #3f7563 48%, #7fb46d 100%); }
.quick-item:first-child { background: linear-gradient(135deg, #2e5649, #6fa865); border-color: transparent; }
.nav .nav-add, .nav .nav-add:hover { background: #b9e36a; color: var(--navy); border: 0; }
.nav .nav-add .ic { color: var(--navy); }
.nav { background: #fffffff2; border: 1px solid #1d2b2414; }
.nav button.active { background: #edf2ee; }
.summary, .summary.muted { background: linear-gradient(150deg, #93ace6, #5a76c4); border: 0; }
.summary.warn { background: linear-gradient(150deg, #f2ab83, #d9704a); }
.summary.ok { background: linear-gradient(150deg, #93c49f, #5b9a6d); }
.tile { background: linear-gradient(150deg, #93c49f, #5b9a6d); border: 0; }
.tile.tone-warn { background: linear-gradient(150deg, #f2ab83, #d9704a); }
.tile.tone-muted { background: linear-gradient(150deg, #93ace6, #5a76c4); }
.task.warn, .review-intro, .next-up { background: #fbe3d1; border: 1px solid #f3cfb4; }
.task.busy { background: #e1ebf7; border: 1px solid #cddcef; }
.task.error { background: #f8dfda; border: 1px solid #efc6be; }
.result.tone-warn { background: #fdeee2; border-color: #f3cfb4; }
.ai-card { background: #f1effc; border: 1px solid #ddd8f5; }
.result-ai, .explain-after { background: #ebe8fb; }
.share-result { background: #e2f1e6; }
.submit-bar { background: #fff; border-top: 1px solid #1d2b2414; }
.stepper li > span, .stepper li > .ic { background: #fff; border: 1px solid #1d2b241f; }
.stepper li.done > .ic { background: #4f8a61; border-color: #4f8a61; }
.stepper li.current > span { background: var(--navy); border-color: var(--navy); }
.doc-icon { background: #e6f0e8; }
.hero-pills span { background: #ffffff26; border: 1px solid #ffffff59; }
.sheet-backdrop { background: #142a2266; }
.range-dot { stroke: none; }
.chart .norm-band { fill: #dcefe2; }

/* ── Alignment pass: widths 320–1440, equal rows, 44px targets ── */
.shell { max-width: none; grid-template-columns: 232px minmax(0, 960px); justify-content: center; }
.main { max-width: none; }
@media (min-width: 621px) { .nav { background: none !important; border: 0 !important; padding: 0; } }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lab-grid { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, .9fr) minmax(0, .9fr); }
.lab-grid.text { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
input[type=date] { min-width: 0; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(min(176px, 100%), 1fr)); }
.tile, .tile > * { min-width: 0; max-width: 100%; }
.tile .chip { white-space: normal; text-align: left; }
.tile-name { overflow-wrap: anywhere; }
.section-head h2 { min-width: 0; }
.section-head .linkbutton, .section-head .chip { white-space: nowrap; flex-shrink: 0; }
.summary-row > *, .quick > * { min-width: 0; }
.segmented label { min-width: 0; }
.segmented span { white-space: nowrap; }
.doc-text strong, .doc-text small { overflow-wrap: anywhere; }
/* Comfortable tap targets for every toggle and text button */
details > summary { min-height: 44px; display: flex; align-items: center; }
.result-group > summary { display: block; min-height: 0; }
.back { min-height: 44px; }
.linkbutton { min-height: 40px; }
.report-top .small { white-space: nowrap; }
@media (max-width: 900px) and (min-width: 621px) { .lab-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lab-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-head h2 { font-size: 19px; }
  .nav button { min-width: 0; }
  .nav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .report-card .report-top { flex-direction: column; gap: 4px; }
}
@media (max-width: 360px) {
  .main { padding: 14px 12px 116px; }
  .topbar { padding: 14px 12px 0; }
  .nav { left: 6px; right: 6px; }
  .nav button { font-size: 9.5px; letter-spacing: -.01em; }
  .nav .nav-add { flex: 0 0 50px; width: 50px; height: 50px; margin: -14px 2px 0; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .segmented:not(.wrap) span { font-size: 11.5px; padding: 0 3px; }
  h1 { font-size: 26px; }
  .hero-x { padding: 22px 18px; }
  .hero-x h1 { font-size: 28px; }
  .card { padding: 16px; }
  .submit-bar { margin: 16px -16px -16px; padding: 12px 16px 14px; }
  .tiles { gap: 8px; }
  .tile { padding: 12px; }
  .tile strong { font-size: 18px; }
  .summary { padding: 12px 8px; }
  .summary strong { font-size: 22px; }
}
/* Round value marker that never stretches with the bar width */
.range-dot { fill: none; stroke: var(--navy); stroke-width: 10px; stroke-linecap: round; }
.tone-warn .range-dot { stroke: #c97a2c; }
form > .button[type=submit], form > .actions, form > .check + .button { margin-top: 16px; }

/* ── Sign-in, registration and account e-mail pages ── */
.login { max-width: 480px; margin: 0 auto; padding: max(24px, 5vh) 20px 32px; display: flex; flex-direction: column; gap: 16px; min-height: 100vh; justify-content: center; }
.login > * { margin: 0; }
.login > .brand { margin-bottom: 8px; }
.login > h1 { margin: 0 0 4px; }
.login .card { margin: 0; }
.login-hero { margin: 0; }
.login-hero h1 { margin-bottom: 10px; }
.login-hero p:last-child { margin-bottom: 0; }
@media (min-width: 900px) {
  .login.split { max-width: 1040px; padding: 40px 32px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); column-gap: 20px; row-gap: 14px; align-content: center; }
  .login.split .login-hero { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; justify-content: flex-end; min-height: 100%; padding: 40px 36px; }
  .login.split .login-logo { margin-bottom: auto; }
  .login.split .wordmark { margin-top: 28px; }
  .login.split .login-hero h1 { font-size: 34px; }
  .login.split > .card { grid-column: 2; grid-row: 1; align-self: center; padding: 32px; }
  .login.split > .small { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .login { padding: 16px 14px 28px; gap: 12px; min-height: 0; justify-content: flex-start; }
  .login-hero { padding: 26px 22px; }
}

/* ── Floating sidebar: a rounded panel instead of a full-height strip ── */
@media (min-width: 621px) {
  .shell { grid-template-columns: 252px minmax(0, 960px); column-gap: 32px; padding: 0 24px; justify-content: center; }
  .sidebar { position: sticky; top: 16px; align-self: start; height: calc(100vh - 32px); margin: 16px 0; padding: 22px 14px 14px; gap: 20px;
    border-radius: 28px; border: 1px solid #1d2b2414; background: #fffffff2; overflow-y: auto; scrollbar-width: none; }
  .sidebar > .brand { padding: 0 8px; }
  .nav { gap: 4px; }
  .nav .nav-add { margin: 0 0 14px; min-height: 50px; border-radius: 16px; font-size: 15px; }
  .nav button:not(.nav-add) { min-height: 48px; padding: 0 8px; gap: 12px; border-radius: 16px; font-size: 14.5px; color: #56645e; font-weight: 500; }
  .nav button:not(.nav-add) .ic { width: 34px; height: 34px; padding: 7px; border-radius: 11px; background: #f0f4f1; color: #4c5e56; }
  .nav button:not(.nav-add):hover { background: #f4f7f5; color: var(--navy); }
  .nav button.active, .nav button.active:hover { background: var(--navy) !important; color: #fff !important; font-weight: 600; }
  .nav button.active .ic { background: #ffffff1a; color: #c6ec78; }
  .side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 20px; background: #f2f5f3; flex-wrap: nowrap; }
  .side-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 4px; border-radius: 14px; text-align: left; color: var(--text); }
  .side-user:hover { background: #ffffffb3; }
  .side-name { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
  .side-name b, .side-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-name b { font-size: 13.5px; font-weight: 600; }
  .side-name small { font-size: 11.5px; color: var(--muted); }
  .side-logout { flex-shrink: 0; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid #1d2b241a; background: #fff; color: #5d6a65; }
  .side-logout:hover { color: var(--error); border-color: #efc6be; }
  .side-logout .ic { width: 18px; height: 18px; }
  .main { padding: 16px 0 64px; }
}
@media (min-width: 621px) and (max-width: 900px) {
  .shell { grid-template-columns: 216px minmax(0, 1fr); column-gap: 18px; padding: 0 14px; }
  .nav button:not(.nav-add) { font-size: 14px; }
}
@media (min-width: 621px) and (max-width: 900px) {
  .side-name b { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
  .side-name small { display: none; }
  .side-foot { gap: 6px; padding: 6px; }
  .side-logout { width: 36px; height: 36px; }
}

/* Side-by-side comparison never replaces the unfinished review form. */
#original-panel {position:fixed;right:12px;top:12px;bottom:12px;width:46vw;z-index:80;background:white;border:1px solid #d5dfda;border-radius:18px;box-shadow:0 12px 40px #17382b22;display:flex;flex-direction:column;overflow:hidden}
.preview-head {display:flex;align-items:center;justify-content:space-between;gap:12px;padding:16px;font-size:14px}
.preview-head button {font-size:28px;background:none;border:0;cursor:pointer}
#original-panel iframe {width:100%;flex:1;border:0;background:#f3f5f3}
@media(min-width:1100px){body.comparing-original {padding-right:48vw} body.comparing-original .grid2,body.comparing-original .lab-grid {grid-template-columns:1fr 1fr}}
.warnings[open] {max-height:none;overflow:visible}
.warnings ul {max-height:none;overflow:visible;overflow-wrap:anywhere}
.warnings li {margin:12px 0;line-height:1.6}

@media(min-width:1100px){body.comparing-original .shell {grid-template-columns:100px minmax(0,1fr)} body.comparing-original .sidebar {padding:20px 8px} body.comparing-original .sidebar .brand {font-size:13px} body.comparing-original .nav button {padding:8px;font-size:11px;gap:4px} body.comparing-original .main {padding:24px 16px} body.comparing-original .side-foot {font-size:11px}}
/* Compact floating sidebar while an original is open side by side */
@media (min-width: 1100px) {
  body.comparing-original .shell { column-gap: 14px; padding: 0 10px; }
  body.comparing-original .sidebar { padding: 16px 8px 10px; }
  body.comparing-original .sidebar > .brand span, body.comparing-original .side-name { display: none; }
  body.comparing-original .nav .nav-add span { display: none; }
  body.comparing-original .nav button:not(.nav-add) { flex-direction: column; justify-content: center; gap: 4px; min-height: 60px; padding: 6px 2px; font-size: 10.5px; }
  body.comparing-original .side-foot { flex-direction: column; padding: 6px; }
}

/* ── Icon-only menu on phones and while an original is open alongside ──
   Labels stay in the accessibility tree; a tooltip shows them on hover. */
@media (max-width: 620px) {
  .nav { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); align-items: center; }
  .nav button { min-height: 50px; padding: 0; gap: 0; border-radius: 18px; }
  .nav .nav-label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav button:not(.nav-add) .ic { width: 24px; height: 24px; }
  .nav button.active { background: var(--navy) !important; color: #fff; }
  .nav button.active .ic { color: #c6ec78; }
  .nav .nav-add { flex: 0 0 56px; width: 56px; height: 56px; margin: -16px 6px 0; }
}
@media (min-width: 1100px) {
  body.comparing-original .shell { grid-template-columns: 84px minmax(0, 1fr); }
  body.comparing-original .nav .nav-label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  body.comparing-original .nav button:not(.nav-add) { min-height: 50px; padding: 0; gap: 0; justify-content: center; align-items: center; }
  body.comparing-original .nav .nav-add { min-height: 50px; padding: 0; }
  body.comparing-original .sidebar { padding: 16px 8px 10px; }
}

.combined-chart{width:100%;height:auto;min-height:200px}.combined-chart text{font:11px system-ui;fill:#52655d}.trend-legend{display:flex;flex-wrap:wrap;gap:8px 16px;font-size:12px}.trend-legend span{display:flex;gap:5px;align-items:center}.trend-picker{max-height:300px;overflow:auto;display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.trend-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:20px}.latest-result{padding:14px 0;border-bottom:1px solid #d7e1db}#trend-filter .grid2{margin-top:16px}#dynamics details{margin-top:18px}#latest-summary{scroll-margin-top:20px}
