/* ===========================================================================
   The signed-in console: sidebar, top bar, content column.

   Shared by all three gates. Only --accent changes between them, which is set
   inline by the layout, so this file never needs to know which gate it is in.
   =========================================================================== */

:root {
    --side-w:        260px;
    --side-w-thin:   68px;
    --ink:           #14161c;
    --ink-2:         #4a5160;
    --ink-3:         #7b8496;
    --line:          #e4e7ee;
    --line-soft:     #eef0f5;
    --paper:         #ffffff;
    --canvas:        #f5f6fa;
    --ok:            #157347;
    --warn:          #b45309;
    --err:           #b42318;
    --radius:        12px;
    --radius-sm:     8px;
    --shadow-sm:     0 1px 2px rgba(16, 20, 35, .06), 0 1px 3px rgba(16, 20, 35, .04);
    --shadow-md:     0 4px 12px rgba(16, 20, 35, .07), 0 1px 3px rgba(16, 20, 35, .05);
    --speed:         .18s;
}

* { box-sizing: border-box; }

body.console {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font: 15px/1.55 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.skip {
    position: absolute; left: -999px;
    background: var(--accent); color: #fff; padding: .6rem 1rem; z-index: 100;
    border-radius: 0 0 var(--radius-sm) 0;
}
.skip:focus { left: 0; top: 0; }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.shell {
    display: grid;
    grid-template-columns: var(--side-w) minmax(0, 1fr);
    min-height: 100vh;
}

.shell.side-is-collapsed { grid-template-columns: var(--side-w-thin) minmax(0, 1fr); }

.main-col { display: flex; flex-direction: column; min-width: 0; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.side {
    position: sticky; top: 0;
    display: flex; flex-direction: column;
    height: 100vh;
    /* The deep accent is the gate's own colour, so a glance at the edge of the
       screen tells you which system you are in. */
    background: linear-gradient(180deg, var(--accent-deep), #0f1220 82%);
    color: #dfe3ee;
    overflow: hidden;
}

.side-brand {
    display: flex; align-items: center; gap: .7rem;
    padding: 1.05rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
    flex-shrink: 0;
}

.side-brand .mark {
    display: grid; place-items: center;
    width: 36px; height: 36px; flex-shrink: 0;
    border-radius: 10px;
    background: var(--accent);
    color: #fff; font-weight: 700; font-size: 1.05rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

.side-brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-brand-text strong { color: #fff; font-size: .95rem; white-space: nowrap; }
.side-brand-text small  { color: #9aa3ba; font-size: .74rem; white-space: nowrap; }

.side-nav { flex: 1; overflow-y: auto; padding: .6rem .5rem 1rem; }

/* Thin scrollbar, so a long menu does not gain a heavy grey bar. */
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 3px; }

.side-group { margin-bottom: .15rem; }

.side-group > summary {
    display: flex; align-items: center; gap: .65rem;
    padding: .58rem .65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: #c3cadb;
    font-size: .8rem; font-weight: 600;
    letter-spacing: .02em;
    list-style: none;
    user-select: none;
    transition: background var(--speed), color var(--speed);
}

.side-group > summary::-webkit-details-marker { display: none; }
.side-group > summary:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-group > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.side-group .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }

.side-group-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-group .chev {
    width: 14px; height: 14px; flex-shrink: 0; opacity: .55;
    transition: transform var(--speed);
}
.side-group[open] > summary .chev { transform: rotate(180deg); }
.side-group[open] > summary { color: #fff; }

.side-items { list-style: none; margin: .1rem 0 .35rem; padding: 0 0 0 2.05rem; }

.side-items a {
    display: block;
    padding: .42rem .6rem;
    margin-bottom: 1px;
    border-radius: 6px;
    color: #a8b1c6;
    font-size: .84rem;
    text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background var(--speed), color var(--speed);
}

.side-items a:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.side-items a.is-current {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-weight: 600;
    /* The bar reads as "you are here" even for someone who cannot separate the
       highlight colour from the background. */
    box-shadow: inset 3px 0 0 var(--accent);
}

.side-collapse {
    /* An icon button in the brand row — the control that changes the sidebar
       sits on the sidebar's own header, not in a bar of its own. */
    display: grid; place-items: center;
    width: 30px; height: 30px; flex-shrink: 0;
    margin-left: auto;
    padding: 0;
    border: 0; border-radius: 8px;
    background: transparent;
    color: #a8b1c6;
    cursor: pointer;
    transition: background var(--speed), color var(--speed);
}
.side-collapse:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.side-collapse:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.side-collapse svg { width: 18px; height: 18px; transition: transform var(--speed); }

/* The section holding the page you are on keeps its icon lit, so the sidebar
   answers "where am I" even before it is opened. */
.side-group.is-here > summary .ico,
.side-solo.is-current .ico { color: #fff; opacity: 1; }
.side-group.is-here > summary { color: #e8ebf5; }

/* ── Collapsed: icons only ──────────────────────────────────────────────── */

.side-is-collapsed .side-brand-text,
.side-is-collapsed .side-group-label,
.side-is-collapsed .side-group .chev { display: none; }

.side-is-collapsed .side-brand {
    flex-direction: column; gap: .55rem;
    justify-content: center; padding: .9rem 0 .7rem;
}
.side-is-collapsed .side-brand .mark { width: 32px; height: 32px; font-size: .95rem; }
.side-is-collapsed .side-collapse { margin-left: 0; }
.side-is-collapsed .side-group > summary { justify-content: center; padding-inline: 0; }
.side-is-collapsed .side-collapse svg { transform: scaleX(-1); }

/* Collapsed sections still open — the links show as a compact stack rather
   than disappearing, so nothing becomes unreachable. */
.side-is-collapsed .side-items { padding-left: .35rem; }
.side-is-collapsed .side-items a { font-size: .72rem; padding: .3rem .4rem; text-align: center; }

/* ── Top bar ────────────────────────────────────────────────────────────── */

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 1rem;
    padding: .7rem 1.4rem;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title strong { font-size: .95rem; }

.side-toggle {
    display: none;
    padding: .4rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--paper); color: var(--ink); cursor: pointer;
}
.side-toggle svg { width: 20px; height: 20px; display: block; }

.topbar-user { display: flex; align-items: center; gap: .7rem; }
.topbar-user .who { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-user .who strong { font-size: .84rem; }
.topbar-user .who small  { color: var(--ink-3); font-size: .72rem; }

.avatar {
    display: grid; place-items: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #fff;
    font-size: .8rem; font-weight: 700;
}

/* ── Content ────────────────────────────────────────────────────────────── */

.content { flex: 1; padding: 1.6rem 1.4rem 2.5rem; max-width: 1380px; width: 100%; }

.page-head { margin-bottom: 1.2rem; }
.page-head h1 { margin: 0 0 .25rem; font-size: 1.5rem; letter-spacing: -.01em; }
.page-head h2 { margin: 1.6rem 0 .25rem; font-size: 1.15rem; }
.page-head p  { margin: 0; color: var(--ink-2); max-width: 68ch; }

.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1.1rem;
}

.panel > h2 { margin: 0 0 .3rem; font-size: 1rem; }
.panel > h2 + .muted { margin-top: -.1rem; }

.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem;
}
.panel-head h2 { margin: 0; }

.app-footer { padding: 1rem 1.4rem 1.6rem; color: var(--ink-3); font-size: .78rem; }
.app-footer p { margin: 0; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

.table-scroll { overflow-x: auto; margin: 0 -.35rem; padding: 0 .35rem; }

table { width: 100%; border-collapse: collapse; font-size: .87rem; }

thead th {
    text-align: left;
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--line);
    color: var(--ink-3);
    font-size: .72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em;
    white-space: nowrap;
}

tbody td { padding: .62rem .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }

td strong { display: block; }
td small  { display: block; }

.muted { color: var(--ink-2); }
.muted.small, .small { font-size: .8rem; }
small.muted { color: var(--ink-3); font-size: .76rem; }

code {
    background: var(--line-soft);
    padding: .08rem .32rem; border-radius: 4px;
    font-size: .8em; color: var(--ink-2);
}

/* ── Pills ──────────────────────────────────────────────────────────────── */

.pill {
    display: inline-block;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: var(--line-soft); color: var(--ink-2);
    font-size: .7rem; font-weight: 600;
    white-space: nowrap;
}

.pill-active    { background: #e6f4ec; color: var(--ok); }
.pill-suspended { background: #fdecea; color: var(--err); }
.pill-warn      { background: #fdf3e3; color: var(--warn); }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .5rem .95rem;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    font: inherit; font-size: .85rem; font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--speed), border-color var(--speed), color var(--speed);
}

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--paper); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink-3); }
.btn-ghost     { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-danger    { background: transparent; border-color: #f0c4bf; color: var(--err); }
.btn-danger:hover { background: #fdecea; }
.btn-small     { padding: .3rem .6rem; font-size: .78rem; }
.btn-inline    { margin-left: auto; }

.actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: flex-start; }
.actions form { display: inline; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */

.tabs {
    display: flex; align-items: center; gap: .3rem;
    margin-bottom: 1rem; flex-wrap: wrap;
    border-bottom: 1px solid var(--line);
}

.tab {
    padding: .5rem .9rem;
    border-bottom: 2px solid transparent;
    color: var(--ink-2); font-size: .87rem; font-weight: 600;
    text-decoration: none;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Forms ──────────────────────────────────────────────────────────────── */

label { display: block; margin-bottom: .85rem; font-size: .85rem; font-weight: 600; }
label > small, label > span.muted { display: block; font-weight: 400; margin-top: .15rem; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=search], select, textarea {
    width: 100%;
    margin-top: .28rem;
    padding: .5rem .65rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--paper); color: var(--ink);
    font: inherit; font-size: .87rem;
    transition: border-color var(--speed), box-shadow var(--speed);
}

input:focus, select:focus, textarea:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

textarea { resize: vertical; min-height: 4.5rem; }

.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: auto; margin: 0; }
.check-inline { display: inline-flex; margin-right: .9rem; }

fieldset {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: .9rem 1rem; margin: 0 0 1.1rem;
}
legend { padding: 0 .4rem; font-size: .82rem; font-weight: 700; color: var(--ink-2); }

.form-stack   { max-width: 780px; }
.form-inline  { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; }
.form-inline label { margin-bottom: 0; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: .4rem; }

.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; }

.error { color: var(--err); font-weight: 600; display: block; margin-top: .2rem; }

/* ── Alerts, empties ────────────────────────────────────────────────────── */

.alert {
    padding: .7rem 1rem; margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    border-left: 3px solid;
    font-size: .87rem;
}
.alert-notice { background: #eef7f1; border-color: var(--ok);  color: #14532d; }
.alert-error  { background: #fdecea; border-color: var(--err); color: #7f1d1d; }

.empty { text-align: center; padding: 2.4rem 1rem; }
.empty h2 { margin: 0 0 .3rem; font-size: 1.05rem; }
.empty p  { margin: 0 auto 1rem; color: var(--ink-2); max-width: 46ch; }

/* ── Stat tiles ─────────────────────────────────────────────────────────── */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }

.stat {
    background: var(--paper);
    border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: .9rem 1rem;
}
.stat .k { color: var(--ink-3); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 1.7rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.stat .n { color: var(--ink-3); font-size: .76rem; }

/* ── Small screens: the sidebar becomes a drawer ────────────────────────── */

.side-scrim { display: none; }

@media (max-width: 900px) {
    .shell, .shell.side-is-collapsed { grid-template-columns: minmax(0, 1fr); }

    .side {
        position: fixed; inset: 0 auto 0 0; z-index: 40;
        width: var(--side-w);
        transform: translateX(-100%);
        transition: transform var(--speed) ease-out;
    }

    .side-is-open .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }

    /* On a phone the drawer is already the collapse control. */
    .side-collapse { display: none; }
    .side-toggle   { display: block; }

    .side-scrim {
        display: block; position: fixed; inset: 0; z-index: 30;
        background: rgba(10, 12, 22, .5);
    }
    .side-scrim[hidden] { display: none; }

    .content { padding: 1.1rem .9rem 2rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ── Filter bar ─────────────────────────────────────────────────────────── */

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .5rem .9rem;
    align-items: end;
}
.filters label { margin-bottom: 0; font-size: .78rem; }
.filters input, .filters select { font-size: .82rem; padding: .38rem .5rem; }
.filters .check { align-self: center; padding-top: 1rem; }
.filter-actions { display: flex; gap: .4rem; align-self: end; }

/* ── Pager ──────────────────────────────────────────────────────────────── */

.pager { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .9rem; }
.pager a {
    min-width: 2rem; padding: .3rem .5rem;
    border: 1px solid var(--line); border-radius: 6px;
    color: var(--ink-2); font-size: .8rem; text-align: center; text-decoration: none;
}
.pager a:hover { border-color: var(--ink-3); color: var(--ink); }
.pager a.is-current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ── Odds and ends ──────────────────────────────────────────────────────── */

.mt { margin-top: .9rem; }
ul.plain { list-style: none; margin: .4rem 0 0; padding: 0; }
ul.plain li { padding: .15rem 0; }
details > summary { cursor: pointer; }
a { color: var(--accent); }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }

/* ── Dashboard ──────────────────────────────────────────────────────────── */

.stat-link { text-decoration: none; color: inherit; display: block; transition: border-color var(--speed), box-shadow var(--speed); }
.stat-link:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.1rem;
    align-items: start;
}
.dash-grid .panel { margin-bottom: 0; }

/* The attention queue: a count, what it is, and where to deal with it. */
.queue { list-style: none; margin: 0; padding: 0; }

.queue-row a, .queue-flat {
    display: flex; align-items: center; gap: .8rem;
    padding: .55rem .3rem;
    border-bottom: 1px solid var(--line-soft);
    color: inherit; text-decoration: none;
}
.queue-row:last-child a, .queue-row:last-child .queue-flat { border-bottom: 0; }
.queue-row a:hover { background: #fafbfd; }

/* Not a link because the screen does not exist yet — say so by feel. */
.queue-flat { cursor: default; opacity: .75; }

.queue-count {
    display: grid; place-items: center;
    min-width: 2.1rem; height: 2.1rem; padding: 0 .4rem;
    border-radius: 8px;
    font-size: .95rem; font-weight: 700;
}
.queue-serious { background: #fdecea; color: var(--err); }
.queue-warn    { background: #fdf3e3; color: var(--warn); }
.queue-muted   { background: var(--line-soft); color: var(--ink-2); }
.queue-zero    { background: #eef7f1; color: var(--ok); }

.queue-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.queue-text strong { font-size: .86rem; font-weight: 600; }
.queue-text small  { font-size: .76rem; }
.queue-row.is-clear .queue-text strong { font-weight: 500; color: var(--ink-2); }

/* This month, with last month beside it. */
.month-rows { margin-bottom: .5rem; }

.month-row {
    display: grid; grid-template-columns: 1fr auto 3.6rem;
    align-items: baseline; gap: .6rem;
    padding: .45rem 0;
    border-bottom: 1px solid var(--line-soft);
}
.month-row:last-child { border-bottom: 0; }
.month-k { color: var(--ink-2); font-size: .85rem; }
.month-v { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.month-d { font-size: .78rem; font-weight: 600; text-align: right; }

/* An arrow as well as a colour, so the direction survives a colour-blind
   reader and a black-and-white print. */
.tone-up::before   { content: "▲ "; }
.tone-down::before { content: "▼ "; }
.tone-up   { color: var(--ok); }
.tone-down { color: var(--err); }
.tone-flat { color: var(--ink-3); }

h3.sub { margin: 1.1rem 0 .3rem; font-size: .82rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }

/* Diary, latest scans, recent activity all read as a time-ordered list. */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
    display: grid; grid-template-columns: 5.2rem 1fr auto;
    align-items: center; gap: .7rem;
    padding: .5rem 0;
    border-bottom: 1px solid var(--line-soft);
}
.timeline li:last-child { border-bottom: 0; }
.timeline.compact li { grid-template-columns: 6.8rem 1fr; padding: .35rem 0; }
.tl-time { color: var(--ink-3); font-size: .78rem; font-variant-numeric: tabular-nums; }
.tl-body { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.tl-body strong { font-size: .86rem; font-weight: 600; }
.tl-body small  { font-size: .76rem; }

.headcount { display: flex; gap: 1.6rem; flex-wrap: wrap; color: var(--ink-2); font-size: .88rem; }
.headcount strong { font-size: 1.15rem; color: var(--ink); margin-right: .2rem; }

.panel svg { max-width: 100%; height: auto; }

@media (max-width: 560px) {
    .timeline li { grid-template-columns: 4.4rem 1fr; }
    .timeline li .pill { grid-column: 2; justify-self: start; }
}

/* A section with a single item is a link, not an accordion — same shape as a
   group header so the column still reads as one list. */
.side-solo {
    display: flex; align-items: center; gap: .65rem;
    padding: .58rem .65rem;
    margin-bottom: .15rem;
    border-radius: var(--radius-sm);
    color: #c3cadb;
    font-size: .8rem; font-weight: 600;
    text-decoration: none;
    transition: background var(--speed), color var(--speed);
}
.side-solo:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-solo.is-current {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}
.side-is-collapsed .side-solo { justify-content: center; padding-inline: 0; }

/* ── The list header: title, count, and the Add button ──────────────────── */

.list-head { margin-bottom: 1rem; }

/* The action sits on the heading's own line, not below it. Explicit rather
   than relying on a button happening to be narrow enough not to wrap. */
.list-head-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem;
}
.list-head-row h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.01em; }
.list-head-row .btn { flex-shrink: 0; }
.list-head > p { margin: .25rem 0 0; color: var(--ink-2); }

/* ── Drawer ─────────────────────────────────────────────────────────────── */

.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer[hidden] { display: none; }

.drawer-scrim {
    position: absolute; inset: 0;
    background: rgba(10, 12, 22, .45);
    animation: drawer-fade var(--speed) ease-out;
}

.drawer-panel {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: min(560px, 100%);
    display: flex; flex-direction: column;
    background: var(--paper);
    box-shadow: -12px 0 40px rgba(10, 12, 22, .22);
    animation: drawer-in .22s cubic-bezier(.2, .8, .3, 1);
}

.drawer-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.3rem;
    border-bottom: 1px solid var(--line);
    /* The accent bar ties the panel to the gate it belongs to. */
    box-shadow: inset 0 3px 0 var(--accent);
    flex-shrink: 0;
}
.drawer-head-text h2 { margin: 0 0 .15rem; font-size: 1.15rem; letter-spacing: -.01em; }
.drawer-head-text p  { margin: 0; color: var(--ink-2); font-size: .84rem; max-width: 46ch; }

.drawer-close {
    display: grid; place-items: center;
    width: 32px; height: 32px; flex-shrink: 0;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--paper); color: var(--ink-2);
    cursor: pointer;
    transition: background var(--speed), color var(--speed);
}
.drawer-close:hover { background: var(--line-soft); color: var(--ink); }
.drawer-close svg { width: 16px; height: 16px; }

.drawer-body { flex: 1; overflow-y: auto; padding: 1.2rem 1.3rem 2rem; }
.drawer-body .panel { border: 0; box-shadow: none; padding: 0; margin: 0; background: none; }
.drawer-body .form-stack { max-width: none; }

/* The submit row stays reachable on a long form. */
.drawer-body .form-actions {
    position: sticky; bottom: -2rem;
    margin: 1.2rem -1.3rem -2rem;
    padding: .9rem 1.3rem;
    background: var(--paper);
    border-top: 1px solid var(--line);
}

@keyframes drawer-in   { from { transform: translateX(100%); } to { transform: none; } }
@keyframes drawer-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .drawer-panel, .drawer-scrim { animation: none; }
}

@media (max-width: 620px) {
    .drawer-panel { width: 100%; }
}

/* ── Pager bar ──────────────────────────────────────────────────────────── */

.pager-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
    margin-top: .9rem; padding-top: .8rem;
    border-top: 1px solid var(--line-soft);
}
.pager-count { margin: 0; flex: 1; min-width: 12rem; }
.pager-size { display: flex; align-items: center; gap: .4rem; }
.pager-size label { display: flex; align-items: center; gap: .4rem; margin: 0; font-size: .78rem; font-weight: 500; color: var(--ink-2); }
.pager-size select { width: auto; margin: 0; padding: .25rem 1.6rem .25rem .5rem; font-size: .8rem; }
.pager-gap { padding: .3rem .2rem; color: var(--ink-3); }

/* ── Overrides for app.css, which loads first ───────────────────────────────
   app.css is the public website's stylesheet. The console still borrows a
   handful of its classes (reports, trends, remedies), so it cannot simply be
   dropped — but two of its rules are written for a narrow sign-in form and
   wreck a toolbar:

     .btn-primary { width: 100%; margin-top: 1.5rem; }

   which turned "+ Add a client" into a full-width purple bar. Buttons in the
   console size to their label; a form's submit opts back in where it wants to
   fill the width. */
.console .btn { width: auto; margin: 0; }

/* Icons are 18px everywhere in the sidebar. Without this the single-item links
   fell through to the SVG's intrinsic size and rendered as huge empty squares. */
.side .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }

/* ---- scan grid -------------------------------------------------------------
   The dense entry screen for disciplines whose entry_layout is 'grid' — today
   only the aura scan, at 34 fields per sitting. Rows are deliberately tight:
   the whole point is to see the previous readings and today's box together and
   tab straight down the column, rather than scroll a roomy form ten screens. */

.scan-grid { font-size: .85rem; }

.scan-grid thead th { padding: .4rem .5rem; }
.scan-grid tbody td,
.scan-grid tbody th { padding: .18rem .5rem; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }

.scan-grid .sg-label { text-align: left; font-weight: 500; color: var(--ink-2); white-space: normal; }
.scan-grid .sg-label label { display: block; margin: 0; font: inherit; cursor: pointer; }

/* Past readings sit quiet — they are reference, not the thing being filled in. */
.scan-grid .sg-past  { width: 4.5rem; text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.scan-grid .sg-today { width: 7rem; }
.scan-grid .sg-range { width: 7rem; color: var(--ink-3); font-size: .78rem; white-space: nowrap; }

.scan-grid .sg-today input,
.scan-grid .sg-today select {
    width: 100%; margin: 0; padding: .22rem .4rem;
    font-size: .85rem; text-align: right; font-variant-numeric: tabular-nums;
}
.scan-grid .sg-today select { text-align: left; }

/* Carried forward from the last visit and not yet looked at. Greyed so that an
   untouched row cannot pass for a reading taken today; it returns to normal
   ink the moment the value is edited. */
.scan-grid .sg-today .is-carried { color: var(--ink-3); background: #fafbfc; }

.scan-grid tbody tr:hover { background: #fafbfc; }
.scan-grid tr.has-error .sg-today input { border-color: #c1121f; }
.scan-grid .field-error { display: block; font-size: .72rem; }
.scan-grid .req { color: #c1121f; margin-left: .15rem; }

.carried-count { margin: 0 0 .5rem; font-size: .82rem; color: var(--ink-3); }

/* An enquiry's message is the reason it exists, but it must not push the
   actions off the screen. */
.enquiry-message { max-width: 34ch; }


/* ── The account menu in the topbar ─────────────────────────────────────────
   A <details>, so it opens and closes without script. The panel is absolutely
   positioned inside a relative .topbar-user-free summary row. */

.user-menu { position: relative; margin-left: auto; }

.user-menu > summary {
    display: flex; align-items: center; gap: .6rem;
    padding: .35rem .5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    list-style: none;
    transition: background var(--speed);
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary::marker { content: ''; }
.user-menu > summary:hover { background: rgba(0, 0, 0, .05); }
.user-menu > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.user-menu .who { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.user-menu .who strong { font-size: .84rem; }
.user-menu .who small  { color: var(--ink-3); font-size: .72rem; }

.user-menu .chev { width: 16px; height: 16px; color: var(--ink-3); transition: transform var(--speed); }
.user-menu[open] .chev { transform: rotate(180deg); }

.user-menu-panel {
    position: absolute; top: calc(100% + .4rem); right: 0; z-index: 60;
    min-width: 15rem;
    padding: .35rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.user-menu-head {
    display: flex; flex-direction: column; gap: .1rem;
    padding: .55rem .6rem .6rem;
    margin-bottom: .3rem;
    border-bottom: 1px solid var(--line);
}
.user-menu-head strong { font-size: .84rem; }
.user-menu-head small  { color: var(--ink-3); font-size: .74rem; word-break: break-all; }

/* The sign-out control is a real submit button in a POST form, so it is styled
   to match the links rather than the links being faked up as buttons. */
.user-menu-panel a,
.user-menu-panel button {
    display: flex; align-items: center; gap: .55rem;
    width: 100%;
    padding: .5rem .6rem;
    border: 0; border-radius: var(--radius-sm);
    background: none;
    color: var(--ink);
    font: inherit; font-size: .84rem; text-align: left; text-decoration: none;
    cursor: pointer;
    transition: background var(--speed);
}
.user-menu-panel a:hover,
.user-menu-panel button:hover { background: var(--canvas); }
.user-menu-panel svg { width: 16px; height: 16px; color: var(--ink-3); flex-shrink: 0; }

.user-menu-panel form { margin: .3rem 0 0; padding-top: .3rem; border-top: 1px solid var(--line); }
.user-menu-panel button:hover { color: var(--err); }
.user-menu-panel button:hover svg { color: currentColor; }

@media (max-width: 640px) {
    .user-menu .who { display: none; }
}
