/* ==========================================================================
   MEDIIKX Care - design system
   --------------------------------------------------------------------------
   Built for the devices this platform actually runs on: a ₦25,000 Android
   phone on a 2G connection, a clinic desktop running an old browser, and a
   projector in a boardroom. So: no web fonts, no icon fonts, no external
   requests of any kind, one stylesheet, and every animation is transform or
   opacity only, so it stays smooth on a weak GPU and vanishes entirely for
   anyone who has asked for reduced motion.
   ========================================================================== */

/* --- tokens ------------------------------------------------------------- */
:root {
    /* A clinical teal that stays legible on cheap LCD panels, warmed with a
       Nigerian-flag-adjacent green so it reads as local, not imported. */
    --teal-50:  #eefbf7;
    --teal-100: #d3f4e9;
    --teal-200: #a8e8d5;
    --teal-300: #71d5bb;
    --teal-400: #3bbb9c;
    --teal-500: #1a9e82;
    --teal-600: #0f7f6a;
    --teal-700: #0d6557;
    --teal-800: #0e5047;
    --teal-900: #0c423b;
    --teal-950: #042623;

    --ink-50:  #f6f8f8;
    --ink-100: #eceff0;
    --ink-200: #d5dcde;
    --ink-300: #b0bcc0;
    --ink-400: #84979d;
    --ink-500: #647a81;
    --ink-600: #4f636a;
    --ink-700: #425258;
    --ink-800: #39464b;
    --ink-900: #333d41;
    --ink-950: #1b2225;

    --amber:   #d97706;
    --amber-l: #fef3c7;
    --rose:    #be123c;
    --rose-l:  #ffe4e6;
    --violet:  #6d28d9;
    --violet-l:#ede9fe;
    --sky:     #0369a1;
    --sky-l:   #e0f2fe;
    --green:   #15803d;
    --green-l: #dcfce7;

    --bg:          #ffffff;
    --bg-soft:     var(--ink-50);
    --bg-sunken:   #f1f5f5;
    --surface:     #ffffff;
    --surface-alt: var(--ink-50);
    --border:      var(--ink-200);
    --border-soft: var(--ink-100);
    --text:        var(--ink-950);
    --text-soft:   var(--ink-600);
    --text-faint:  var(--ink-400);
    --brand:       var(--teal-600);
    --brand-ink:   var(--teal-800);
    --brand-soft:  var(--teal-50);
    --on-brand:    #ffffff;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 999px;

    --shadow-xs: 0 1px 2px rgba(16, 33, 36, .06);
    --shadow-sm: 0 1px 3px rgba(16, 33, 36, .08), 0 1px 2px rgba(16, 33, 36, .04);
    --shadow:    0 4px 14px rgba(16, 33, 36, .08), 0 1px 3px rgba(16, 33, 36, .05);
    --shadow-lg: 0 18px 40px -12px rgba(16, 33, 36, .18), 0 4px 12px rgba(16, 33, 36, .06);
    --shadow-brand: 0 12px 30px -10px rgba(15, 127, 106, .45);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --ease: cubic-bezier(.22, .61, .36, 1);
    --ease-out-back: cubic-bezier(.34, 1.4, .64, 1);
    --dur: .28s;

    --sidebar-w: 250px;
    --header-h: 62px;
}

/* Dark palette - only ever applied explicitly via data-theme="dark", which
   is what the toggle button and its localStorage preference set. Light is
   always the default on first visit, regardless of the device's system
   theme; dark is opt-in only. */
:root[data-theme="dark"] {
    --bg:          #0c1416;
    --bg-soft:     #101a1d;
    --bg-sunken:   #0a1113;
    --surface:     #142024;
    --surface-alt: #182a2e;
    --border:      #24393e;
    --border-soft: #1c2d31;
    --text:        #e8f1f1;
    --text-soft:   #a2b6b9;
    --text-faint:  #6f868b;
    --brand:       var(--teal-400);
    --brand-ink:   var(--teal-200);
    --brand-soft:  #0d2b28;
    --on-brand:    #04211d;

    --amber-l: #3a2a06; --rose-l: #3d0d1c; --violet-l: #251445;
    --sky-l: #06283c;   --green-l: #08321a;
    --amber: #fbbf24;   --rose: #fb7185;  --violet: #a78bfa;
    --sky: #38bdf8;     --green: #4ade80;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.45);
    --shadow:    0 4px 16px rgba(0,0,0,.5);
    --shadow-lg: 0 20px 44px -14px rgba(0,0,0,.7);
    --shadow-brand: 0 12px 30px -12px rgba(59, 187, 156, .35);
}

/* --- reset -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
    font-family: var(--font);
    font-size: 15.5px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 680; letter-spacing: -.018em; }
h1 { font-size: clamp(1.85rem, 1.2rem + 2.4vw, 3.1rem); }
h2 { font-size: clamp(1.4rem, 1.05rem + 1.4vw, 2.1rem); }
h3 { font-size: 1.16rem; }
h4 { font-size: 1rem; }
p  { text-wrap: pretty; }
ul, ol { padding-left: 1.15rem; }

:focus-visible {
    outline: 2.5px solid var(--brand);
    outline-offset: 2px;
    border-radius: 4px;
}

::selection { background: var(--teal-200); color: var(--teal-950); }

/* --- layout primitives -------------------------------------------------- */
.wrap { width: min(1180px, calc(100% - 2.5rem)); margin-inline: auto; }
.wrap-narrow { width: min(760px, calc(100% - 2.5rem)); margin-inline: auto; }
.stack > * + * { margin-top: var(--gap, 1rem); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid { display: grid; gap: 1.15rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 900px) { .grid-sidebar { grid-template-columns: 1fr; } }
.spacer { flex: 1; }
.section { padding-block: clamp(3rem, 7vw, 6rem); }
.text-center { text-align: center; }
.hide-sm { }
@media (max-width: 720px) { .hide-sm { display: none !important; } }

/* --- typography helpers ------------------------------------------------- */
.eyebrow {
    display: inline-flex; align-items: center; gap: .5rem;
    font-size: .74rem; font-weight: 700; letter-spacing: .13em;
    text-transform: uppercase; color: var(--brand);
}
.eyebrow::before {
    content: ""; width: 22px; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, var(--brand), transparent);
}
.lede { font-size: 1.1rem; color: var(--text-soft); max-width: 62ch; }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.small { font-size: .86rem; }
.tiny  { font-size: .78rem; }
.mono  { font-family: var(--mono); font-size: .88em; letter-spacing: -.02em; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 650; }
.numeric { font-variant-numeric: tabular-nums; }

/* --- buttons ------------------------------------------------------------ */
.btn {
    --btn-bg: var(--brand);
    --btn-fg: var(--on-brand);
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .68rem 1.15rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-weight: 600; font-size: .94rem; line-height: 1.15;
    cursor: pointer; text-decoration: none;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
                background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
    box-shadow: var(--shadow-xs);
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1.5px); box-shadow: var(--shadow); text-decoration: none; }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-xs); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }

.btn-primary { box-shadow: var(--shadow-brand); }
.btn-primary:hover { background: var(--teal-700); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary:hover { background: var(--teal-300); } }

.btn-ghost { --btn-bg: transparent; --btn-fg: var(--text); border-color: var(--border); box-shadow: none; }
.btn-ghost:hover { --btn-bg: var(--surface-alt); border-color: var(--ink-300); }

.btn-soft { --btn-bg: var(--brand-soft); --btn-fg: var(--brand-ink); box-shadow: none; }
.btn-soft:hover { --btn-bg: var(--teal-100); }

.btn-danger { --btn-bg: var(--rose); --btn-fg: #fff; }
.btn-danger:hover { filter: brightness(.93); }

.btn-lg { padding: .92rem 1.6rem; font-size: 1.02rem; border-radius: var(--radius-lg); }
.btn-sm { padding: .42rem .8rem; font-size: .84rem; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

/* The emergency button is deliberately unmistakable and slightly alive. */
.btn-emergency {
    --btn-bg: var(--rose); --btn-fg: #fff;
    font-weight: 750; letter-spacing: .02em;
    box-shadow: 0 0 0 0 rgba(190, 18, 60, .5);
    animation: emergency-pulse 2.4s var(--ease) infinite;
}
@keyframes emergency-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(190, 18, 60, .45); }
    70%  { box-shadow: 0 0 0 14px rgba(190, 18, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(190, 18, 60, 0); }
}

/* --- cards -------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 1.35rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border); }
.card-flush { padding: 0; overflow: hidden; }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1.05rem 1.35rem; border-bottom: 1px solid var(--border-soft);
}
.card-head h3 { font-size: 1.02rem; }
.card-body { padding: 1.35rem; }
.card-foot { padding: .9rem 1.35rem; border-top: 1px solid var(--border-soft); background: var(--surface-alt); }

/* --- stat tiles --------------------------------------------------------- */
.stat {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.25rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat::after {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
    background: linear-gradient(180deg, var(--brand), transparent);
    opacity: .8;
}
.stat-label { font-size: .76rem; font-weight: 640; letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint); }
.stat-value {
    font-size: clamp(1.6rem, 1.2rem + 1.1vw, 2.15rem);
    font-weight: 700; letter-spacing: -.03em; line-height: 1.1;
    font-variant-numeric: tabular-nums; margin-top: .3rem;
}
.stat-note { font-size: .82rem; color: var(--text-soft); margin-top: .2rem; }
.stat-rose::after   { background: linear-gradient(180deg, var(--rose), transparent); }
.stat-amber::after  { background: linear-gradient(180deg, var(--amber), transparent); }
.stat-sky::after    { background: linear-gradient(180deg, var(--sky), transparent); }
.stat-violet::after { background: linear-gradient(180deg, var(--violet), transparent); }

/* --- badges and pills --------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: .34rem;
    padding: .2rem .58rem;
    border-radius: var(--radius-full);
    font-size: .74rem; font-weight: 640; letter-spacing: .01em;
    background: var(--surface-alt); color: var(--text-soft);
    border: 1px solid var(--border-soft);
    white-space: nowrap;
}
.badge-brand  { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.badge-green  { background: var(--green-l); color: var(--green); border-color: transparent; }
.badge-amber  { background: var(--amber-l); color: var(--amber); border-color: transparent; }
.badge-rose   { background: var(--rose-l);  color: var(--rose);  border-color: transparent; }
.badge-sky    { background: var(--sky-l);   color: var(--sky);   border-color: transparent; }
.badge-violet { background: var(--violet-l);color: var(--violet);border-color: transparent; }
.badge-dot::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex: none;
}
.badge-live::before { animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* Risk bands - the visual language repeats everywhere risk is shown. */
.risk-low      { background: var(--green-l); color: var(--green); }
.risk-moderate { background: var(--amber-l); color: var(--amber); }
.risk-high     { background: #ffedd5; color: #c2410c; }
.risk-critical { background: var(--rose-l); color: var(--rose); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .risk-high { background: #3d2408; color: #fb923c; }
}

/* --- tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
    width: 100%; border-collapse: collapse; font-size: .9rem;
}
table.data th {
    text-align: left; font-weight: 640; font-size: .74rem;
    letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint);
    padding: .65rem .8rem; border-bottom: 1px solid var(--border);
    white-space: nowrap; position: sticky; top: 0; background: var(--surface);
}
table.data td { padding: .72rem .8rem; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.data tbody tr { transition: background-color .16s var(--ease); }
table.data tbody tr:hover { background: var(--surface-alt); }
table.data tbody tr:last-child td { border-bottom: 0; }
.table-empty { padding: 2.6rem 1rem; text-align: center; color: var(--text-faint); }

/* --- forms -------------------------------------------------------------- */
.field { display: block; }
.field + .field { margin-top: 1rem; }
.label {
    display: block; font-size: .82rem; font-weight: 620;
    color: var(--text-soft); margin-bottom: .35rem;
}
.label .req { color: var(--rose); }
.input, .select, .textarea {
    width: 100%;
    padding: .68rem .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background-color .18s var(--ease);
    font-size: .95rem;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-300); }
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--brand) 18%, transparent);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.select { appearance: none; padding-right: 2.2rem;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
    background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.hint { font-size: .8rem; color: var(--text-faint); margin-top: .3rem; }
.error-text { font-size: .82rem; color: var(--rose); margin-top: .3rem; }
.input-error { border-color: var(--rose); }

.check {
    display: flex; align-items: flex-start; gap: .6rem;
    padding: .7rem .85rem; border: 1px solid var(--border-soft);
    border-radius: var(--radius); cursor: pointer;
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.check:hover { border-color: var(--brand); background: var(--brand-soft); }
.check input { margin-top: .18rem; accent-color: var(--brand); width: 17px; height: 17px; flex: none; }
.check-title { font-weight: 600; font-size: .92rem; }
.check-note  { font-size: .81rem; color: var(--text-soft); }
.check input:checked ~ .check-body .check-title { color: var(--brand-ink); }

fieldset { border: 0; padding: 0; }
legend { font-weight: 650; font-size: .95rem; padding: 0; margin-bottom: .6rem; }

/* --- alerts ------------------------------------------------------------- */
.alert {
    display: flex; gap: .75rem; align-items: flex-start;
    padding: .9rem 1.05rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-soft);
    background: var(--surface-alt);
    font-size: .92rem;
    animation: slide-in .35s var(--ease-out-back) both;
}
.alert-success { background: var(--green-l); color: var(--green); border-color: transparent; }
.alert-error   { background: var(--rose-l);  color: var(--rose);  border-color: transparent; }
.alert-warn    { background: var(--amber-l); color: var(--amber); border-color: transparent; }
.alert-info    { background: var(--sky-l);   color: var(--sky);   border-color: transparent; }
.alert strong { font-weight: 700; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* The AI provenance marker. Anything a model produced wears this, always. */
.ai-tag {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .16rem .5rem; border-radius: var(--radius-full);
    background: var(--violet-l); color: var(--violet);
    font-size: .71rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.ai-block {
    border: 1px dashed var(--violet); border-radius: var(--radius);
    background: color-mix(in srgb, var(--violet-l) 55%, transparent);
    padding: 1rem 1.1rem;
}
.ai-block .disclaimer { font-size: .8rem; color: var(--text-soft); margin-top: .6rem; font-style: italic; }

/* --- public site -------------------------------------------------------- */
.site-header {
    position: sticky; top: 0; z-index: 60;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(150%) blur(12px);
    -webkit-backdrop-filter: saturate(150%) blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color .3s var(--ease), background-color .3s var(--ease);
}
.site-header.is-stuck { border-bottom-color: var(--border-soft); box-shadow: var(--shadow-xs); }
.site-nav { display: flex; align-items: center; gap: 1.5rem; height: 66px; }
.site-nav .links { display: flex; gap: 1.35rem; align-items: center; }
.site-nav a.nav-link {
    color: var(--text-soft); font-weight: 550; font-size: .93rem;
    text-decoration: none; position: relative; padding-block: .35rem;
}
.site-nav a.nav-link::after {
    content: ""; position: absolute; left: 0; right: 100%; bottom: 0; height: 2px;
    background: var(--brand); border-radius: 2px;
    transition: right .3s var(--ease);
}
.site-nav a.nav-link:hover { color: var(--text); }
.site-nav a.nav-link:hover::after, .site-nav a.nav-link.active::after { right: 0; }
.site-nav a.nav-link.active { color: var(--brand-ink); }

.logo { display: inline-flex; align-items: center; gap: .55rem; font-weight: 760; letter-spacing: -.03em; font-size: 1.08rem; color: var(--text); text-decoration: none; }
.logo:hover { text-decoration: none; }
.logo-mark {
    width: 30px; height: 30px; border-radius: 9px; flex: none;
    background: linear-gradient(140deg, var(--teal-400), var(--teal-700));
    display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .95rem;
    box-shadow: var(--shadow-brand);
}
.logo .sub { font-weight: 500; color: var(--text-faint); font-size: .78rem; letter-spacing: 0; }

.nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .4rem .55rem; cursor: pointer; }
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .28s var(--ease), opacity .2s; }
.nav-toggle span + span { margin-top: 4px; }
.nav-open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 900px) {
    .nav-toggle { display: block; }
    .site-nav .links {
        position: absolute; left: 0; right: 0; top: 66px;
        flex-direction: column; align-items: stretch; gap: 0;
        background: var(--surface); border-bottom: 1px solid var(--border);
        padding: .5rem 1.25rem 1.25rem;
        box-shadow: var(--shadow-lg);
        clip-path: inset(0 0 100% 0); opacity: 0; pointer-events: none;
        transition: clip-path .35s var(--ease), opacity .25s var(--ease);
    }
    .nav-open .site-nav .links { clip-path: inset(0 0 0 0); opacity: 1; pointer-events: auto; }
    .site-nav .links a.nav-link { padding: .8rem 0; border-bottom: 1px solid var(--border-soft); }
    .site-nav .links .btn { margin-top: .8rem; }
}

/* --- hero --------------------------------------------------------------- */
.hero {
    position: relative; overflow: hidden;
    padding-block: clamp(3.5rem, 9vw, 7rem);
    background:
        radial-gradient(120% 90% at 8% -10%, var(--brand-soft) 0%, transparent 58%),
        radial-gradient(90% 70% at 100% 0%, color-mix(in srgb, var(--sky-l) 60%, transparent) 0%, transparent 55%);
}
.hero::before {
    /* A very quiet aurora. It moves slowly enough to feel calm, not busy. */
    content: ""; position: absolute; inset: -35% -10% auto -10%; height: 130%;
    background:
        radial-gradient(closest-side, color-mix(in srgb, var(--teal-300) 32%, transparent), transparent) 18% 30% / 46% 58% no-repeat,
        radial-gradient(closest-side, color-mix(in srgb, var(--teal-500) 22%, transparent), transparent) 78% 12% / 40% 52% no-repeat;
    filter: blur(38px); opacity: .55; z-index: 0;
    animation: drift 26s var(--ease) infinite alternate;
}
@keyframes drift {
    from { transform: translate3d(0,0,0) scale(1); }
    to   { transform: translate3d(-3%, 3%, 0) scale(1.09); }
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { max-width: 17ch; }
.hero .lede { font-size: clamp(1.02rem, .96rem + .4vw, 1.22rem); margin-top: 1.1rem; }
.hero-actions { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 1.9rem; }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 3rem; align-items: center; }
@media (max-width: 940px) { .hero-grid { grid-template-columns: 1fr; gap: 2.4rem; } }

/* The phone mock in the hero: a real USSD screen, not a stock image. */
.handset {
    width: min(280px, 78vw); margin-inline: auto;
    background: var(--ink-950); border-radius: 30px; padding: 12px;
    box-shadow: var(--shadow-lg), 0 0 0 1.5px rgba(255,255,255,.06) inset;
    transform: perspective(900px) rotateY(-11deg) rotateX(3deg);
    transition: transform .6s var(--ease);
}
.handset:hover { transform: perspective(900px) rotateY(-3deg) rotateX(1deg) translateY(-5px); }
.handset-screen {
    background: #0a1a17; border-radius: 20px; padding: 1.15rem 1rem;
    min-height: 320px; color: #b8f5e2;
    font-family: var(--mono); font-size: .8rem; line-height: 1.65;
    display: flex; flex-direction: column;
}
.handset-screen .ussd-line { opacity: 0; animation: type-in .5s var(--ease) forwards; }
.handset-screen .ussd-line:nth-child(1) { animation-delay: .25s; }
.handset-screen .ussd-line:nth-child(2) { animation-delay: .55s; }
.handset-screen .ussd-line:nth-child(3) { animation-delay: .8s; }
.handset-screen .ussd-line:nth-child(4) { animation-delay: 1.05s; }
.handset-screen .ussd-line:nth-child(5) { animation-delay: 1.3s; }
.handset-screen .ussd-line:nth-child(6) { animation-delay: 1.55s; }
.handset-screen .ussd-line:nth-child(7) { animation-delay: 1.8s; }
@keyframes type-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.handset-caption { text-align: center; margin-top: .9rem; font-size: .82rem; color: var(--text-faint); }

/* --- feature cards ------------------------------------------------------ */
.feature {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    background: var(--surface);
    position: relative; overflow: hidden;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.feature::before {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(150deg, var(--brand-soft), transparent 62%);
    opacity: 0; transition: opacity var(--dur) var(--ease);
}
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.feature:hover::before { opacity: 1; }
.feature > * { position: relative; }
.feature h3 { margin-bottom: .45rem; }
.feature p { color: var(--text-soft); font-size: .93rem; }
.feature-icon {
    width: 42px; height: 42px; border-radius: 12px; margin-bottom: .95rem;
    display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand-ink);
    transition: transform var(--dur) var(--ease-out-back);
}
.feature:hover .feature-icon { transform: scale(1.08) rotate(-4deg); }
.feature-icon svg { width: 21px; height: 21px; }

/* --- flow diagram ------------------------------------------------------- */
.flow { display: grid; gap: .75rem; counter-reset: step; }
.flow-step {
    display: grid; grid-template-columns: 38px 1fr; gap: 1rem; align-items: start;
    padding: 1rem 1.15rem; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border-soft);
    transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.flow-step:hover { transform: translateX(4px); border-color: var(--brand); }
.flow-step::before {
    counter-increment: step; content: counter(step);
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--brand); color: var(--on-brand);
    font-weight: 700; font-size: .88rem;
}
.flow-step h4 { margin-bottom: .15rem; }
.flow-step p { font-size: .9rem; color: var(--text-soft); }

/* --- problem statistics ------------------------------------------------- */
.stat-hero {
    padding: 1.6rem 1.5rem; border-radius: var(--radius-lg);
    background: var(--surface); border: 1px solid var(--border-soft);
    border-left: 4px solid var(--rose);
}
.stat-hero .figure {
    font-size: clamp(2rem, 1.5rem + 2vw, 2.9rem); font-weight: 750;
    letter-spacing: -.035em; line-height: 1; color: var(--rose);
    font-variant-numeric: tabular-nums;
}
.stat-hero .desc { margin-top: .5rem; font-size: .94rem; color: var(--text-soft); }
.stat-hero .source { margin-top: .6rem; font-size: .76rem; color: var(--text-faint); }

/* --- app shell ---------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    background: var(--surface); border-right: 1px solid var(--border-soft);
    display: flex; flex-direction: column; position: sticky; top: 0;
    height: 100vh; height: 100dvh; /* dvh accounts for mobile browser chrome, so the sheet isn't taller than what's actually visible */
    overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.sidebar-brand { padding: 1.05rem 1.15rem; border-bottom: 1px solid var(--border-soft); }
.sidebar-nav { padding: .85rem .7rem; flex: 1; }
.nav-group + .nav-group { margin-top: 1.15rem; }
.nav-group-label {
    font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
    color: var(--text-faint); padding: 0 .55rem .4rem;
}
.nav-item {
    display: flex; align-items: center; gap: .65rem;
    padding: .58rem .6rem; border-radius: var(--radius-sm);
    color: var(--text-soft); font-size: .91rem; font-weight: 540;
    text-decoration: none; position: relative;
    transition: background-color .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.nav-item:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; transform: translateX(2px); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 620; }
.nav-item.active::before {
    content: ""; position: absolute; left: -.7rem; top: 20%; bottom: 20%; width: 3px;
    background: var(--brand); border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item .count {
    margin-left: auto; font-size: .72rem; font-weight: 700;
    background: var(--rose); color: #fff; border-radius: var(--radius-full);
    padding: .05rem .42rem; min-width: 20px; text-align: center;
}
.sidebar-foot { padding: .85rem .85rem calc(.85rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border-soft); }

/* The mobile scrim. It must be display:none on desktop, or it participates in
   the app grid and takes the sidebar's column. */
.app-backdrop { display: none; }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.app-header {
    height: var(--header-h); display: flex; align-items: center; gap: 1rem;
    padding-inline: 1.35rem; border-bottom: 1px solid var(--border-soft);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 40;
}
.app-header h1 { font-size: 1.14rem; font-weight: 660; letter-spacing: -.02em; }
.app-content { padding: 1.5rem 1.35rem 3.5rem; flex: 1; }
@media (max-width: 980px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 90;
        transform: translateX(-100%); transition: transform .3s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .app.sidebar-open .sidebar { transform: none; }
    .app-backdrop {
        display: block;
        position: fixed; inset: 0; background: rgba(6, 20, 22, .5); z-index: 80;
        opacity: 0; pointer-events: none; transition: opacity .3s var(--ease);
        backdrop-filter: blur(2px);
    }
    .app.sidebar-open .app-backdrop { opacity: 1; pointer-events: auto; }
    .sidebar-toggle { display: inline-flex !important; }
    /* Room for the fixed bottom tab bar so the last bit of content, and any
       floating action, is never hidden behind it. */
    .app-content { padding-bottom: calc(5.4rem + env(safe-area-inset-bottom)); }
}
.sidebar-toggle { display: none; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }

/* --- bottom tab bar (mobile app shell) ----------------------------------- */
.bottom-nav {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-soft);
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 20px rgba(16, 33, 36, .06);
}
@media (max-width: 980px) {
    .bottom-nav { display: flex; align-items: stretch; justify-content: space-around; }
}
.bottom-nav-item {
    appearance: none; border: 0; background: none; cursor: pointer;
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: .2rem; padding: .4rem .2rem .3rem; border-radius: var(--radius);
    color: var(--text-faint); font: inherit; font-size: .68rem; font-weight: 620;
    transition: color .2s var(--ease), transform .15s var(--ease);
}
.bottom-nav-icon { display: flex; transition: transform .2s var(--ease-out-back); }
.bottom-nav-label { line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bottom-nav-item.active { color: var(--brand); }
.bottom-nav-item.active .bottom-nav-icon { transform: translateY(-1px) scale(1.08); }
.bottom-nav-item:active { transform: scale(.92); }

/* --- top progress bar (page navigation / async requests) ---------------- */
.page-loader {
    position: fixed; top: 0; left: 0; height: 3px; width: 0%; z-index: 300;
    background: linear-gradient(90deg, var(--teal-400), var(--brand));
    box-shadow: 0 0 8px color-mix(in srgb, var(--brand) 60%, transparent);
    opacity: 0; transition: width .35s var(--ease), opacity .2s linear;
    pointer-events: none;
}
.page-loader.is-active { opacity: 1; }
.page-loader.is-done { width: 100% !important; opacity: 0; transition: width .2s var(--ease), opacity .4s linear .15s; }

/* --- touch feedback, mobile-app feel ------------------------------------- */
.btn, .nav-item, .nav-toggle, .sidebar-toggle, .avatar, a.logo {
    transition: transform .15s var(--ease), background-color .2s var(--ease),
        border-color .2s var(--ease), box-shadow .2s var(--ease), color .2s var(--ease);
}
.btn:active, .sidebar-toggle:active, .nav-toggle:active { transform: scale(.96); }
.nav-item:active { transform: scale(.98); }

/* --- light / dark toggle -------------------------------------------------
   Two stacked icons cross-fade and rotate into each other; only opacity and
   transform move, so it stays cheap on the low-end hardware this runs on. */
.theme-toggle {
    position: relative; flex: none; width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--radius-full);
    background: var(--surface); color: var(--text-soft); cursor: pointer;
}
.theme-toggle-sm { width: 30px; height: 30px; }
.theme-toggle-icon {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    transition: opacity .25s var(--ease), transform .35s var(--ease);
}
.theme-toggle-icon-moon { opacity: 0; transform: rotate(-70deg) scale(.5); }
:root[data-theme="dark"] .theme-toggle-icon-sun { opacity: 0; transform: rotate(70deg) scale(.5); }
:root[data-theme="dark"] .theme-toggle-icon-moon { opacity: 1; transform: none; }
.theme-toggle { transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease), transform .15s var(--ease); }
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }
.theme-toggle:active { transform: scale(.9); }

/* A brief, capped color transition on the elements that actually carry the
   theme's colors - not a blanket `* { transition }`, which would be costly
   on the low-end hardware this app targets. Elements that already define
   their own transition (bottom nav, buttons, nav items) keep those as-is,
   since those already include color. */
body, .app, .sidebar, .app-header, .app-content, .card, .surface, .stat,
.site-header, .toast {
    transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease);
}

/* --- app-content entrance --------------------------------------------- */
@keyframes app-content-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}
.app-content { animation: app-content-in .32s var(--ease) both; }

.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    background: linear-gradient(140deg, var(--teal-400), var(--teal-700));
    color: #fff; display: grid; place-items: center;
    font-weight: 700; font-size: .82rem; letter-spacing: -.02em;
}
.avatar-lg { width: 52px; height: 52px; font-size: 1.05rem; }

/* --- page header -------------------------------------------------------- */
.page-head { margin-bottom: 1.5rem; }
.page-head h2 { letter-spacing: -.025em; }
.page-head p { color: var(--text-soft); margin-top: .3rem; max-width: 70ch; }

/* --- timeline ----------------------------------------------------------- */
.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before {
    content: ""; position: absolute; left: 6px; top: .4rem; bottom: .4rem; width: 2px;
    background: linear-gradient(180deg, var(--border), transparent);
    border-radius: 2px;
}
.tl-item { position: relative; padding-bottom: 1.35rem; }
.tl-item::before {
    content: ""; position: absolute; left: -1.6rem; top: .42rem;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--surface); border: 2.5px solid var(--brand);
    box-shadow: 0 0 0 3px var(--bg);
}
.tl-item.tl-emergency::before { border-color: var(--rose); }
.tl-item.tl-lab::before       { border-color: var(--sky); }
.tl-item.tl-chw::before       { border-color: var(--amber); }
.tl-item.tl-rx::before        { border-color: var(--violet); }
.tl-time { font-size: .78rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.tl-title { font-weight: 620; margin-top: .1rem; }
.tl-body { font-size: .9rem; color: var(--text-soft); margin-top: .18rem; }
.tl-meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .45rem; }

/* --- emergency state machine rail --------------------------------------- */
.states { display: flex; gap: 0; overflow-x: auto; padding-bottom: .5rem; }
.state-node {
    flex: 1; min-width: 108px; text-align: center; position: relative;
    padding-top: 1.9rem; font-size: .78rem; color: var(--text-faint);
}
.state-node::before {
    content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--surface); border: 2.5px solid var(--border); z-index: 2;
}
.state-node::after {
    content: ""; position: absolute; top: 14px; left: 50%; width: 100%; height: 2.5px;
    background: var(--border); z-index: 1;
}
.state-node:last-child::after { display: none; }
.state-node.done::before { background: var(--brand); border-color: var(--brand); }
.state-node.done::after  { background: var(--brand); }
.state-node.done { color: var(--text); font-weight: 600; }
.state-node.current::before {
    border-color: var(--rose); background: var(--rose);
    animation: emergency-pulse 2s var(--ease) infinite;
}
.state-node.current { color: var(--rose); font-weight: 700; }
.state-time { display: block; font-size: .7rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* --- charts (dependency-free, drawn as inline SVG) ---------------------- */
.chart { width: 100%; }
.chart-line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
    stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: draw 1.5s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart-area { fill: url(#chartFade); opacity: 0; animation: fade-in .8s var(--ease) .5s forwards; }
@keyframes fade-in { to { opacity: 1; } }
.chart-grid { stroke: var(--border-soft); stroke-width: 1; }
.chart-label { fill: var(--text-faint); font-size: 10px; font-family: var(--font); }
.chart-dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }

.bar-row { display: grid; grid-template-columns: minmax(90px, 1.1fr) 3fr auto; gap: .8rem; align-items: center; padding: .45rem 0; font-size: .88rem; }
.bar-track { height: 9px; background: var(--surface-alt); border-radius: var(--radius-full); overflow: hidden; }
.bar-fill {
    height: 100%; border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--teal-400), var(--teal-600));
    transform-origin: left; animation: bar-grow .9s var(--ease) both;
}
@keyframes bar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* --- reveal on scroll --------------------------------------------------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .65s var(--ease), transform .65s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal-d1 { transition-delay: .08s; }
.reveal-d2 { transition-delay: .16s; }
.reveal-d3 { transition-delay: .24s; }
.reveal-d4 { transition-delay: .32s; }

/* --- misc --------------------------------------------------------------- */
.divider { height: 1px; background: var(--border-soft); border: 0; margin-block: 1.35rem; }
.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: .45rem 1rem; font-size: .91rem; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; font-weight: 540; }
.chip-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.code-block {
    background: var(--ink-950); color: var(--teal-200); border-radius: var(--radius);
    padding: 1rem 1.1rem; font-family: var(--mono); font-size: .82rem; overflow-x: auto;
    line-height: 1.7;
}
.empty {
    text-align: center; padding: 3rem 1.5rem; color: var(--text-faint);
    border: 1.5px dashed var(--border); border-radius: var(--radius-lg);
}
.empty h3 { color: var(--text-soft); margin-bottom: .35rem; }

.toast-host { position: fixed; right: 1.15rem; bottom: 1.15rem; z-index: 200; display: grid; gap: .55rem; max-width: 340px; }
.toast {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .8rem 1rem; box-shadow: var(--shadow-lg); font-size: .9rem;
    animation: slide-in .3s var(--ease-out-back) both;
}

.skeleton {
    background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border-soft) 37%, var(--surface-alt) 63%);
    background-size: 400% 100%; animation: shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm); height: 1em;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.offline-banner {
    position: fixed; left: 50%; bottom: 1rem; transform: translate(-50%, 150%);
    background: var(--ink-950); color: #fff; padding: .6rem 1.1rem;
    border-radius: var(--radius-full); font-size: .86rem; font-weight: 600;
    box-shadow: var(--shadow-lg); z-index: 150;
    transition: transform .35s var(--ease-out-back);
}
.offline-banner.show { transform: translate(-50%, 0); }

/* --- print -------------------------------------------------------------- */
@media print {
    .sidebar, .app-header, .site-header, .btn, .toast-host, .no-print { display: none !important; }
    .app { grid-template-columns: 1fr; }
    .card, .stat { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    body { background: #fff; color: #000; font-size: 11pt; }
}

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