:root {
  color-scheme: light;
  --bg: #f5f0e6;
  --bg-2: #ede4d4;
  --card: #fffdf8;
  --card-2: #fbf6ec;
  --text: #1e1a15;
  --muted: #5b5146;
  --border: #d7cab3;
  --border-strong: #b9a98e;
  --primary: #7b3f18;
  --primary-soft: #f3e3d3;
  --primary-ink: #fffaf4;
  --accent: #a55825;
  --ok: #1d6b3a;
  --ok-bg: #e0f0e4;
  --warn: #7a4300;
  --warn-bg: #fff1d6;
  --bad: #a12621;
  --bad-bg: #fbe4e2;
  --focus: #1f63c9;
  --shadow: 0 1px 2px rgba(48, 35, 18, .06), 0 10px 28px rgba(48, 35, 18, .08);
  --band-under: #dbe8f6;
  --band-normal: #d8eedf;
  --band-over: #f8e8c2;
  --band-ob1: #f6d6c5;
  --band-ob2: #efbdb0;
  --band-ob3: #e7a59c;
  --band-track: #e7ddcd;
  --pill-under-bg: #dbe8f6;
  --pill-under-text: #173a5e;
  --pill-normal-bg: #d8eedf;
  --pill-normal-text: #12452a;
  --pill-over-bg: #f8e8c2;
  --pill-over-text: #5c3b00;
  --pill-ob1-bg: #f6d6c5;
  --pill-ob1-text: #652516;
  --pill-ob2-bg: #efbdb0;
  --pill-ob2-text: #5e1d14;
  --pill-ob3-bg: #e7a59c;
  --pill-ob3-text: #551a14;
  --radius: 18px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15120f;
  --bg-2: #1b1712;
  --card: #211d18;
  --card-2: #27221c;
  --text: #f6efe4;
  --muted: #cfc4b4;
  --border: #3e352a;
  --border-strong: #5b4d3c;
  --primary: #f0b47e;
  --primary-soft: #3a2a1d;
  --primary-ink: #2a1608;
  --accent: #f2c096;
  --ok: #8fd6a8;
  --ok-bg: #173a24;
  --warn: #ffd48a;
  --warn-bg: #3d2c0c;
  --bad: #ffaaa2;
  --bad-bg: #451b18;
  --focus: #9cc8ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .3);
  --band-under: #1b3348;
  --band-normal: #173a24;
  --band-over: #443414;
  --band-ob1: #47281b;
  --band-ob2: #54271e;
  --band-ob3: #622821;
  --band-track: #3a3228;
  --pill-under-bg: #1b3348;
  --pill-under-text: #cfe6ff;
  --pill-normal-bg: #173a24;
  --pill-normal-text: #c9f2d7;
  --pill-over-bg: #443414;
  --pill-over-text: #ffe3a4;
  --pill-ob1-bg: #47281b;
  --pill-ob1-text: #ffd7c6;
  --pill-ob2-bg: #54271e;
  --pill-ob2-text: #ffd2c5;
  --pill-ob3-bg: #622821;
  --pill-ob3-text: #ffccc3;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(760px 380px at 12% -8%, rgba(183, 114, 58, .12), transparent 68%),
    radial-gradient(620px 320px at 92% 2%, rgba(73, 128, 90, .10), transparent 70%);
}

[data-theme="dark"] body::before {
  background:
    radial-gradient(760px 380px at 12% -8%, rgba(240, 180, 126, .10), transparent 68%),
    radial-gradient(620px 320px at 92% 2%, rgba(120, 190, 145, .08), transparent 70%);
}

h1,
h2,
h3 {
  margin: 0 0 .35em;
  line-height: 1.18;
  letter-spacing: -.012em;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
}

h2 {
  font-size: clamp(1.2rem, 2.4vw, 1.45rem);
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 .75em;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--primary);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

strong {
  font-weight: 700;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  max-width: 100%;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.skip:focus {
  top: 12px;
}

/* header */

.site-header {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
}

.brand-mark {
  color: var(--primary);
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1rem;
  letter-spacing: -.01em;
}

.brand-text span {
  font-size: 12px;
  color: var(--muted);
}

.header-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.theme-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.theme-btn[aria-pressed="true"] {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.theme-text {
  display: none;
}

.theme-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  display: inline-block;
}

.theme-dot.auto {
  background: linear-gradient(90deg, #fffaf4 50%, #24201a 50%);
}

.theme-dot.light {
  background: #fffaf4;
}

.theme-dot.dark {
  background: #24201a;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 2px;
}

.lang-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.lang-link[aria-current="page"] {
  background: var(--primary);
  color: var(--primary-ink);
  font-weight: 700;
}

.lang-link:hover {
  color: var(--text);
}

.lang-link[aria-current="page"]:hover {
  color: var(--primary-ink);
}

/* banners and notices */

.banner {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.banner.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.banner.info,
.noscript {
  background: var(--primary-soft);
  color: var(--text);
}

.noscript {
  margin: 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.notice {
  position: fixed;
  z-index: 60;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.notice.ok {
  border-left: 5px solid var(--ok);
}

.notice.error {
  border-left: 5px solid var(--bad);
}

.notice.info {
  border-left: 5px solid var(--primary);
}

.link-btn {
  min-height: 44px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--primary);
  text-decoration: underline;
  font-weight: 700;
}

/* layout */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 16px 60px;
}

main > * + * {
  margin-top: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 24px);
  box-shadow: var(--shadow);
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.error {
  margin: 7px 0 0;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--bad-bg);
  color: var(--bad);
  font-size: 12px;
  font-weight: 650;
}

.warning {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-left: 4px solid var(--warn);
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12px;
}

.status {
  color: var(--ok);
  font-size: 12px;
  font-weight: 700;
}

/* hero */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, .65fr);
  gap: 20px;
  align-items: end;
  padding: 10px 2px 4px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
}

.hero h1 {
  margin-bottom: 8px;
}

.lead {
  max-width: 62ch;
  color: var(--muted);
  font-size: 15px;
}

.hero-note {
  margin: 0;
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
  background: color-mix(in srgb, var(--card) 65%, transparent);
  border-radius: 0 12px 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.hero-note strong {
  color: var(--text);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 34px;
  margin-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--text);
  font-size: 12px;
}

.chip-key {
  color: var(--muted);
  font-size: 12px;
}

.ref-chip {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
  color: var(--primary);
  font-weight: 650;
}

.warn-chip {
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 36%, var(--border));
  color: var(--warn);
  font-weight: 650;
}

/* kpis */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kpi {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card-2);
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .02em;
}

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 6px;
  font-size: clamp(1.65rem, 4.4vw, 2.15rem);
  font-weight: 750;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.kpi-value .unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.kpi .meta {
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.spark-wrap {
  margin-top: 6px;
  color: var(--primary);
  min-height: 26px;
}

.spark.good {
  color: var(--ok);
}

.spark.bad {
  color: var(--bad);
}

.trend {
  display: inline-flex;
  color: var(--muted);
}

.trend.good {
  color: var(--ok);
}

.trend.bad {
  color: var(--bad);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 6px;
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.pill.under {
  background: var(--pill-under-bg);
  color: var(--pill-under-text);
}

.pill.normal {
  background: var(--pill-normal-bg);
  color: var(--pill-normal-text);
}

.pill.over {
  background: var(--pill-over-bg);
  color: var(--pill-over-text);
}

.pill.ob1 {
  background: var(--pill-ob1-bg);
  color: var(--pill-ob1-text);
}

.pill.ob2 {
  background: var(--pill-ob2-bg);
  color: var(--pill-ob2-text);
}

.pill.ob3,
.pill.obese {
  background: var(--pill-ob3-bg);
  color: var(--pill-ob3-text);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.badge.muted {
  background: var(--bg-2);
  color: var(--muted);
}

.ring-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 8px auto 4px;
}

.ring-holder,
.ring {
  width: 100%;
  height: 100%;
  display: block;
}

.ring-track {
  fill: none;
  stroke: var(--band-track);
  stroke-width: 9;
}

.ring-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 9;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 52px 52px;
}

.ring.ok .ring-progress {
  stroke: var(--ok);
}

.ring.warn .ring-progress {
  stroke: var(--warn);
}

.ring-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.gauge-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  text-align: center;
}

.gauge-holder {
  width: min(360px, 100%);
  margin: 0 auto;
  color: var(--text);
}

.gauge {
  display: block;
  overflow: visible;
}

.gauge-track {
  fill: none;
  stroke: var(--band-track);
  stroke-width: 15;
  stroke-linecap: butt;
}

.gauge-band {
  fill: none;
  stroke-width: 15;
  stroke-linecap: butt;
}

.gauge-band.under {
  stroke: var(--band-under);
}

.gauge-band.normal {
  stroke: var(--band-normal);
}

.gauge-band.over {
  stroke: var(--band-over);
}

.gauge-band.ob1,
.gauge-band.obese {
  stroke: var(--band-ob1);
}

.gauge-band.ob2 {
  stroke: var(--band-ob2);
}

.gauge-band.ob3 {
  stroke: var(--band-ob3);
}

.gauge-cut {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.gauge-value {
  fill: var(--text);
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.gauge-hub {
  fill: var(--text);
}

.needle line {
  stroke: var(--text);
  stroke-width: 3;
  stroke-linecap: round;
}

.gauge .needle {
  transform: rotate(var(--angle));
  animation: needleSweep 900ms cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes needleSweep {
  from { transform: rotate(180deg); }
  to { transform: rotate(var(--angle)); }
}

.gauge-na {
  padding: 26px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
}

.screening-note {
  margin: 14px 0 0;
  padding: 8px 0 0 10px;
  border-left: 3px solid var(--primary);
  color: var(--muted);
  font-size: 12px;
}

.empty-dashboard {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.empty-dashboard .empty-art {
  width: 160px;
  height: auto;
  margin: 0 auto 6px;
  display: block;
  color: var(--border-strong);
}

/* forms */

.field {
  margin-bottom: 14px;
  min-width: 0;
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.field legend {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px var(--bad-bg);
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.unit-input {
  display: flex;
  align-items: stretch;
}

.unit-input input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 0;
  min-width: 0;
}

.unit-input span {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 10px 10px 0;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid var(--primary);
  border-radius: 10px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn.ghost {
  background: transparent;
  color: var(--primary);
}

.btn.ghost:hover {
  background: var(--primary-soft);
}

.btn.danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

[data-theme="dark"] .btn.danger {
  color: #2b0d0b;
}

.btn.small {
  min-height: 44px;
  padding: 7px 12px;
  font-size: 13px;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  filter: none;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.icon-btn:hover {
  background: var(--bg-2);
}

.danger-text {
  color: var(--bad);
}

.tag {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.tag[data-kind="ideal"] {
  background: var(--ok-bg);
  color: var(--ok);
}

.paed-fields {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-2);
}

.paed-fields legend {
  padding: 0 4px;
  color: var(--primary);
}

/* goal */

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.two-col > .card {
  margin: 0;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.plan-badge.clinical {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.goal-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 12px 0;
}

.goal-list > div {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-2);
  min-width: 0;
}

.goal-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.goal-list dd {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.status-detail {
  min-height: 1.5em;
  color: var(--muted);
  font-size: 13px;
}

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.plan-controls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

/* charts */

.range-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-2);
}

.range-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 7px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.range-btn[aria-pressed="true"] {
  background: var(--primary);
  color: var(--primary-ink);
}

.chart-block {
  margin-top: 14px;
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.chart-head h3 {
  margin: 0;
}

.chart-wrap {
  position: relative;
  min-width: 0;
  margin-top: 6px;
}

.chart {
  display: block;
  overflow: visible;
}

.chart .grid {
  stroke: var(--border);
  stroke-width: 1;
  opacity: .65;
}

.chart .axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chart .band-label {
  fill: var(--text);
  font-size: 12px;
  font-weight: 700;
  opacity: .9;
}

.chart .band {
  opacity: .82;
}

.chart .band-under {
  fill: var(--band-under);
}

.chart .band-normal {
  fill: var(--band-normal);
}

.chart .band-over {
  fill: var(--band-over);
}

.chart .band-ob1,
.chart .band-obese {
  fill: var(--band-ob1);
}

.chart .band-ob2 {
  fill: var(--band-ob2);
}

.chart .band-ob3 {
  fill: var(--band-ob3);
}

.chart .goal-band {
  fill: var(--primary);
  opacity: .13;
}

.chart .area {
  fill: var(--primary);
  opacity: .12;
}

.chart .line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart .ma {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
  stroke-dasharray: 2 5;
  stroke-linecap: round;
}

.chart .ideal-line {
  stroke: var(--ok);
  stroke-width: 1.8;
  stroke-dasharray: 5 4;
}

.chart .target-line {
  stroke: var(--primary);
  stroke-width: 1.8;
  stroke-dasharray: 4 4;
}

.chart .line-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.chart .pt {
  fill: var(--card);
  stroke: var(--primary);
  stroke-width: 2.4;
  cursor: pointer;
}

.chart .pt:focus {
  outline: none;
  stroke: var(--focus);
  stroke-width: 4;
  filter: drop-shadow(0 0 3px var(--focus));
}

.chart .crosshair {
  stroke: var(--focus);
  stroke-width: 1.4;
  stroke-dasharray: 3 3;
  opacity: .7;
  pointer-events: none;
}

.chart-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  max-width: 210px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--text);
  color: var(--card);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  z-index: 5;
}

.chart-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.chart-empty .empty-art {
  color: var(--border-strong);
}

/* history */

.count {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.actions {
  white-space: nowrap;
}

td.actions .icon-btn + .icon-btn {
  margin-left: 4px;
}

#history-body tr.is-new {
  animation: rowHighlight 2200ms ease-out;
}

@keyframes rowHighlight {
  0% { background: var(--primary-soft); }
  100% { background: transparent; }
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

#history-empty {
  padding: 10px 0;
}

/* reference and static content */

.reference-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
}

.reference-card summary::-webkit-details-marker {
  display: none;
}

.reference-card summary h2 {
  margin: 0;
  font-size: 1.1rem;
}

.reference-card summary h2::after {
  content: " +";
  color: var(--primary);
  font-weight: 800;
}

.reference-card details[open] summary h2::after {
  content: " -";
}

.reference-card p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.reference-card .note {
  padding: 8px 10px;
  border-left: 3px solid var(--primary);
  background: var(--card-2);
  border-radius: 0 8px 8px 0;
  color: var(--text);
}

.seo {
  padding: 8px 2px 0;
  content-visibility: auto;
  contain-intrinsic-size: auto 1100px;
}

.seo h2 {
  margin-top: 24px;
}

.seo h3 {
  margin-top: 20px;
}

.seo p {
  max-width: 78ch;
  color: var(--muted);
  font-size: 14px;
}

.seo .table-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.seo table {
  min-width: 560px;
  background: var(--card);
}

.faq {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.faq details {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.faq summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  font-size: 14px;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  color: var(--primary);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.faq details[open] summary::after {
  content: "-";
}

.faq p {
  margin: 8px 0 0;
  font-size: 13px;
}

/* footer */

.site-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px 40px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer p + p {
  margin-top: 4px;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* dialog */

.app-dialog {
  width: min(430px, calc(100% - 32px));
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 20px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .3);
}

.app-dialog::backdrop {
  background: rgba(20, 15, 10, .55);
  backdrop-filter: blur(2px);
}

.app-dialog h2 {
  margin-bottom: 6px;
  font-size: 1.25rem;
}

.app-dialog p {
  color: var(--muted);
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

/* responsive */

@media (min-width: 640px) {
  .theme-text {
    display: inline;
  }

  .kpi-grid {
    gap: 12px;
  }
}

@media (min-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .gauge-block {
    display: grid;
    grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
    gap: 20px;
    align-items: center;
    text-align: left;
  }

  .gauge-holder {
    margin: 0;
  }
}

@media (max-width: 760px) {
  .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .hero-note {
    border-left-width: 3px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .header-inner {
    align-items: flex-start;
  }

  .header-tools {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 520px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .kpi {
    padding: 10px;
  }

  .kpi-head {
    align-items: flex-start;
  }

  .goal-list {
    grid-template-columns: 1fr;
  }

  .range-switch {
    width: 100%;
  }

  .range-btn {
    flex: 1;
    padding-left: 6px;
    padding-right: 6px;
  }

  .notice {
    font-size: 13px;
  }
}

@media (max-width: 360px) {
  .history-card tbody tr {
    grid-template-columns: 1fr;
  }

  .brand-text span {
    display: none;
  }

  .theme-btn {
    padding-left: 8px;
    padding-right: 8px;
  }

  .lang-link {
    padding-left: 8px;
    padding-right: 8px;
  }
}


@media (max-width: 640px) {
  .history-card .table-wrap {
    overflow: visible;
  }

  .history-card table,
  .history-card tbody,
  .history-card tr,
  .history-card td {
    display: block;
    width: 100%;
  }

  .history-card thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .history-card tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px 12px;
    margin-bottom: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-2);
  }

  .history-card tbody tr:last-child {
    margin-bottom: 0;
  }

  .history-card td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  .history-card td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    flex: none;
  }

  .history-card td.num {
    text-align: right;
  }

  .history-card td.actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-top: 4px;
  }

  .history-card td.actions::before {
    content: none;
  }
}

@media (max-width: 360px) {
  .history-card tbody tr {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }

  .gauge .needle {
    animation: none;
    transform: rotate(var(--angle));
  }
}

@media print {
  @page {
    margin: 14mm;
  }

  :root {
    --bg: #fff;
    --card: #fff;
    --card-2: #fff;
    --text: #111;
    --muted: #444;
    --border: #bbb;
    --shadow: none;
  }

  body {
    background: #fff;
  }

  body::before,
  .skip,
  .site-header,
  .banner,
  .notice,
  .add-card,
  #profile-card,
  .charts-card,
  .plan-actions,
  .plan-controls,
  .history-actions,
  .reference-card,
  .seo,
  .site-footer,
  .theme-switch,
  .lang-switch,
  .chart-tip {
    display: none !important;
  }

  main {
    padding: 0;
    max-width: none;
  }

  main > * + * {
    margin-top: 10px;
  }

  .card {
    border: 1px solid #999;
    border-radius: 0;
    padding: 12px;
    break-inside: avoid;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .hero-note {
    display: none;
  }

  h1 {
    font-size: 24px;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .kpi {
    background: #fff;
  }

  .kpi-value {
    font-size: 22px;
  }

  .gauge-block {
    display: none;
  }

  .two-col {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .goal-card {
    break-inside: avoid;
  }

  table {
    font-size: 12px;
  }

  th:last-child,
  td:last-child {
    display: none;
  }

  #history-body tr {
    break-inside: avoid;
  }

  .screening-note {
    margin-top: 8px;
  }
}
