html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}
/* ===== Health tracker ===== */
:root {
  --surface: #fcfcfb;
  --page: #f6f6f3;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --axis: #c3c2b7;
  --series: #2a78d6;
  --good: #0ca30c;
  --good-text: #006300;
  --critical: #d03b3b;
  --figure: #dfe6ee;
  --figure-active: #2a78d6;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.navbar .nav-link { color: var(--ink-2); }
.navbar .nav-link.active { color: var(--ink); font-weight: 600; }

.page-head { margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.75rem; font-weight: 650; margin-bottom: .25rem; }

.card-section {
  background: var(--surface);
  border: 1px solid rgba(11, 11, 11, .08);
  border-radius: 12px;
  padding: 1.25rem;
}
.card-section h2 { font-weight: 600; }

.section-label {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .75rem;
  color: var(--ink-2);
  font-weight: 600;
}

/* --- stat tiles --- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .75rem;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid rgba(11, 11, 11, .08);
  border-radius: 12px;
  padding: .9rem 1rem;
}
.stat-label { font-size: .8rem; color: var(--ink-2); }
.stat-value { font-size: 1.75rem; font-weight: 600; line-height: 1.2; margin-top: .15rem; }
.stat-unit { font-size: .9rem; font-weight: 400; color: var(--ink-2); }
.stat-sub { font-size: .8rem; color: var(--ink-2); margin-top: .2rem; }

/* --- status badges (icon + text, never color alone) --- */
.status-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: .1rem .45rem;
  border-radius: 999px;
  white-space: nowrap;
}
.status-ok { background: #e3f4e3; color: var(--good-text); }
.status-out { background: #fbe4e4; color: #9b1f1f; }
.status-inline { color: #9b1f1f; font-weight: 700; margin-left: .15rem; }

/* --- marker cards --- */
.marker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem;
}
.marker-card {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  background: var(--surface);
  border: 1px solid rgba(11, 11, 11, .08);
  border-radius: 12px;
  padding: .85rem 1rem;
  color: inherit;
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.marker-card:hover, .marker-card:focus-visible {
  border-color: var(--series);
  box-shadow: 0 2px 10px rgba(42, 120, 214, .12);
  color: inherit;
}
.marker-card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.marker-name { font-weight: 600; }
.marker-value { display: flex; align-items: baseline; gap: .35rem; }
.marker-number { font-size: 1.35rem; font-weight: 600; }
.marker-unit { color: var(--ink-2); font-size: .85rem; }
.marker-date { color: var(--muted); font-size: .75rem; margin-left: auto; }
.marker-range { color: var(--muted); font-size: .75rem; }

/* --- trend chart (inline SVG from Charts/TrendChart.cs) --- */
.trend-chart { display: block; width: 100%; height: auto; overflow: visible; }
.trend-chart-mini { max-height: 64px; }
.chart-grid { stroke: var(--hairline); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-label { fill: var(--ink); font-size: 13px; font-weight: 600; }
.chart-band { fill: var(--good); fill-opacity: .1; }
.chart-band-edge { stroke: var(--good); stroke-opacity: .45; stroke-width: 1; }
.chart-goal { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart-dot-out { fill: var(--critical); }
.chart-hit { fill: transparent; }
.chart-pt:hover .chart-dot { stroke: var(--ink); stroke-width: 1.5; }
.chart-empty { color: var(--muted); font-size: .85rem; padding: 1rem 0; text-align: center; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 1rem; }
.chart-legend .key { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; margin-right: .3rem; }
.key-band { background: rgba(12, 163, 12, .15); border-top: 1px solid rgba(12, 163, 12, .5); border-bottom: 1px solid rgba(12, 163, 12, .5); }
.key-dot { background: var(--series); border-radius: 50%; }
.key-out { background: var(--critical); transform: rotate(45deg) scale(.85); }

/* --- tables --- */
.num-table td, .num-table th { white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta { color: var(--muted); font-size: .75rem; margin-left: .25rem; }
.notes-row td { border-top: 0; padding-top: 0; }

/* --- body measurement form --- */
.composition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .75rem 1rem;
}
.bd-label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .2rem; }
.bd-prev { font-size: .72rem; color: var(--muted); min-height: 1em; margin-top: .15rem; }
.bd-field input::placeholder { color: #b9b8b1; }

.body-diagram { position: relative; max-width: 760px; margin: 0 auto; }
.bd-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.bd-figure > * { fill: var(--figure); }
.bd-figure .limb { stroke: var(--figure); stroke-linecap: round; fill: none; }
.bd-side { fill: var(--muted); font-size: 12px; }
.bd-line { stroke: var(--axis); stroke-width: 1; transition: stroke .15s; }
.bd-dot { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.5; transition: fill .15s, r .15s; }
.bd-line.active { stroke: var(--figure-active); stroke-width: 2; }
.bd-dot.active { fill: var(--figure-active); stroke: var(--figure-active); r: 7; }
.bd-field.bd-col-left, .bd-field.bd-col-right {
  position: absolute;
  width: 31%;
  transform: translateY(-50%);
}
.bd-col-left { left: 0; text-align: right; }
.bd-col-right { right: 0; }
.bd-col-left .input-group { justify-content: flex-end; }

@media (max-width: 767.98px) {
  .body-diagram {
    aspect-ratio: auto !important;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem 1rem;
  }
  .bd-svg { display: none; }
  .bd-field.bd-col-left, .bd-field.bd-col-right {
    position: static;
    width: auto;
    transform: none;
    text-align: left;
    order: var(--order);
  }
  .bd-col-left .input-group { justify-content: flex-start; }
}

/* --- lab test rows --- */
.result-row { padding: .75rem 0; border-bottom: 1px solid var(--hairline); }
.result-row:first-child { padding-top: 0; }
.result-main {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1fr);
  gap: .75rem;
  align-items: end;
}
.result-info { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding-bottom: .45rem; }
.new-marker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem .75rem;
  margin-top: .6rem;
  padding: .75rem;
  background: #f1f5fb;
  border-radius: 8px;
}
.new-marker[hidden] { display: none; }
@media (max-width: 767.98px) {
  .result-main { grid-template-columns: 1fr 1fr; }
  .result-marker { grid-column: 1 / -1; }
  .new-marker { grid-template-columns: 1fr 1fr; }
}

/* --- vitals --- */
.vitals-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .75rem 1rem;
}
.vitals-notes { grid-column: span 2; }
@media (max-width: 575.98px) { .vitals-notes { grid-column: auto; } }

/* Large charts: SVG text scales with width, so enlarge it on phones. */
@media (max-width: 767.98px) {
  .trend-chart-large .chart-axis { font-size: 24px; }
  .trend-chart-large .chart-label { font-size: 26px; }
  .trend-chart-large .chart-line { stroke-width: 3.5; }
}
.row-unit:empty { display: none; }
.input-group:has(.row-unit:empty) > .form-control { border-radius: var(--bs-border-radius) !important; }
