/* PSM Tools - "Clinic" look: soft grey-green ground, one teal result card, white rounded cards, pills. */
@font-face { font-family: "Manrope"; src: url("fonts/manrope.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #eef3f2; --card: #ffffff; --soft: #eef3f2;
  --ink: #10201f; --muted: #5b6b6a; --line: #e6eceb;
  --accent: #0d5c56; --accent-ink: #0d4f4a; --accent-soft: #dcebe8;
  --on-accent: #ffffff; --on-accent-muted: #d6ebe8; --on-accent-tile: rgba(255, 255, 255, 0.13);
  --btn: #10201f; --btn-ink: #ffffff;
  --ok: #1f8a5b; --watch: #a86a12; --moderate: #c2570c; --severe: #c0342b;
  --r-card: 28px; --r-in: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d1615; --card: #162221; --soft: #1f2e2c;
    --ink: #e8f0ee; --muted: #9db0ad; --line: #243331;
    --accent: #0f6a63; --accent-ink: #7fd6c9; --accent-soft: #1c3b37;
    --btn: #e8f0ee; --btn-ink: #0d1615;
    --ok: #6fd3a2; --watch: #f0c36a; --moderate: #f5a570; --severe: #f59088;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 500 16px/1.4 "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.wrap { max-width: 520px; margin: 0 auto; padding: 20px 16px 120px; display: flex; flex-direction: column; gap: 14px; }
a { color: var(--accent-ink); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }

/* top bar */
.bar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.bar h1 { margin: 0 auto 0 0; font-size: clamp(19px, 6.2vw, 24px); font-weight: 700; letter-spacing: -0.02em; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home { width: 44px; height: 44px; border-radius: 50%; background: var(--card); color: var(--ink); display: flex; align-items: center; justify-content: center; flex: none; }
.chip { flex: none; font-size: 12px; font-weight: 700; color: var(--accent-ink); background: var(--card); padding: 8px 12px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* teal result card */
.hero { background: var(--accent); color: var(--on-accent); border-radius: var(--r-card); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.hero .top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--on-accent-muted); font-variant-numeric: tabular-nums; }
.hero .big { font-size: 60px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
.hero .big.mid { font-size: 30px; letter-spacing: -0.02em; line-height: 1.12; }
.hero .big.idle { opacity: 0.45; }
.steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.steps i { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.28); }
.steps i.on { background: #ffffff; }
.steps-lab { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; text-align: center; font-size: 12px; color: var(--on-accent-muted); margin-top: -6px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.zt { background: var(--on-accent-tile); border-radius: var(--r-in); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.zt .k { font-size: 12px; color: var(--on-accent-muted); }
.zt .z { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.zt .r { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--tone); }
.hero .ok { --tone: #7ee2b0; } .hero .watch { --tone: #ffd479; } .hero .moderate { --tone: #ffb37a; } .hero .severe { --tone: #ff9a92; }
.hero .line { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.hero ul { margin: 0; padding-left: 16px; font-size: 12px; color: var(--on-accent-muted); display: flex; flex-direction: column; gap: 4px; }
.hero .err { font-size: 14px; }

/* white cards */
.card { background: var(--card); border-radius: var(--r-card); padding: 8px 20px; }
.card.pad { padding: 18px 20px; }
.rowi { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; border-bottom: 1px solid var(--line); }
.rowi:last-child { border-bottom: 0; }
.rowi.col { flex-direction: column; align-items: stretch; justify-content: center; gap: 8px; padding: 12px 0; }
.rowi > label, .rowi > .lab { font-size: 15px; color: var(--muted); flex: none; }
.rowi input[type="number"], .rowi input[type="text"], .rowi input[type="date"], .rowi select {
  font: 700 18px "Manrope", sans-serif; color: var(--ink); background: none; border: 0; text-align: right; min-height: 44px; padding: 0; width: 100%; min-width: 0; font-variant-numeric: tabular-nums; border-radius: 8px;
}
.rowi input::placeholder { color: var(--muted); opacity: 0.55; font-weight: 500; }
.rowi select { font-size: 15px; text-align-last: right; appearance: none; -webkit-appearance: none; cursor: pointer; max-width: 62%; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.rowi input[type="text"] { font-size: 16px; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input { width: 44px !important; text-align: center !important; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--soft); color: var(--ink); font: 500 20px "Manrope", sans-serif; cursor: pointer; flex: none; }
.mini { font: 600 12px "Manrope", sans-serif; color: var(--accent-ink); background: var(--accent-soft); border: 0; border-radius: 999px; padding: 0 12px; height: 32px; cursor: pointer; flex: none; }

.seg { display: flex; background: var(--soft); border-radius: 24px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg label { flex: 1 1 0; margin: 0; position: relative; }
.seg.wide label { flex: 1 1 30%; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 10px; border-radius: 20px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg input:checked + span { background: var(--card); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.switch { width: 28px; height: 28px; accent-color: var(--accent); flex: none; }

/* range lists */
.list { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.list div { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.list div.on { color: var(--accent-ink); font-weight: 700; }
.list h2 { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* actions */
.actions { display: flex; gap: 8px; }
.btn { flex: 1; height: 54px; border: 0; border-radius: 999px; background: var(--btn); color: var(--btn-ink); font: 600 16px "Manrope", sans-serif; cursor: pointer; }
.btn:disabled { opacity: 0.35; cursor: default; }
.icon { width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--card); color: var(--ink); display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.btn.small { flex: none; height: 40px; padding: 0 16px; font-size: 13px; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--soft); color: var(--severe); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* records + details */
.card h2 { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { font-weight: 600; color: var(--muted); }
th:first-child, td:first-child { padding-left: 0; } th:last-child, td:last-child { padding-right: 0; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
details.card { padding: 0 20px; }
summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; min-height: 56px; font-size: 15px; font-weight: 600; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-size: 20px; font-weight: 400; color: var(--muted); }
details[open] summary::after { content: "\2212"; }
details .in { padding: 0 0 18px; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 10px; }
details .in p { margin: 0; }
.formula { background: var(--soft); color: var(--ink); border-radius: var(--r-in); padding: 12px 14px; font: 500 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-x: auto; }
.copybox { background: var(--soft); color: var(--ink); border-radius: var(--r-in); padding: 12px 14px; font-size: 13px; }

/* chart */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px 10px; padding: 0 4px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; height: 40px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--soft); color: var(--muted); font: 600 13px "Manrope", sans-serif; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis, .chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font: 600 11px "Manrope", sans-serif; }
.chart .c0 { stroke: var(--accent-ink); stroke-width: 2.5; fill: none; }
.chart .c2 { stroke: var(--muted); stroke-width: 1.25; fill: none; opacity: 0.7; }
.chart .c3 { stroke: var(--muted); stroke-width: 1.25; fill: none; stroke-dasharray: 3 4; opacity: 0.7; }
.chart .pt { fill: var(--ink); stroke: var(--card); stroke-width: 3; }

/* home */
.tool { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--r-card); padding: 20px; text-decoration: none; color: var(--ink); }
.tool b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.tool span { font-size: 13px; color: var(--muted); }
.tool .go { margin-left: auto; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; flex: none; }
.credit { text-align: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.credit a { color: inherit; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid .tool { flex-direction: column; align-items: flex-start; gap: 4px; padding: 18px; border-radius: 24px; }
.grid .tool b { font-size: 16px; }
.sect { font-size: 13px; font-weight: 600; color: var(--muted); margin: 8px 4px -4px; }
.fact { display: flex; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.fact:last-child { border-bottom: 0; }
.fact .l { font-size: 14px; min-width: 0; }
.fact .l small { display: block; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.fact .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.due { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.due:last-child { border-bottom: 0; }
.due .d { flex: none; width: 104px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.due .d small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.due .t { font-size: 14px; color: var(--muted); }
.due.next .d, .due.next .t { color: var(--accent-ink); }
.due.past { opacity: 0.55; }

/* bottom pill navigation */
.nav { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(488px, calc(100% - 20px)); background: var(--card); border-radius: 999px; padding: 6px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); font-size: 13px; font-weight: 600; text-align: center; box-shadow: 0 8px 28px rgba(16, 32, 31, 0.14); z-index: 5; }
.nav a { padding: 13px 0; border-radius: 999px; text-decoration: none; color: var(--muted); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }

.toast { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); background: var(--btn); color: var(--btn-ink); padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 10; }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media print {
  :root { --bg: #fff; --card: #fff; --soft: #f1f1f1; --ink: #000; --muted: #333; --line: #bbb; --accent: #fff; --on-accent: #000; --on-accent-muted: #333; --on-accent-tile: #f1f1f1; }
  .nav, .actions, .toast, .no-print, details.card { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .hero, .card { border: 1px solid #999; break-inside: avoid; }
  .steps i { background: #ddd; } .steps i.on { background: #000; }
}
