:root {
  color-scheme: light;
  --page: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #142231;
  --muted: #536579;
  --line: #ced8e1;
  --line-strong: #9dabb9;
  --accent: #075fc7;
  --accent-dark: #074b98;
  --accent-soft: #e8f2ff;
  --nav: #10283e;
  --nav-hover: #1b466b;
  --focus: #ffbf47;
  --danger: #b42318;
  --danger-dark: #8f1d14;
  --danger-soft: #fff0ee;
  --good: #146c43;
  --good-soft: #e9f7ef;
  --warn: #805600;
  --warn-soft: #fff5d8;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 8px 26px rgb(18 39 57 / 8%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { min-height: 100%; margin: 0; background: var(--page); color: var(--ink); font-size: 1rem; line-height: 1.58; }
body, button, input, select, textarea { font: inherit; }
button, input, select, textarea { color: inherit; }
a { color: var(--accent-dark); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: .14em; }
img, svg { max-width: 100%; }
p, ul { max-width: 78ch; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; text-wrap: balance; }
h1 { margin: .25rem 0 1rem; font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.035em; }
h2 { margin: 0 0 .8rem; font-size: clamp(1.25rem, 2.3vw, 1.65rem); }
h3 { margin: 1.35rem 0 .55rem; font-size: 1.08rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip { position: fixed; z-index: 1000; top: .75rem; left: .75rem; transform: translateY(-180%); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); padding: .75rem 1rem; box-shadow: var(--shadow); }
.skip:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted, .metric-label, .confidence { color: var(--muted); }

.app { min-height: 100dvh; }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 17rem; overflow-y: auto; padding: calc(1.5rem + env(safe-area-inset-top)) 1.25rem calc(1.5rem + env(safe-area-inset-bottom)); background: var(--nav); color: #fff; }
.brand { display: grid; gap: .05rem; margin: 0 .45rem 2rem; color: #fff; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; text-decoration: none; }
.brand span { color: #bcd0e1; font-size: .76rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.nav { display: grid; gap: .35rem; }
.nav a, .nav button { display: flex; align-items: center; width: 100%; min-height: 48px; margin: 0; border: 0; border-radius: 12px; padding: .72rem .9rem; background: transparent; color: #e7f0f7; cursor: pointer; font-weight: 650; text-align: left; text-decoration: none; }
.nav a:hover, .nav button:hover, .nav a[aria-current="page"] { background: var(--nav-hover); color: #fff; }
.nav a[aria-current="page"] { box-shadow: inset 4px 0 0 #74b8ff; }
.nav form { margin: 0; padding: 0; border: 0; }

.main { min-height: 100dvh; margin-left: 17rem; padding: clamp(1.25rem, 3vw, 3rem); }
.main > * { width: min(100%, 78rem); margin-inline: auto; }
.main.login { display: grid; align-content: center; min-height: 100dvh; max-width: 34rem; margin: auto; padding: 1.25rem; }
.main.login > * { width: 100%; }
.bottom-tabs { display: none; }

.page-header, .topline, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-header { margin-bottom: 1rem; }
.page-header .activity-actions, .topline .button { flex: 0 0 auto; }
.eyebrow { margin: 0 0 .25rem; color: var(--muted); font-size: .76rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

.card { margin-block: 1rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: clamp(1.1rem, 2.5vw, 1.65rem); box-shadow: var(--shadow); }
.overview-card > p { font-size: 1.02rem; }
.section-heading { margin-bottom: .75rem; }
.status-stack { display: grid; justify-items: end; gap: .35rem; text-align: right; }
.status-badge { display: inline-flex; align-items: center; min-height: 28px; border: 1px solid var(--line-strong); border-radius: 999px; padding: .2rem .65rem; background: var(--surface-soft); font-size: .88rem; font-weight: 750; white-space: nowrap; }
.status-badge[data-status="met"] { border-color: #6fae8d; background: var(--good-soft); color: #0c5734; }
.status-badge[data-status="partial"], .status-badge[data-status="inconclusive"] { border-color: #c3a34e; background: var(--warn-soft); color: #624200; }
.status-badge[data-status="not_met"] { border-color: #d28a84; background: var(--danger-soft); color: #841b13; }
.confidence { font-size: .9rem; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: .75rem; margin-top: 1.25rem; }
.metric { min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); padding: .9rem 1rem; }
.metric-label { display: block; font-size: .86rem; font-weight: 650; }
.metric strong { display: block; margin-top: .15rem; font-size: clamp(1.15rem, 2.3vw, 1.45rem); line-height: 1.3; overflow-wrap: anywhere; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; border: 1px solid transparent; border-radius: 12px; padding: .68rem 1rem; background: var(--accent); color: #fff; cursor: pointer; font-weight: 750; line-height: 1.25; text-align: center; text-decoration: none; }
.button:hover { background: var(--accent-dark); }
.button.secondary { border-color: #a9c4df; background: var(--accent-soft); color: #123b60; }
.button.secondary:hover { background: #d7e9fb; }
.button.danger { background: var(--danger); color: #fff; }
.button.danger:hover { background: var(--danger-dark); }
.activity-actions, .form-actions, .training-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }

.field { display: grid; gap: .38rem; margin-block: .95rem; }
.field label { font-weight: 720; }
.field input, .field select, .field textarea, textarea { width: 100%; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 11px; background: #fff; padding: .7rem .8rem; }
.field textarea, textarea { min-height: 7rem; resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #65778a; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.profile-zone-grid, .zone-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }
.zone-grid > section { min-width: 0; }
.inline-form { margin-top: .75rem; }

.data-section { overflow: clip; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 3px 14px rgb(18 39 57 / 5%); }
.data-section > summary { min-height: 58px; cursor: pointer; padding: 1rem 1.15rem; background: var(--surface); }
.data-section > summary:hover { background: var(--surface-soft); }
.data-section > summary::marker { color: var(--accent); font-size: 1.1em; }
.data-section > summary h2 { display: inline; margin: 0; font-size: clamp(1.08rem, 2.2vw, 1.35rem); }
.data-section[open] > summary { border-bottom: 1px solid var(--line); background: var(--accent-soft); }
.data-section-content { padding: clamp(1rem, 2.5vw, 1.45rem); }
.section-summary { margin: 0 0 .65rem; }
.section-summary + .section-summary { color: var(--muted); }
.nested-details { margin-top: .85rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-soft); padding: .75rem .9rem; }
.nested-details summary { min-height: 32px; cursor: pointer; font-weight: 720; }
.evidence-list { padding-left: 1.3rem; }
.evidence-list li + li { margin-top: .55rem; }

.table-wrap { max-width: 100%; margin-block: 1rem; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
.table-wrap:focus-visible { outline-offset: 2px; }
table { width: 100%; min-width: 34rem; border-collapse: collapse; font-variant-numeric: tabular-nums; }
caption { padding: .78rem .85rem; background: var(--surface-soft); color: var(--ink); font-weight: 760; text-align: left; }
th, td { padding: .7rem .8rem; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { background: #f0f4f7; color: #33475a; font-size: .87rem; }
tbody th { font-weight: 680; }
tbody tr:nth-child(even) { background: #fafcfd; }

.training-list { display: grid; gap: .8rem; }
.training-table { min-width: 52rem; }
.training-table .training-actions { margin: 0; padding: 0; border: 0; flex-wrap: nowrap; gap: .45rem; }
.training-table .training-actions .button { min-height: 40px; padding: .5rem .7rem; font-size: .9rem; }
.training { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 1rem; }
.training-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; color: inherit; text-decoration: none; }
.training-main:hover h3 { color: var(--accent-dark); text-decoration: underline; text-underline-offset: .2em; }
.training h3 { margin: 0 0 .3rem; overflow-wrap: anywhere; }
.training-actions { margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }

.notice { max-width: none; border: 1px solid #a9c8e8; border-left: 5px solid var(--accent); border-radius: var(--radius-sm); background: #eef6ff; padding: .85rem 1rem; }
.notice.error, .error { border-color: #e2aaa5; border-left-color: var(--danger); background: var(--danger-soft); }
dl { display: grid; grid-template-columns: minmax(11rem, .8fr) minmax(0, 1.2fr); gap: .45rem 1rem; }
dt, dd { margin: 0; padding-block: .32rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.confirm-dialog { width: min(92vw, 36rem); max-height: min(88dvh, 46rem); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); padding: clamp(1.1rem, 3vw, 1.6rem); box-shadow: 0 24px 80px rgb(8 25 40 / 35%); }
.confirm-dialog::backdrop { background: rgb(8 25 40 / 62%); }
.confirm-dialog h2 { margin-top: 0; }

@media (max-width: 900px) {
  html { scroll-padding-bottom: 5.5rem; }
  .sidebar { display: none; }
  .main { margin: 0; padding: calc(1rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) calc(5.9rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
  .main.login { padding-bottom: calc(1.25rem + env(safe-area-inset-bottom)); }
  .bottom-tabs { position: fixed; z-index: 40; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--line); background: rgb(255 255 255 / 96%); padding: .35rem max(.25rem, env(safe-area-inset-right)) calc(.35rem + env(safe-area-inset-bottom)) max(.25rem, env(safe-area-inset-left)); box-shadow: 0 -8px 24px rgb(18 39 57 / 10%); }
  .bottom-tabs a { display: grid; place-items: center; min-width: 0; min-height: 50px; border-radius: 10px; padding: .25rem .2rem; color: #34495d; font-size: clamp(.68rem, 2.4vw, .82rem); font-weight: 680; line-height: 1.15; text-align: center; text-decoration: none; overflow-wrap: anywhere; }
  .bottom-tabs a[aria-current="page"] { background: var(--accent-soft); color: #073c70; }
  .card { box-shadow: none; }
  .page-header, .topline { align-items: stretch; }
  .profile-zone-grid, .zone-grid { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  body { line-height: 1.52; }
  .page-header, .topline, .section-heading { display: grid; }
  .status-stack { justify-items: start; text-align: left; }
  .activity-actions .button, .form-actions .button { flex: 1 1 9rem; }
  .metrics, .form-grid { grid-template-columns: 1fr; }
  dl { grid-template-columns: 1fr; gap: 0; }
  dd { padding-top: 0; color: var(--muted); }
  .training-main { grid-template-columns: 1fr; }
  .data-section > summary { padding: .9rem 1rem; }
  .data-section-content { padding: 1rem; }
  th, td { padding: .65rem .7rem; }
}

@media (max-width: 390px) {
  .bottom-tabs a { font-size: .67rem; }
  .main { padding-inline: max(.75rem, env(safe-area-inset-left)); }
}

@media (max-height: 500px) and (orientation: landscape) and (max-width: 900px) {
  .main { padding-bottom: calc(4.8rem + env(safe-area-inset-bottom)); }
  .bottom-tabs a { min-height: 42px; }
}

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

@media (prefers-contrast: more) {
  :root { --line: #788898; --muted: #34475a; --shadow: none; }
  .card, .data-section, .training, .table-wrap { border-width: 2px; }
}

@media (forced-colors: active) {
  .button, .status-badge, .nav a[aria-current="page"] { border: 2px solid currentColor; }
  .nav a[aria-current="page"] { box-shadow: none; }
  .confirm-dialog::backdrop { background: Canvas; opacity: .75; }
}

@media print {
  .sidebar, .bottom-tabs, .activity-actions, .skip { display: none !important; }
  .main { margin: 0; padding: 0; }
  .card, .data-section { box-shadow: none; break-inside: avoid; }
  .data-section:not([open]) > .data-section-content { display: block; }
}

