:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  --canvas: #eef6f4;
  --panel: #fff;
  --soft: #e5f4f0;
  --ink: #192e2d;
  --muted: #405e5a;
  --line: #bdcfca;
  --accent: #135d56;
  --on-accent: #fff;
  --danger: #832b29;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #142523;
  --panel: #1d322f;
  --soft: #254640;
  --ink: #f0faf8;
  --muted: #b6d0cb;
  --line: #577a73;
  --accent: #a4e5d6;
  --on-accent: #173632;
  --danger: #ffc4bb;
}
:root[data-large="true"] { font-size: 120%; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.55; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.skip { position: absolute; margin: 8px; padding: 10px; background: var(--panel); transform: translateY(-150%); }
.skip:focus { transform: none; }
.bar { background: var(--panel); border-bottom: 1px solid var(--line); }
.bar-inner, main { width: min(1100px, 100% - 2rem); margin: auto; }
.bar-inner, .account { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.bar-inner { padding-block: .75rem; }
.brand, .toolbar, .buttons { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.brand { font-weight: 760; font-size: 1.15rem; }
main { padding: 2.3rem 0 4rem; }
.hero { border-radius: 1.25rem; background: #103c3d; color: #fff; padding: clamp(1.25rem, 5vw, 3rem); margin-bottom: 1rem; }
.hero p { max-width: 55ch; color: #d3ece7; margin-bottom: 0; }
.hero .eyebrow { margin: 0 0 .45rem; font-size: .85rem; font-weight: 730; letter-spacing: .11em; }
h1, h2 { margin: 0; line-height: 1.15; letter-spacing: -.035em; }
h1 { font-size: clamp(2rem, 6vw, 3.65rem); }
h2 { font-size: 1.45rem; }
p, dd, .label { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 1rem; }
.stack { display: grid; gap: 1rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: clamp(1rem, 3vw, 1.55rem); }
.account, .recovery { margin-bottom: 1rem; }
.account strong { display: block; overflow-wrap: anywhere; }
.label { display: block; font-size: .85rem; }
button, input, textarea, select { font: inherit; color: inherit; }
button, input, textarea, select { border: 1px solid var(--line); border-radius: .55rem; background: var(--panel); }
button { padding: .54rem .76rem; min-height: 44px; cursor: pointer; font-weight: 650; }
button:hover { background: var(--soft); }
button:disabled { opacity: .57; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { filter: brightness(1.12); }
form { display: grid; gap: .45rem; margin-top: 1rem; }
form > button, form > .buttons { justify-self: start; margin-top: .35rem; }
input, textarea, select { padding: .55rem; width: 100%; min-width: 0; }
textarea { resize: vertical; }
label { font-weight: 620; }
.check { display: inline-flex; gap: .55rem; align-items: center; min-height: 44px; }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
#notice:not(:empty), .recovery { background: var(--soft); }
#notice:not(:empty) { margin: 1rem 0; padding: .8rem 1rem; border-radius: .6rem; border: 1px solid var(--line); }
#notice[data-error="true"], .conflict { color: var(--danger); }
output { display: block; margin-bottom: 1rem; font: 1rem ui-monospace, monospace; overflow-wrap: anywhere; user-select: all; }
dl { display: grid; gap: .2rem; }
dt { font-weight: 650; }
dd { margin: 0 0 .55rem; }
.entry { padding: .85rem 0; border-top: 1px solid var(--line); }
#entries:not(:empty) { margin-top: 1.3rem; }
.entry p { margin: .3rem 0 .7rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry strong { overflow-wrap: anywhere; }
#ocr-label:not([hidden]) { display: block; margin-top: 1rem; }
.health-nav { display: grid; gap: .6rem; margin-bottom: 1.6rem; }
.main-menu, .sub-menu, .quick-links { display: flex; flex-wrap: wrap; gap: .5rem; }
.main-menu { background: var(--panel); border: 1px solid var(--line); border-radius: .9rem; padding: .5rem; }
.health-nav button { border-color: transparent; }
.main-menu button[aria-current] { background: var(--accent); color: var(--on-accent); }
.sub-menu button[aria-current] { border-color: var(--accent); background: var(--soft); }
.section-heading { margin-block: .65rem .3rem; }
.section-heading h1 { font-size: clamp(1.85rem, 4vw, 2.9rem); }
.section-heading p { margin-bottom: 0; }
#health-content { display: grid; gap: 1rem; }
#storage-tools { margin-top: 1rem; }
.dashboard-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); }
.metric-card { display: flex; align-items: flex-start; flex-direction: column; gap: .45rem; }
.metric-card h2 { font-size: 1.03rem; letter-spacing: normal; color: var(--muted); }
.metric-value { font-size: clamp(1.25rem, 2.4vw, 1.65rem); font-weight: 730; overflow-wrap: anywhere; }
.metric-card p { margin: 0 0 auto; }
.metric-card button { margin-top: .4rem; }
.record-form, .filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: .85rem 1rem; align-items: start; }
.record-form > .buttons, .record-form > fieldset, .record-form .wide { grid-column: 1 / -1; }
.control { display: flex; flex-direction: column; gap: .25rem; font-weight: 650; min-width: 0; }
.control:has(> input[type="checkbox"]) { align-items: center; flex-direction: row-reverse; justify-content: flex-end; gap: .55rem; min-height: 44px; }
.control > input[type="checkbox"] { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.control small, .import-text { font-weight: 400; color: var(--muted); }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: .65rem; }
legend { font-weight: 650; }
.health-record { padding: .85rem 0; border-top: 1px solid var(--line); }
.health-record h3, .health-record p { margin: 0 0 .4rem; }
.health-record .buttons { margin: .5rem 0; }
.health-record details { margin: .4rem 0; }
.health-record .record-summary, dd { white-space: pre-wrap; overflow-wrap: anywhere; }
.filters { margin: .8rem 0; }
.entry-details { display: grid; grid-template-columns: minmax(105px, max-content) minmax(0, 1fr); column-gap: .9rem; }
.entry-details dd { margin: 0 0 .35rem; }
summary { cursor: pointer; font-weight: 650; }
.chart-box { position: relative; height: clamp(245px, 48vw, 390px); }
.table-scroll { overflow-x: auto; margin-top: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; vertical-align: top; padding: .45rem; border-bottom: 1px solid var(--line); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .25rem; margin-top: 1rem; }
.calendar-grid button { padding: .15rem; }
.calendar-grid button[aria-current] { background: var(--soft); border-color: var(--accent); }
.weekday { text-align: center; }
.import-review { display: grid; gap: .85rem; }
.import-text { white-space: pre-wrap; overflow: auto; overflow-wrap: anywhere; max-height: 22rem; font: inherit; }
.import-image, .document-preview img, .document-preview canvas { max-width: 100%; height: auto; display: block; }
.document-preview { overflow: auto; }
.document-preview.zoomed img { max-width: none; }
.import-candidate { border-bottom: 1px solid var(--line); margin-bottom: 1rem; padding-bottom: .65rem; }
dialog { width: min(32rem, 100% - 1.6rem); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: .8rem; }
dialog::backdrop { background: #142523aa; }
@media (max-width: 750px) { .grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 445px) { .bar-inner { align-items: flex-start; } .toolbar { width: 100%; } main { padding-top: 1rem; } }
@media (max-width: 500px) { .entry-details { grid-template-columns: 1fr; } }
@media print {
  .bar, .health-nav, .account, .buttons, .quick-links, .filters, #notice { display: none !important; }
  body, .panel { color: #173632; background: #fff; }
  main { width: 100%; padding: 0; }
}
