/* ==========================================================================
   Community Medical Outreach — Prescription Records
   Mobile first: most of the team works from a phone or a tablet in the field,
   so the small-screen layout is the base and the desktop rules are additive.
   ========================================================================== */

:root {
    --green:        #16a34a;
    --green-dark:   #15803d;
    --green-soft:   #dcfce7;
    --teal:         #0ea5e9;
    --blue:         #1d4ed8;
    --blue-dark:    #1e3a8a;
    --blue-soft:    #eff6ff;
    --blue-ring:    rgba(29, 78, 216, .18);

    --ink:          #0f172a;
    --ink-soft:     #334155;
    --muted:        #64748b;
    --rule:         #e2e8f0;
    --rule-strong:  #cbd5e1;
    --bg:           #f4f7fb;
    --surface:      #ffffff;

    --amber:        #b45309;
    --amber-soft:   #fef3c7;
    --red:          #b91c1c;
    --red-soft:     #fee2e2;

    --brand-gradient: linear-gradient(90deg, #16a34a 0%, #0d9488 28%, #0ea5e9 62%, #1d4ed8 100%);

    --radius:       12px;
    --radius-sm:    8px;
    --shadow:       0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
    --shadow-sm:    0 1px 2px rgba(15, 23, 42, .08);

    --tap:          46px;   /* comfortable finger target */
}

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .98rem; }
p  { margin: 0 0 .75rem; }
a  { color: var(--blue); text-decoration: none; }
a:hover, a:focus-visible { color: var(--green-dark); text-decoration: underline; }

em { font-style: italic; }

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

/* ==========================================================================
   Masthead
   ========================================================================== */

.masthead {
    background: var(--brand-gradient);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 2px 12px rgba(15, 23, 42, .16);
}

.masthead__bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .9rem;
    max-width: 1240px;
    margin: 0 auto;
}

.masthead__brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #fff;
    min-width: 0;
    flex: 1;
}
.masthead__brand:hover, .masthead__brand:focus-visible { color: #fff; text-decoration: none; }

.masthead__mark {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .3);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: .82rem;
    letter-spacing: .02em;
}

.masthead__names { min-width: 0; }

.masthead__org {
    font-weight: 700;
    font-size: .96rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.masthead__tagline {
    font-size: .7rem;
    line-height: 1.3;
    color: rgba(255, 255, 255, .88);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.masthead__toggle {
    flex: none;
    width: var(--tap);
    height: var(--tap);
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .32);
    border-radius: 10px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    cursor: pointer;
}
.masthead__toggle:hover { background: rgba(255, 255, 255, .24); }
.masthead__toggle span, .masthead__toggle span::before, .masthead__toggle span::after {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    position: relative;
}
.masthead__toggle span::before, .masthead__toggle span::after {
    content: "";
    position: absolute;
}
.masthead__toggle span::before { top: -6px; }
.masthead__toggle span::after  { top: 6px; }

/* -- navigation ---------------------------------------------------------- */

.nav {
    display: none;
    background: rgba(0, 0, 0, .14);
    border-top: 1px solid rgba(255, 255, 255, .18);
    padding: .5rem .6rem .75rem;
}
.nav.is-open { display: block; }

.nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .25rem;
}

.nav__link {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-height: var(--tap);
    padding: .4rem .8rem;
    border-radius: 10px;
    color: rgba(255, 255, 255, .94);
    font-weight: 600;
    font-size: .95rem;
}
.nav__link:hover, .nav__link:focus-visible {
    background: rgba(255, 255, 255, .18);
    color: #fff;
    text-decoration: none;
}
.nav__link.is-active {
    background: #fff;
    color: var(--blue);
}

.nav__meta {
    margin-top: .5rem;
    padding-top: .6rem;
    border-top: 1px solid rgba(255, 255, 255, .2);
    display: grid;
    gap: .4rem;
    font-size: .82rem;
    color: rgba(255, 255, 255, .9);
}

.nav__who { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.nav__role {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: rgba(255, 255, 255, .2);
    padding: .12rem .45rem;
    border-radius: 999px;
}

.nav__signout {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, .4);
    background: transparent;
    color: #fff;
    border-radius: 8px;
    min-height: 38px;
    padding: 0 .8rem;
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
}
.nav__signout:hover { background: var(--green); border-color: var(--green); }

/* -- outreach selector --------------------------------------------------- */

.outreach-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
    padding: .55rem .9rem;
}

.outreach-bar__inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}

.outreach-bar__label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    flex: none;
}

.outreach-bar select {
    flex: 1 1 200px;
    min-width: 0;
}

.outreach-bar__none {
    color: var(--amber);
    font-size: .86rem;
    font-weight: 600;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 1rem .9rem 4rem;
}

.page__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.page__title { display: grid; gap: .15rem; min-width: 0; }
.page__sub { color: var(--muted); font-size: .87rem; }
.page__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    overflow: hidden;
}

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--rule);
    background: linear-gradient(180deg, #fbfdff, #f6f9fd);
}

.card__title { font-size: .95rem; font-weight: 700; }
.card__hint { font-size: .8rem; color: var(--muted); font-weight: 500; }
.card__body { padding: 1rem; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 1rem; }

/* ==========================================================================
   Buttons — primary is blue, and every button greens on hover.
   ========================================================================== */

.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: var(--tap);
    padding: 0 1.05rem;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--blue);
    color: #fff;
    font: inherit;
    font-size: .93rem;
    font-weight: 650;
    text-align: center;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
}
.btn:hover, .btn:focus-visible {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn--ghost {
    background: var(--surface);
    border-color: var(--rule-strong);
    color: var(--ink-soft);
}
.btn--ghost:hover, .btn--ghost:focus-visible {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.btn--danger { background: var(--red); }
.btn--danger:hover, .btn--danger:focus-visible { background: var(--green); border-color: var(--green); }

.btn--sm { min-height: 36px; padding: 0 .7rem; font-size: .84rem; border-radius: 8px; }
.btn--block { width: 100%; }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ==========================================================================
   Forms
   ========================================================================== */

.field { margin-bottom: .9rem; }

.field__label {
    display: block;
    font-size: .82rem;
    font-weight: 650;
    color: var(--ink-soft);
    margin-bottom: .3rem;
}

.field__label .req { color: var(--red); }

.field__hint { font-size: .76rem; color: var(--muted); margin-top: .28rem; }

.field__error {
    display: block;
    font-size: .78rem;
    color: var(--red);
    font-weight: 600;
    margin-top: .28rem;
}

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="tel"], input[type="search"], select, textarea {
    width: 100%;
    min-height: var(--tap);
    padding: .55rem .7rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    /* 16px keeps iOS from zooming the viewport when a field is focused. */
    font: inherit;
    font-size: 16px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

textarea { min-height: 88px; resize: vertical; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-ring);
}

input[readonly] { background: #f8fafc; color: var(--muted); }

.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%2364748b' d='M8 11 3.5 6.5 4.9 5.1 8 8.2l3.1-3.1 1.4 1.4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .6rem center;
    background-size: 16px;
    padding-right: 2rem;
}

.field-grid { display: grid; gap: 0 .8rem; grid-template-columns: 1fr; }

/* -- segmented choice (sex, age unit) ------------------------------------ */

.segmented { display: flex; gap: .4rem; }

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0 .6rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-weight: 650;
    font-size: .92rem;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.segmented label:hover { border-color: var(--green); color: var(--green-dark); }
.segmented input:checked + label {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}
.segmented input:focus-visible + label { box-shadow: 0 0 0 3px var(--blue-ring); }

/* -- checkbox ------------------------------------------------------------ */

.check {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-height: var(--tap);
    font-size: .92rem;
    font-weight: 600;
    color: var(--ink-soft);
    cursor: pointer;
}
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--blue); }

/* -- medication rows ----------------------------------------------------- */

.meds { display: grid; gap: .5rem; }

.med-row {
    display: grid;
    grid-template-columns: 28px 1fr 92px;
    gap: .4rem;
    align-items: center;
}

.med-row__no {
    font-size: .82rem;
    font-weight: 700;
    color: var(--muted);
    text-align: center;
}

.med-row input { min-height: 44px; }

.meds__head {
    display: none;
    grid-template-columns: 28px 1fr 92px;
    gap: .4rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    padding-bottom: .15rem;
}

/* -- sticky save bar ----------------------------------------------------- */

.form-actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    gap: .5rem;
    padding: .7rem .9rem calc(.7rem + env(safe-area-inset-bottom));
    margin: 1rem -.9rem -4rem;
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid var(--rule);
    backdrop-filter: blur(6px);
}
.form-actions .btn { flex: 1; }

/* ==========================================================================
   Flash + callouts
   ========================================================================== */

.flash {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .75rem .9rem;
    border-radius: var(--radius-sm);
    border: 1px solid;
    font-size: .9rem;
    font-weight: 550;
    margin-bottom: 1rem;
}
.flash--success { background: var(--green-soft); border-color: #86efac; color: #14532d; }
.flash--error   { background: var(--red-soft);   border-color: #fca5a5; color: #7f1d1d; }
.flash--info    { background: var(--blue-soft);  border-color: #bfdbfe; color: var(--blue-dark); }

.callout {
    padding: .8rem .9rem;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--rule-strong);
    background: #fbfdff;
    color: var(--ink-soft);
    font-size: .89rem;
}
.callout--warn { border-color: #fcd34d; background: var(--amber-soft); color: #78350f; }

/* ==========================================================================
   Stats
   ========================================================================== */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }

.stat {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: .75rem .8rem .8rem 1rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.stat::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--brand-gradient);
}
.stat__label {
    font-size: .67rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
}
.stat__value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--blue);
    line-height: 1.15;
    margin-top: .15rem;
}
.stat__note { font-size: .76rem; color: var(--muted); }

/* ==========================================================================
   Tables — they collapse into cards on a phone.
   ========================================================================== */

.table-wrap { width: 100%; overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

table.data th {
    text-align: left;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--rule);
    background: #f8fafc;
    white-space: nowrap;
}

table.data td {
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: top;
}

table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--blue-soft); }

.cell-strong { font-weight: 650; color: var(--ink); }
.cell-muted  { color: var(--muted); font-size: .84rem; }
.cell-clip {
    display: block;
    max-width: 26ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-actions { white-space: nowrap; text-align: right; }

/* -- card mode (phones) --------------------------------------------------- */

@media (max-width: 767px) {
    /* Compact buttons still have to be thumbable inside a row card. */
    .btn--sm { min-height: 42px; padding: 0 .9rem; }

    table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
    table.data thead { display: none; }

    table.data tr {
        border: 1px solid var(--rule);
        border-radius: var(--radius-sm);
        margin: 0 0 .6rem;
        padding: .3rem .1rem;
        background: var(--surface);
    }
    table.data tr:hover { background: var(--surface); }

    table.data td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        border-bottom: 1px dashed var(--rule);
        padding: .45rem .75rem;
    }
    table.data td:last-child { border-bottom: 0; }

    table.data td::before {
        content: attr(data-label);
        flex: none;
        font-size: .68rem;
        font-weight: 700;
        letter-spacing: .05em;
        text-transform: uppercase;
        color: var(--muted);
    }

    table.data td[data-label=""]::before { content: none; }

    .cell-clip { max-width: 60vw; text-align: right; }
    .cell-actions { text-align: right; }
}

/* ==========================================================================
   Badges, pills, lists
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge--blue  { background: var(--blue-soft);  color: var(--blue-dark); border-color: #bfdbfe; }
.badge--green { background: var(--green-soft); color: #14532d;          border-color: #86efac; }
.badge--amber { background: var(--amber-soft); color: var(--amber);     border-color: #fcd34d; }
.badge--red   { background: var(--red-soft);   color: var(--red);       border-color: #fca5a5; }
.badge--muted { background: #f1f5f9;           color: var(--muted);     border-color: var(--rule); }

.chip-list { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; list-style: none; }

.rank { list-style: none; margin: 0; padding: 0; }
.rank li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    padding: .5rem 0;
    border-bottom: 1px dashed var(--rule);
    font-size: .9rem;
}
.rank li:last-child { border-bottom: 0; }
.rank__count { font-weight: 700; color: var(--blue); font-variant-numeric: tabular-nums; }

.bar {
    height: 6px;
    border-radius: 999px;
    background: var(--brand-gradient);
    min-width: 4px;
}
.bar-track { flex: 1; height: 6px; background: #eef2f7; border-radius: 999px; overflow: hidden; }

.spark {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 64px;
    padding-top: .5rem;
}
.spark__bar {
    flex: 1;
    min-width: 4px;
    background: var(--brand-gradient);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
}
.spark__label { font-size: .68rem; color: var(--muted); text-align: center; }

.kv { display: grid; gap: .55rem; margin: 0; }
.kv__row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.kv__key { font-size: .78rem; color: var(--muted); font-weight: 600; }
.kv__val { font-weight: 650; text-align: right; }

.empty {
    text-align: center;
    padding: 2.25rem 1rem;
    color: var(--muted);
}
.empty h3 { color: var(--ink); margin-bottom: .35rem; }
.empty p { font-size: .9rem; }

/* ==========================================================================
   Filters + pagination
   ========================================================================== */

.filters { display: grid; gap: .6rem; grid-template-columns: 1fr; }
.filters__actions { display: flex; gap: .5rem; }
.filters__actions .btn { flex: 1; }

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .8rem 1rem;
    border-top: 1px solid var(--rule);
    font-size: .85rem;
    color: var(--muted);
}

/* ==========================================================================
   Sign in
   ========================================================================== */

.signin {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background:
        radial-gradient(1100px 520px at 12% -8%, rgba(22, 163, 74, .16), transparent 62%),
        radial-gradient(1100px 560px at 92% 6%, rgba(29, 78, 216, .18), transparent 60%),
        var(--bg);
}

.signin__card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.signin__banner {
    background: var(--brand-gradient);
    color: #fff;
    padding: 1.4rem 1.25rem;
    text-align: center;
}
.signin__org { font-weight: 800; font-size: 1.05rem; line-height: 1.25; }
.signin__tagline { font-size: .78rem; color: rgba(255, 255, 255, .92); margin-top: .3rem; }
.signin__body { padding: 1.25rem; }
.signin__foot {
    text-align: center;
    font-size: .78rem;
    color: var(--muted);
    padding: 0 1.25rem 1.25rem;
}

/* ==========================================================================
   Error page
   ========================================================================== */

.errorpage {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    text-align: center;
}
.errorpage__code {
    font-size: 3.4rem;
    font-weight: 800;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1;
}
.errorpage pre {
    text-align: left;
    font-size: .74rem;
    background: #0f172a;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow: auto;
    max-width: min(900px, 92vw);
    max-height: 40vh;
}

/* ==========================================================================
   Slip preview (records/show)
   ========================================================================== */

.slip {
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.slip__head {
    background: #0f172a;
    color: #fff;
    display: grid;
    grid-template-columns: 34px 1fr 74px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
}
.slip__head span { padding: .5rem .6rem; }
.slip__row {
    display: grid;
    grid-template-columns: 34px 1fr 74px;
    border-top: 1px solid var(--rule);
    font-size: .9rem;
}
.slip__row span { padding: .55rem .6rem; }
.slip__row span:first-child { color: var(--muted); font-weight: 700; text-align: center; }
.slip__row span:last-child { text-align: center; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Utilities
   ========================================================================== */

.muted   { color: var(--muted); }
.small   { font-size: .82rem; }
.strong  { font-weight: 700; }
.right   { text-align: right; }
.center  { text-align: center; }
.nowrap  { white-space: nowrap; }
.mt-0    { margin-top: 0; }
.mt-1    { margin-top: .75rem; }
.mb-0    { margin-bottom: 0; }
.mb-1    { margin-bottom: .75rem; }
.stack   { display: grid; gap: .75rem; }
.inline-form { display: inline; }
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Tablet and up
   ========================================================================== */

@media (min-width: 640px) {
    h1 { font-size: 1.6rem; }

    .stats { grid-template-columns: repeat(3, 1fr); }
    .field-grid--2 { grid-template-columns: repeat(2, 1fr); }
    .field-grid--3 { grid-template-columns: repeat(3, 1fr); }

    .filters { grid-template-columns: repeat(2, 1fr); }
    .filters__actions { grid-column: 1 / -1; }

    .meds__head { display: grid; }
    .med-row { grid-template-columns: 32px 1fr 120px; }

    .form-actions { justify-content: flex-end; }
    .form-actions .btn { flex: 0 0 auto; min-width: 148px; }
}

@media (min-width: 768px) {
    .page { padding: 1.5rem 1.25rem 4rem; }
    .card__body { padding: 1.15rem; }
}

@media (min-width: 900px) {
    .masthead__bar { padding: .55rem 1.25rem; }
    .masthead__toggle { display: none; }

    .nav {
        display: block;
        background: rgba(0, 0, 0, .12);
        border-top: 1px solid rgba(255, 255, 255, .16);
        padding: 0 1.25rem;
    }
    .nav__list {
        max-width: 1240px;
        margin: 0 auto;
        display: flex;
        gap: .15rem;
        align-items: center;
    }
    .nav__link {
        min-height: 42px;
        border-radius: 8px 8px 0 0;
        font-size: .89rem;
        padding: 0 .85rem;
    }
    .nav__link.is-active { background: var(--bg); color: var(--blue); }

    .nav__meta {
        margin: 0 0 0 auto;
        padding: 0;
        border: 0;
        display: flex;
        align-items: center;
        gap: .6rem;
    }
    .nav__who { gap: .45rem; }
    .nav__signout { min-height: 32px; font-size: .8rem; }

    .stats { grid-template-columns: repeat(5, 1fr); }
    .grid--split { grid-template-columns: 2fr 1fr; }
    .grid--halves { grid-template-columns: 1fr 1fr; }

    .filters { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: end; }
    .filters__actions { grid-column: auto; }

    .field-grid--4 { grid-template-columns: repeat(4, 1fr); }

    .form-actions {
        position: static;
        margin: 1rem 0 0;
        padding: 0;
        border: 0;
        background: none;
        backdrop-filter: none;
    }
}

/* ==========================================================================
   Print — the browser's own "print to PDF" of a record.
   ========================================================================== */

@media print {
    .masthead, .outreach-bar, .page__actions, .form-actions, .no-print { display: none !important; }
    body { background: #fff; }
    .page { padding: 0; max-width: none; }
    .card { border-color: #999; box-shadow: none; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
