/*
 * Zipquill admin styling — "Golden Hour".
 *
 * A dark sidebar, warm neutrals, one saffron accent and a display face for
 * headings and headline figures. The brief changed from "calm" to "a product
 * with a voice", but three rules from the original stylesheet carry over
 * untouched, because they were never about taste:
 *
 *   - Status is never carried by colour alone. Every badge pairs a glyph with
 *     a word; the colour is the third signal. A red/green pair is a coin toss
 *     under deuteranopia, and the single most important thing this interface
 *     does is make a paused client impossible to miss.
 *   - Nothing moves while it is being read. Transitions are limited to hover
 *     and focus feedback, and prefers-reduced-motion switches even those off.
 *   - Every text colour below was checked against its surface for WCAG AA
 *     (4.5:1) in both schemes, not chosen by eye. The old muted grey was
 *     3.13:1; --ink-faint is now 5.5:1 on the page background.
 *
 * Saffron is a FILL colour. As text on white it fails contrast, so links and
 * accented text use --accent-text, a darker step of the same hue; saffron
 * itself appears only as a background behind dark ink, or on the dark
 * sidebar, where both pass comfortably.
 *
 * Hand-written rather than pulled from a framework, and the fonts are served
 * from /assets rather than a CDN: no build step, and no third-party request
 * on a page that shows client data.
 */

@font-face {
    font-family: "Bricolage Grotesque";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("/assets/fonts/bricolage-grotesque-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                   U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                   U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Bricolage Grotesque";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("/assets/fonts/bricolage-grotesque-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
                   U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
                   U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("/assets/fonts/inter-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                   U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                   U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("/assets/fonts/inter-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
                   U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
                   U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    color-scheme: light;

    --bg:        #f7f7f5;
    --surface:   #ffffff;
    --surface-2: #fbfaf8;
    --line:      #e6e2da;
    --line-soft: #f0ede7;
    --ink:       #1a1611;
    --ink-soft:  #4e473e;
    --ink-faint: #6b6358;

    /* Saffron fills, and the darker step used wherever it must be text. */
    --accent:      #f5a524;
    --accent-ink:  #15120e;
    --accent-text: #8f5400;
    --accent-soft: #fff4e5;
    --focus:       #c77d00;

    /* The primary button is the dark ink slab from the sidebar, not saffron:
       a page of saffron buttons stops having an accent at all. */
    --btn-primary-bg: #15120e;
    --btn-primary-fg: #ffffff;

    --ok:      #1f5a35;
    --ok-bg:   #e2f1e6;
    --warn:    #7a4b00;
    --warn-bg: #fff0d6;
    --bad:     #8a2c1b;
    --bad-bg:  #fbe3dd;
    --idle:    #4e473e;
    --idle-bg: #efece6;

    --side-bg:      #15120e;
    --side-raised:  #221d17;
    --side-line:    #332c23;
    --side-current: #2a241c;
    --side-ink:     #d4cdc2;
    --side-faint:   #9a9184;

    --radius:    10px;
    --radius-lg: 18px;
    --shadow:    0 1px 2px rgba(26, 22, 17, 0.04), 0 1px 1px rgba(26, 22, 17, 0.03);
    --font:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --display: "Bricolage Grotesque", "Inter", -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, sans-serif;
    --mono:    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
}

/* Dark is a choice the reader makes with the sidebar switch, never inferred
   from the operating system: see uiTheme(). The attribute is rendered by the
   server, so the first paint is already the right scheme. */
:root[data-theme="dark"] {
        color-scheme: dark;
        --bg:        #0f0d0a;
        --surface:   #1a1712;
        --surface-2: #1f1b15;
        --line:      #2e2820;
        --line-soft: #25201a;
        --ink:       #f2eee7;
        --ink-soft:  #cfc7ba;
        --ink-faint: #a69d90;

        --accent-text: #f5b544;
        --accent-soft: #2b2010;
        --focus:       #f5a524;

        /* On a dark page the dark slab disappears, so the primary action
           becomes the saffron fill with dark ink on it. */
        --btn-primary-bg: #f5a524;
        --btn-primary-fg: #15120e;

        --ok:      #86d9a6;
        --ok-bg:   #15271c;
        --warn:    #f5b544;
        --warn-bg: #2b2010;
        --bad:     #ff9c8f;
        --bad-bg:  #36170f;
        --idle:    #bdb5a9;
        --idle-bg: #25211b;

        --side-bg:      #0a0907;
        --side-raised:  #17140f;
        --side-line:    #26211a;
        --side-current: #1f1b15;

        --shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 var(--font);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }

/* One focus treatment everywhere, visible on both surfaces and on the dark
   sidebar. Keyboard users only — a mouse click does not draw a ring. */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; margin: 0; }
h2 { font-size: 18px; margin: 0 0 14px; }
/* A section heading sitting directly on the page, not in a card, needs air
   above it or it reads as a caption for whatever came before. */
.wrap > h2 { margin-top: 30px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--ink-soft); font-family: var(--font); font-weight: 600; letter-spacing: 0; }

.muted { color: var(--ink-faint); }
/* Read by screen readers, not drawn: a label for a control whose purpose is
   obvious to sighted readers from the row it sits in. */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.mono  { font-family: var(--mono); font-size: 0.9em; }
code   { font-family: var(--mono); font-size: 0.9em; }

/* Hidden until focused, then the first thing on the page. With twenty-odd
   sections in the sidebar, a keyboard user otherwise tabs through all of
   them on every page load before reaching the thing they came for. */
.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 50;
    background: var(--accent); color: var(--accent-ink);
    padding: 10px 16px; border-radius: var(--radius); font-weight: 700;
}
.skip-link:focus { top: 12px; text-decoration: none; }

/* --- shell: sidebar + main -------------------------------------------- */

/* The sidebar colour is painted down the shell's left edge as well, so a
   page taller than the window never shows the sidebar ending part-way. */
.shell {
    display: flex; min-height: 100vh;
    background: linear-gradient(to right, var(--side-bg) 252px, transparent 252px);
}

.side {
    flex: none;
    width: 252px;
    background: var(--side-bg);
    color: var(--side-ink);
    padding: 22px 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    color: #ffffff; padding: 0 8px;
    font-family: var(--display); font-weight: 800; font-size: 20px; letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px; flex: none;
    background: var(--accent); color: var(--accent-ink);
    display: inline-flex; align-items: center; justify-content: center;
}
.brand-mark svg { display: block; }

/* Which workspace everything on the page belongs to. At the top of the
   sidebar because "whose data is this" is the first question on any page. */
.ws-switch {
    display: flex; flex-direction: column; gap: 4px; margin: 0;
    background: var(--side-raised); border: 1px solid var(--side-line);
    border-radius: 12px; padding: 9px 10px;
}
.ws-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--side-faint); }
.ws-name { color: #ffffff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-switch--none .ws-name { color: var(--side-ink); font-weight: 500; }
.ws-row { display: flex; gap: 6px; }
.ws-row select {
    flex: 1; min-width: 0; min-height: 32px; padding: 4px 8px; font-size: 13px;
    background: var(--side-bg); color: #ffffff; border-color: var(--side-line);
}
.ws-go, button.ws-go {
    min-height: 32px; padding: 0 10px; font-size: 12px;
    background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}

.nav-toggle { display: none; }

/* The links scroll on their own and the signed-in account stays pinned
   beneath them. With every section visible the list is taller than a laptop
   screen, and the one thing that must never scroll away is whose account
   this is. */
.nav {
    display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0;
    overflow-y: auto; margin: 0 -6px; padding: 0 6px;
    scrollbar-width: thin; scrollbar-color: var(--side-line) transparent;
}
.whoami { flex: none; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--side-faint); padding: 0 10px 5px;
}
.nav-link {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    min-height: 32px; padding: 0 10px; border-radius: 9px;
    color: var(--side-ink); font-size: 14px; font-weight: 500;
}
.nav-link:hover { background: var(--side-raised); color: #ffffff; text-decoration: none; }
/* The current page: a saffron rule as well as the raised fill, so the
   position reads without relying on the fill's small contrast step. */
.nav-link.is-current {
    background: var(--side-current); color: #ffffff; font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}
.nav-link:focus-visible { outline-color: var(--accent); outline-offset: 0; }

.nav-soon {
    padding: 6px 10px; font-size: 14px; color: var(--side-faint);
    display: inline-flex; gap: 6px; align-items: baseline; cursor: default;
}
.nav-soon-tag {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
    border: 1px solid var(--side-line); border-radius: 3px; padding: 0 4px;
}

/* A count beside a nav item. A prompt, not an alarm — an alarm in the chrome
   of every page is one people learn to stop seeing. */
.nav-badge {
    display: inline-block; min-width: 1.6em; padding: 0 7px;
    border-radius: 999px; background: var(--accent); color: var(--accent-ink);
    font-size: 11px; font-weight: 700; line-height: 1.6; text-align: center;
}

/* Who is signed in, at the foot of the sidebar. Everything in this tool is
   done on behalf of a client, and an operator who cannot see which account
   they are using will eventually pause the wrong one. */
.whoami {
    display: flex; flex-direction: column; gap: 8px;
    border-top: 1px solid var(--side-line); padding: 14px 10px 0;
    font-size: 13px;
}
.whoami-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.whoami-avatar {
    flex: none; width: 32px; height: 32px; border-radius: 999px;
    background: var(--side-raised); border: 1px solid var(--side-line);
    color: var(--accent); font-weight: 700; font-size: 12px;
    display: inline-flex; align-items: center; justify-content: center;
}
.whoami-text { display: flex; flex-direction: column; min-width: 0; }
.whoami-name { color: #ffffff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami-role { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--side-faint); }
.whoami-links { display: flex; gap: 14px; }
.whoami-out { color: var(--side-ink); }
.whoami-out:hover { color: #ffffff; }

/* The light/dark switch: a real button, styled as a quiet link so it sits with
   Security and Log out rather than reading as a primary action. */
.theme-switch { margin: 0; }
.theme-toggle, button.theme-toggle {
    min-height: 0; padding: 0; border: 0; background: none; border-radius: 0;
    color: var(--side-ink); font-size: 13px; font-weight: 500; cursor: pointer;
}
.theme-toggle:hover { color: #ffffff; border: 0; text-decoration: underline; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* --- page ------------------------------------------------------------- */

.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 34px 40px 56px; flex: 1; }
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; margin-bottom: 8px; flex-wrap: wrap;
}
.page-sub { color: var(--ink-soft); margin: 0 0 26px; font-size: 14.5px; max-width: 72ch; }
.page-kicker { color: var(--ink-faint); font-size: 13px; margin: 0 0 4px; }
.foot {
    width: 100%; max-width: 1240px; margin: 0 auto;
    padding: 0 40px 30px; color: var(--ink-faint); font-size: 12.5px;
}

.card, .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 22px;
}
.card--flush { padding: 0; overflow-x: auto; }
.card--flush h2 { padding: 20px 24px 0; margin-bottom: 12px; }
.grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.sub { color: var(--ink-faint); font-size: 13px; }

/* The dark card: used sparingly, for the one thing on a page that is live
   right now. Two of them on one screen and neither stands out. */
.card--ink {
    background: var(--side-bg); color: var(--side-ink); border-color: var(--side-line);
}
.card--ink h2 { color: #ffffff; }
.card--ink a { color: var(--accent); }
.card--ink .muted { color: var(--side-faint); }

/* --- tables ----------------------------------------------------------- */

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
    text-align: left; font-weight: 600; font-size: 11.5px;
    text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-faint);
    padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
.card--flush table.data th:first-child, .card--flush table.data td:first-child { padding-left: 24px; }
.card--flush table.data th:last-child,  .card--flush table.data td:last-child  { padding-right: 24px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The account-wide line. It is not a client and must not read as one. */
tr.row--total td {
    border-top: 2px solid var(--line);
    background: var(--surface-2);
    font-weight: 600;
}
tr.row--total:hover { background: var(--surface-2); }

/* A paused client gets a left rule as well as its badge, so the row is
 * distinguishable in a printout and at a glance from across a desk. */
tr.row--paused td:first-child { box-shadow: inset 3px 0 0 var(--bad); }

.empty { padding: 28px 24px; color: var(--ink-faint); font-size: 14px; }

/* --- badges ----------------------------------------------------------- */

.badge, .pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 700; line-height: 1.5;
    padding: 2px 10px 2px 8px; border-radius: 999px;
    white-space: nowrap;
}
.badge-glyph { font-size: 11px; }
.badge--ok      { color: var(--ok);   background: var(--ok-bg); }
.badge--warn    { color: var(--warn); background: var(--warn-bg); }
.badge--danger,
.badge--paused  { color: var(--bad);  background: var(--bad-bg); }
.badge--idle,
.badge--busy,
.badge--info,
.badge--muted,
.badge--unknown { color: var(--idle); background: var(--idle-bg); }
/* Sending is the one idle-family state that is happening now. */
.badge--busy    { color: var(--accent-text); background: var(--accent-soft); }

.pill        { color: var(--idle); background: var(--idle-bg); padding: 2px 10px; }
.pill--on    { color: var(--ok);   background: var(--ok-bg); }
.pill--off   { color: var(--bad);  background: var(--bad-bg); }

/* --- alerts ----------------------------------------------------------- */

.alert {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 13px 16px 13px 44px;
    margin-bottom: 18px;
    font-size: 14px;
    position: relative;
}
/* A glyph per kind, for the same reason badges carry one. */
.alert::before {
    position: absolute; left: 16px; top: 12px;
    font-weight: 700; font-size: 14px;
}
.alert--ok    { border-color: var(--ok);   background: var(--ok-bg);   color: var(--ok); }
.alert--ok::before    { content: "\2713"; }
.alert--warn  { border-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.alert--warn::before  { content: "\25B2"; }
.alert--error { border-color: var(--bad);  background: var(--bad-bg);  color: var(--bad); }
.alert--error::before { content: "\2715"; }
.alert a { color: inherit; text-decoration: underline; }

/* The paused-clients block at the top of the dashboard. Loud on purpose. */
.pause-banner {
    border: 1px solid var(--bad);
    background: var(--bad-bg);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    margin-bottom: 24px;
}
.pause-banner h2 { color: var(--bad); margin-bottom: 10px; }
.pause-banner ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.pause-banner li { line-height: 1.6; }
.pause-banner .reason { color: var(--ink); }

/* --- stats and bars --------------------------------------------------- */

.stats { display: flex; gap: 14px 34px; flex-wrap: wrap; margin: 8px 0 26px; }
.card .stats { margin: 0; }
.stat-value {
    font-family: var(--display); font-size: 28px; font-weight: 700;
    letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-faint);
}

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; font-size: 13.5px; }
.bar-name { width: 92px; color: var(--ink-soft); }
.bar-track { flex: 1; height: 10px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar-fill--ok   { background: var(--ok); }
.bar-fill--bad  { background: var(--bad); }
.bar-fill--idle { background: var(--idle); }
.bar-value { width: 92px; text-align: right; font-variant-numeric: tabular-nums; }

/* --- forms ------------------------------------------------------------ */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: 12.5px; color: var(--ink-faint); margin-top: 5px; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], input[type=url], input[type=tel], input[type=date],
input[type=datetime-local], input[type=time], select, textarea {
    width: 100%;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 9px 12px;
    min-height: 40px;
}
textarea { font-family: var(--mono); font-size: 13px; min-height: 140px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--focus);
    outline-offset: -1px;
    border-color: var(--focus);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); opacity: 1; }
input[type=checkbox], input[type=radio] { accent-color: var(--btn-primary-bg); width: 16px; height: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: auto; margin: 0; }

/* --- buttons ----------------------------------------------------------
   Bare <button> and <button class="primary"> are styled here too. About
   thirty pages wrote class="primary" or class="danger" with no rule behind
   it, so the same action looked different depending on which page it was
   on. One look for every button, whichever way the markup spelled it. */

.btn, button, input[type=submit], input[type=button] {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
    min-height: 40px; padding: 0 16px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.12s, border-color 0.12s;
}
.btn:hover, button:hover, input[type=submit]:hover { border-color: var(--ink-faint); text-decoration: none; }
.btn--primary, button.primary, input[type=submit].primary {
    background: var(--btn-primary-bg); border-color: var(--btn-primary-bg); color: var(--btn-primary-fg);
}
.btn--primary:hover, button.primary:hover { filter: brightness(1.15); border-color: var(--btn-primary-bg); }
.btn--danger, button.danger { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.btn--sm, button.btn--sm { font-size: 13px; min-height: 32px; padding: 0 12px; }
.btn[disabled], button[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
/* Fields inside a row share it. The global width: 100% would otherwise stack
   a name/value pair into two full-width boxes, which reads as two unrelated
   settings rather than one parameter. */
.btn-row > input, .btn-row > select { width: auto; flex: 1 1 200px; min-width: 0; }
.form .btn-row { margin-top: 0; }
/* A button that only exists to be the form's default for Enter. */
button[hidden] { display: none; }

details.inline { margin-top: 10px; }
details.inline > summary {
    cursor: pointer; font-size: 13.5px; font-weight: 600;
    color: var(--accent-text); list-style: none;
}
details.inline > summary::-webkit-details-marker { display: none; }
details.inline > summary::before { content: "\25B8\00a0"; }
details.inline[open] > summary::before { content: "\25BE\00a0"; }
details.inline > div {
    margin-top: 12px; padding: 16px;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface-2);
}

/* --- login ------------------------------------------------------------
   The signed-out pages have no sidebar, so they carry the brand themselves. */

.login-wrap { max-width: 400px; margin: 11vh auto; padding: 0 22px; }
.login-wrap .brand { justify-content: center; margin-bottom: 22px; color: var(--ink); font-size: 24px; }
.login-wrap .card { padding: 28px; }
.login-note { font-size: 13px; color: var(--ink-faint); margin: 12px 0 0; text-align: center; }
.login-note.is-error { color: var(--bad); }
.login-alt { margin-top: 18px; }
.login-or {
    display: flex; align-items: center; gap: 10px;
    color: var(--ink-faint); font-size: 13px; margin-bottom: 12px;
}
.login-or::before, .login-or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }

/* --- checks list (health.php) ----------------------------------------- */

.check-row {
    display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap;
    padding: 11px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px;
}
.check-row:last-child { border-bottom: 0; }
.check-what { flex: 1; }
.check-detail { color: var(--ink-soft); font-size: 13px; flex-basis: 100%; padding-left: 0; }

/* Definition list used for a record's fixed facts — campaign detail, client
   detail. Two columns on anything wider than a phone, stacked below that,
   because a label and its value wrapping apart from each other is unreadable. */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; margin: 0; font-size: 14px; }
.facts dt { color: var(--ink-faint); }
.facts dd { margin: 0; }
.facts dd .muted { margin-left: 6px; }

/* A stat tile inside .stats. No modifier colours: these are magnitudes, and
   colouring a count green or red asserts a judgement the number alone cannot
   support — a high "Failed" is bad, a high "Sent" is not, and one rule cannot
   know which it is looking at. Judgement is the badge's job. */
.stat { min-width: 96px; }

.small { font-size: 13px; }

/* Vertically stacked labelled inputs. Deliberately not a grid: these forms
   are short, and a label sitting directly above its field is the layout that
   survives being read on a phone at the end of a long page. */
.form { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.form label.check { flex-direction: row; font-weight: 500; }
.form textarea { resize: vertical; line-height: 1.5; font-family: var(--font); font-size: 14px; }
.form textarea.mono { font-family: var(--mono); font-size: 13px; }

/* Collapsed reference material. Open by default would push the form it
   explains below the fold, which is where documentation goes to be ignored. */
.help { margin-top: 20px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.help summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.help summary:hover { color: var(--ink); }
.help p { margin: 10px 0; }

/* A card holding an irreversible action. The tint is a second signal after
   the heading, never the only one — the button inside carries .btn--danger
   and the copy says plainly what cannot be undone. */
.card--danger { border-color: var(--bad); background: var(--bad-bg); }
.card--danger h2 { color: var(--bad); }

/* Slug tabs on the templates page. Horizontally scrollable rather than
   wrapping: an agency accumulates templates, and a nav that grows to four
   rows pushes the thing it is navigating off the screen. */
.tabs {
    display: flex; gap: 4px; overflow-x: auto; margin: 20px 0 0;
    border-bottom: 1px solid var(--line); padding-bottom: 0;
}
.tab {
    flex: none; padding: 10px 14px; font-size: 14px; font-weight: 500; color: var(--ink-soft);
    border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab--active, .tab.is-active { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }

/* Template preview. White background unconditionally, in both colour schemes:
   email HTML assumes a white canvas and almost never sets its own, so showing
   it on a dark surface renders dark text on dark and misrepresents what the
   recipient will actually see. */
.preview-frame {
    width: 100%; height: 620px; border: 1px solid var(--line);
    border-radius: var(--radius); background: #ffffff; display: block;
}

/* --- builder ---------------------------------------------------------
   Two columns: editor left, live preview right. The preview sticks so it
   stays in view while the author scrolls a long block list — editing an
   email while unable to see it is the entire complaint about every tool
   this one is meant to replace. The preview column is at least 640px wide
   on a wide screen, so a 600px email is not cropped on the right. */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(640px, 1fr); gap: 22px; align-items: start; }
.builder-edit { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.builder-preview { min-width: 0; position: sticky; top: 18px; }
.builder-preview .preview-frame { height: 78vh; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.block {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 12px; background: var(--surface-2);
}
.block-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 10px; font-size: 13px; font-weight: 600;
}
.block-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.block .form { gap: 10px; }
.block textarea { font-size: 14px; }

/* Below this the two columns do not both fit, and a squeezed preview is
   worse than one that follows the editor. */
@media (max-width: 1280px) {
    .builder { grid-template-columns: 1fr; }
    .builder-preview { position: static; }
    .builder-preview .preview-frame { height: 560px; }
}

/* --- contacts ---------------------------------------------------------
   A filter bar that wraps rather than scrolls: these controls are read
   together, and one sliding out of view is one nobody notices is set —
   which matters when a bulk action applies to whatever the filter selected. */
.filters {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin: 18px 0 14px; padding: 14px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.filters input[type="search"], .filters input[type="text"], .filters select { width: auto; background: var(--surface-2); }
.filters input[type="search"] { min-width: 220px; flex: 1 1 220px; }
.filters .check { font-size: 13px; color: var(--ink-soft); }

/* Narrow cells — checkboxes and single buttons — that should not be given
   an equal share of the table width. */
td.tight, th.tight { width: 1%; white-space: nowrap; }

.paging { display: flex; align-items: center; gap: 10px; margin: 16px 0; }

.rule { border: 0; border-top: 1px solid var(--line-soft); margin: 20px 0; }

/* A segment name. Deliberately not shaped like a list entry — a contact
   belongs to lists and merely matches segments, and the two must not look
   like the same kind of thing. */
.chip {
    display: inline-block; padding: 3px 11px; margin: 0 4px 5px 0;
    background: var(--idle-bg); color: var(--ink-soft);
    border-radius: 999px; font-size: 13px;
}

/* A tag chip that is also a remove button. Styled as the chip it sits
   beside rather than as a button, because a row of buttons reads as a
   toolbar and these are labels that happen to be removable. */
.chip--button, button.chip--button {
    font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; min-height: 0;
    border: 1px solid var(--line); background: var(--idle-bg); color: var(--ink-soft);
    padding: 3px 11px; margin: 0 4px 5px 0; border-radius: 999px;
}
.chip--button:hover { border-color: var(--bad); color: var(--bad); }

/* Record on the left, activity on the right. Collapses early: the contact
   page is read on a phone more than any other screen here, usually while
   someone is on the phone to the person it describes. */
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }

details.help pre, pre.mono {
    background: var(--surface-2); border: 1px solid var(--line-soft);
    border-radius: var(--radius); padding: 12px 14px; overflow-x: auto;
}

/* --- security -------------------------------------------------------- */

/* A QR code wants a white background in both colour schemes: inverted, the
   dark modules stop being dark and no scanner will read it. */
.qr {
    display: inline-block; padding: 12px; background: #fff;
    border: 1px solid var(--line); border-radius: var(--radius); margin: 4px 0 12px;
}
.qr svg { display: block; }

/* Recovery codes, shown exactly once. Wide letter-spacing because these get
   read aloud and transcribed by hand. */
pre.codes {
    font-size: 15px; letter-spacing: 0.06em; line-height: 1.9;
    background: var(--surface); border-color: var(--line);
}

details > summary.btn { display: inline-flex; list-style: none; }
details > summary.btn::-webkit-details-marker { display: none; }

/* --- roles ------------------------------------------------------------
   The permission grid. Three columns on a wide screen so a whole role is
   visible at once — scrolling to compare what you just ticked against what
   you ticked a moment ago is how people grant more than they meant to. */
.perm-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px; margin: 14px 0;
}
.perm-group h3 {
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ink-faint); margin: 0 0 8px;
}
label.perm {
    align-items: flex-start; gap: 8px; padding: 6px 0;
    border-bottom: 1px solid var(--line-soft); font-size: 13px; font-weight: 500;
}
label.perm:last-child { border-bottom: 0; }
label.perm input { margin-top: 3px; flex: none; }
label.perm code { font-size: 12px; }

/* A select that submits itself, sitting inside a table cell. */
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form select { width: auto; min-height: 34px; padding: 4px 8px; font-size: 13px; }

/* --- charts -----------------------------------------------------------
   Series colours come from --s0..--s3, emitted by chartPaletteStyle() so
   dark mode is a media query rather than a second server render. They were
   validated for colour-vision separation against both surfaces; the dark
   steps are chosen, not a lightening of the light ones. The redesign keeps
   them exactly: a re-skin is no reason to re-open a validated palette. */
.chart { width: 100%; height: auto; display: block; margin: 4px 0 2px; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis { fill: var(--ink-faint); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* A 2px surface ring where marks overlap, so a crossing stays readable. */
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .line.s0 { stroke: var(--s0); } .chart .dot.s0 { fill: var(--s0); }
.chart .line.s1 { stroke: var(--s1); } .chart .dot.s1 { fill: var(--s1); }
.chart .line.s2 { stroke: var(--s2); } .chart .dot.s2 { fill: var(--s2); }
.chart .line.s3 { stroke: var(--s3); } .chart .dot.s3 { fill: var(--s3); }

/* Identity is never colour alone: the swatch sits beside a text label in
   ordinary ink, so the chart survives grayscale and forced colours. */
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 2px 0 8px; font-size: 13px; color: var(--ink-soft); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-swatch.s0 { background: var(--s0); } .legend-swatch.s1 { background: var(--s1); }
.legend-swatch.s2 { background: var(--s2); } .legend-swatch.s3 { background: var(--s3); }

/* Ranked categories with long labels. Horizontal because link URLs and
   provider names do not fit under a vertical column unrotated, and rotated
   axis labels are unreadable. */
.barlist { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.barlist-row { display: grid; grid-template-columns: minmax(90px, 1.4fr) 2fr max-content; gap: 12px; align-items: center; font-size: 13px; }
.barlist-label { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-track { background: var(--line-soft); border-radius: 999px; height: 10px; overflow: hidden; }
.barlist-fill { background: var(--s0); height: 100%; border-radius: 0 999px 999px 0; min-width: 2px; }
.barlist-value { font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }

/* Headline figures: the display face, large, because these are what a page
   is opened to read. */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 18px 0 24px; }
.metric {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow);
}
.metric-value {
    font-family: var(--display); font-size: 32px; font-weight: 700; letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.1;
}
.metric-label { font-size: 13px; font-weight: 500; color: var(--ink-faint); margin-top: 6px; }
.metric-detail { font-size: 12.5px; margin-top: 6px; color: var(--ink-soft); }
/* A rate off too few sends is dimmed and captioned, never hidden — hiding
   it invites the reader to assume the data is missing. */
.metric--thin .metric-value { color: var(--ink-faint); }
.metric-label abbr { cursor: help; text-decoration: none; border: 1px solid var(--line); border-radius: 50%; padding: 0 4px; font-size: 10px; }

/* --- dashboard -------------------------------------------------------- */

.dash { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.dash-main, .dash-aside { min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.dash-main > .card, .dash-aside > .card { margin-bottom: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

/* Sent per day, as plain bars in HTML rather than an SVG chart: one series,
   no axis worth reading, and a title per bar gives the exact figure. */
.daybars { display: flex; align-items: flex-end; gap: 4px; height: 150px; border-bottom: 1px solid var(--line); }
.daybar { flex: 1; min-width: 3px; background: var(--side-current); border-radius: 5px 5px 2px 2px; }
.daybar.is-today { background: var(--accent); }
.daybar.is-zero { background: var(--line); height: 2px !important; }
[data-theme="dark"] .daybar { background: #4a4135; }
.daybars-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-faint); margin-top: 6px; }

.progress { height: 10px; background: var(--side-line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }

.queue { list-style: none; margin: 0; padding: 0; }
.queue li { border-top: 1px solid var(--line-soft); }
.queue li:first-child { border-top: 0; }
.queue a { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; color: var(--ink); }
.queue a:hover { text-decoration: none; }
.queue a:hover .queue-title { text-decoration: underline; }
.queue-title { font-weight: 600; }
.queue-meta { color: var(--ink-faint); font-size: 12.5px; }

.live-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.live-kicker {
    display: flex; align-items: center; gap: 8px; color: var(--accent);
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 10px;
}
.live-title { font-family: var(--display); color: #ffffff; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.live-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--side-ink); margin-top: 8px; }

/* --- responsive -------------------------------------------------------- */

@media (max-width: 1100px) {
    .dash { grid-template-columns: 1fr; }
}

/* Below this the sidebar becomes a bar across the top. Without JavaScript
   the whole menu simply shows, stacked; app.js adds a Menu button that
   folds it away, so the page is usable either way. */
@media (max-width: 960px) {
    .shell { flex-direction: column; background: none; }
    .side {
        width: auto; height: auto; position: static; overflow: visible;
        padding: 12px 16px; gap: 12px;
        flex-direction: row; flex-wrap: wrap; align-items: center;
    }
    .brand { flex: 1; padding: 0; }
    .nav, .whoami, .ws-switch { flex-basis: 100%; }
    .js .side:not(.is-open) .ws-switch { display: none; }
    .nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; overflow: visible; }
    .js .nav-toggle {
        display: inline-flex; min-height: 40px; background: var(--side-raised);
        border-color: var(--side-line); color: #ffffff;
    }
    .js .side:not(.is-open) .nav, .js .side:not(.is-open) .whoami { display: none; }
    .wrap { padding: 24px 16px 48px; }
    .foot { padding: 0 16px 28px; }
    .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    h1 { font-size: 26px; }
    table.data { font-size: 13px; }
    table.data th, table.data td { padding: 9px 10px; }
    /* A wide table scrolls inside itself on a phone. Without this the
       contacts table pushed the whole page sideways, and inside a
       .card--flush (overflow: hidden) the dashboard's bounce, complaint and
       reputation columns were clipped off with no way to reach them. */
    table.data { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .facts { grid-template-columns: 1fr; gap: 3px 0; }
    .facts dt { margin-top: 10px; }
    .perm-grid { grid-template-columns: 1fr; }
    .card, .panel { padding: 18px; }
    .card--flush { padding: 0; }
    .card--flush h2 { padding: 18px 18px 0; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .metric { padding: 14px 16px; }
    .metric-value { font-size: 24px; }
}

@media (max-width: 620px) {
    .barlist-row { grid-template-columns: 1fr max-content; }
    .barlist-track { display: none; }
}

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

@media print {
    .side, .skip-link, .foot { display: none; }
    .shell { display: block; }
    body { background: #ffffff; }
}

/* DNS records (public/domain.php): a name or value is copied whole, so it
   never wraps at a hyphen where it would look like two things. The table
   scrolls instead. */
.table-scroll { overflow-x: auto; }
.dns-value { white-space: nowrap; }
