/*
 * panel.css — shared dark UI for the secret/ admin pages.
 *
 * Extracted from boxes.php, which was the first page built in this style, so
 * the other secret/ pages can adopt it with one <link> instead of each carrying
 * its own copy of the palette. boxes.php still inlines its own styles; it can
 * be migrated onto this file later without any visual change.
 *
 * Contains only the page chrome shared across pages — palette, buttons, chips,
 * cards, fact tiles, tables, toolbar. Page-specific rules stay in that page's
 * own stylesheet (e.g. quotas.css).
 */

/* Dark is the default — these pages have always been dark, and an operator
   opening one at night should not get flashed. Light is opt-in via
   data-theme="light" on <html>, set before first paint by an inline script so
   there is no flicker. A saved choice always wins over the OS preference. */
/* Inter, self-hosted (SIL OFL) — the Tenko brand face. Variable, so one file
   covers every weight; swap keeps text visible while it loads. */
@font-face {
    font-family: "Inter";
    src: url(/fonts/inter-variable.woff2) format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

/* Tokens come in three layers, and pages should only reach for the last two:
     brand   — Tenko identity colours, used by the logo/footer and to derive
               --accent. Never used for status: brand teal sits too close to
               --green, and "branded" must not read as "healthy".
     surface — bg/panel/line/text/accent, themed below.
     status  — green/amber/red (+ purple), meaning only ok/warn/bad. */
:root {
    --brand-indigo: #7B61FF;
    --brand-blue: #3D5AFE;
    --brand-teal: #19C3B1;
    --brand-ink: #0B1220;
    --font-sans: "Inter", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root, :root[data-theme="dark"] {
    /* Native controls (checkboxes, scrollbars, date pickers) follow the theme. */
    color-scheme: dark;
    --bg: #0f1419;
    --panel: #171e26;
    --panel2: #1d2630;
    --line: #2a3642;
    --text: #d7e0e9;
    --dim: #7d8d9c;
    /* Brand blue lifted for the dark ground: #3D5AFE itself is only ~3.4:1
       on #0f1419; this is 7.5:1. */
    --accent: #8C9EFF;
    --green: #3ddc84;
    --amber: #ffb454;
    --red: #ff5f56;
    --purple: #b388ff;
    --hover: #26313d;
    --hover-line: #3a4a5a;
    --scrim: rgba(0,0,0,.6);
    --accent-soft: rgba(140,158,255,.14);
    --accent-soft2: rgba(140,158,255,.22);
    --accent-line: rgba(140,158,255,.4);
    --red-soft: rgba(255,95,86,.12);
    --red-line: rgba(255,95,86,.35);
    --shadow: none;
    font-size: 15px;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel2: #eef1f5;
    --line: #d5dce4;
    --text: #1b242e;
    --dim: #5f6d7d;
    /* Accents are darkened from their dark-theme values: the originals are
       tuned for contrast against #0f1419 and fail WCAG AA on white. */
    --accent: #3D5AFE;   /* exact brand blue — 5.1:1 on white */
    --green: #1a8348;
    --amber: #9a6100;
    --red: #c62f26;
    --purple: #6d43c8;
    --hover: #e3e8ee;
    --hover-line: #b9c4d0;
    --scrim: rgba(16,24,32,.45);
    --accent-soft: rgba(61,90,254,.08);
    --accent-soft2: rgba(61,90,254,.15);
    --accent-line: rgba(61,90,254,.35);
    --red-soft: rgba(198,47,38,.08);
    --red-line: rgba(198,47,38,.3);
    --shadow: 0 1px 2px rgba(16,24,32,.06);
}

* { box-sizing: border-box; margin: 0; }

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-family: var(--font-sans);
    padding: 24px 20px 96px;
    max-width: 1280px;
    margin: 0 auto;
}

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

h1 { font-size: 1.35rem; font-weight: 650; letter-spacing: .3px; }
h2 { font-size: 1.05rem; font-weight: 650; }

.top { display: flex; align-items: baseline; gap: 16px; margin-bottom: 6px; flex-wrap: wrap; }
.top .meta { color: var(--dim); font-size: .85rem; }
.sub { color: var(--dim); font-size: .85rem; margin-bottom: 20px; line-height: 1.5; }

/* --- summary chips --- */
.summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.chip {
    background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
    padding: 6px 14px; font-size: .82rem; display: flex; align-items: center; gap: 7px;
}
.chip .k { color: var(--dim); }
.chip b { font-size: .95rem; font-variant-numeric: tabular-nums; }
.chip.critical b { color: var(--red); }
.chip.warn b { color: var(--amber); }
.chip.ok b { color: var(--green); }
.chip.unknown b { color: var(--purple); }

/* --- controls --- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }

button, .btn {
    font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
    background: var(--panel2); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px; padding: 9px 16px;
    transition: background .12s, border-color .12s;
    display: inline-block; text-decoration: none;
}
button:hover:not(:disabled), .btn:hover { background: var(--hover); border-color: var(--hover-line); text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
button.primary, .btn.primary {
    background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent);
}
button.primary:hover:not(:disabled), .btn.primary:hover { background: var(--accent-soft2); }
button.danger { border-color: var(--red-line); color: var(--red); }
button.danger:hover:not(:disabled) { background: var(--red-soft); }

input[type="text"], input[type="number"], input[type="date"], select {
    font: inherit; font-size: .85rem;
    background: var(--panel2); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* --- cards --- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 16px; }
.card {
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
    border-left: 4px solid var(--line);
    border-radius: 12px; padding: 16px 18px;
}
.card.critical { border-left-color: var(--red); }
.card.warn { border-left-color: var(--amber); }
.card.ok { border-left-color: var(--green); }
.card.unknown { border-left-color: var(--purple); }

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.card-head .name { font-size: 1.05rem; font-weight: 650; }

.pill {
    font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
    padding: 3px 9px; border-radius: 20px;
}
.pill.critical { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.pill.warn { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.pill.ok { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.pill.unknown { background: color-mix(in srgb, var(--purple) 16%, transparent); color: var(--purple); }

.card .meta-line { color: var(--dim); font-size: .8rem; margin-bottom: 12px; }

/* --- fact tiles --- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px 12px; }
.fact { background: var(--panel2); border-radius: 8px; padding: 8px 10px; }
.fact .k { color: var(--dim); font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; }
.fact .v { font-size: .9rem; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.fact .v.red { color: var(--red); }
.fact .v.amber { color: var(--amber); }
.fact .v.green { color: var(--green); }
.fact .v.accent { color: var(--accent); }
.fact .v.dim { color: var(--dim); font-weight: 500; }

/* --- status badges --- */
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
    font-size: .72rem; padding: 4px 10px; border-radius: 7px;
    background: var(--panel2); border: 1px solid var(--line);
    /* inline-flex + baseline so the dot aligns to the first text line rather
       than the centre of a wrapped badge. */
    display: inline-flex; align-items: baseline; gap: 6px; line-height: 1.5;
}
.badge .dot {
    width: 7px; height: 7px; border-radius: 50%; flex: none;
    align-self: baseline; position: relative; top: -1px;
}
.badge .dot.ok { background: var(--green); }
.badge .dot.warn { background: var(--amber); }
.badge .dot.critical { background: var(--red); }
.badge .dot.dim { background: var(--dim); }
.badge .st { color: var(--dim); }

/* --- tables --- */
.table-wrap {
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
    border-radius: 12px; overflow-x: auto; margin-bottom: 16px;
}
table.data { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.data th, table.data td {
    padding: 10px 13px; text-align: left; white-space: nowrap;
    border-bottom: 1px solid var(--line);
}
table.data th {
    color: var(--dim); font-size: .66rem; text-transform: uppercase; letter-spacing: .07em;
    font-weight: 700; user-select: none;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }
table.data th.sorted { color: var(--text); }
table.data th .sort-arrow {
    margin-left: 5px; font-size: .8em; opacity: .35;
}
table.data th.sorted .sort-arrow { opacity: 1; }
table.data th.sortable:hover .sort-arrow { opacity: .75; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--panel2); }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data td.c-red { color: var(--red); font-weight: 600; }
table.data td.c-amber { color: var(--amber); }
table.data td.c-green { color: var(--green); }
table.data td.c-dim { color: var(--dim); }
table.data tfoot td {
    border-top: 1px solid var(--line); font-weight: 650;
    font-variant-numeric: tabular-nums; background: var(--panel2);
}

.rowdot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    margin-right: 8px; vertical-align: 1px;
}
.rowdot.critical { background: var(--red); }
.rowdot.warn { background: var(--amber); }
.rowdot.ok { background: var(--green); }
.rowdot.unknown { background: var(--purple); }

/* First column stays pinned while the rest scrolls sideways; without it a
   narrow viewport loses track of which row is which. Opaque background is
   required since sticky cells float over the ones sliding beneath. */
table.data th:first-child, table.data td:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--panel);
}
table.data tbody tr:hover td:first-child { background: var(--panel2); }

/* --- notices --- */
.notice {
    border-radius: 10px; padding: 11px 14px; margin-bottom: 16px;
    border: 1px solid var(--line); background: var(--panel2);
    font-size: .85rem; line-height: 1.5;
}
.notice.warn { border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: color-mix(in srgb, var(--amber) 9%, transparent); }
.notice.critical { border-color: color-mix(in srgb, var(--red) 40%, transparent); background: color-mix(in srgb, var(--red) 9%, transparent); }
.notice.info { border-color: var(--accent-line); background: var(--accent-soft); }

.state { color: var(--dim); font-size: .9rem; padding: 20px 0; }

/* Quiet heading above a results pane — the pane itself carries the weight, so
   the label sits back rather than competing with the page h1. */
.section-label {
    font-size: .78rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .12em; color: var(--dim); margin: 26px 0 12px;
}

/* --- spinner --- */
.spinner {
    width: 15px; height: 15px; border-radius: 50%; display: inline-block;
    border: 2px solid var(--line); border-top-color: var(--accent);
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- hint markers ("?" affordance on column headers) --- */
.hint {
    display: inline-block; width: 14px; height: 14px; line-height: 14px;
    text-align: center; border-radius: 50%; font-size: .6rem; font-weight: 700;
    background: var(--panel2); color: var(--dim); border: 1px solid var(--line);
    cursor: help; margin-left: 3px; vertical-align: 1px;
}
.hint:hover { color: var(--accent); border-color: var(--accent-line); }

/* --- modal --- */
.modal {
    display: none; position: fixed; inset: 0; z-index: 50;
    background: var(--scrim); align-items: center; justify-content: center; padding: 20px;
}
.modal.open { display: flex; }
.modal-box {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    padding: 20px 22px; max-width: 560px; width: 100%;
}
.modal-box h3 { font-size: 1rem; font-weight: 650; margin-bottom: 10px; }
.modal-box p { font-size: .87rem; line-height: 1.55; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; }

/* --- output pane --- */
.output {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    padding: 14px 16px; font-size: .82rem; line-height: 1.55;
    max-height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.output:empty { display: none; }

/* ------------------------------------------------------------------ *
 * Legacy class vocabulary
 *
 * configure_systems.php, bounces.php and quota_history.php were written
 * against the old light quotas.css and use a different set of class names
 * (.page-header, .callout, .action-button, .modal-overlay, .command-output …).
 * When quotas.css was rewritten for the dark UI those classes vanished and the
 * three pages fell back to browser defaults.
 *
 * Mapping the old names onto the shared tokens here restyles all three without
 * touching their markup or the jQuery that depends on those same selectors —
 * markedly less risk than rewriting three pages of interleaved PHP and JS.
 * If those pages are ever rewritten onto the primary vocabulary, this whole
 * block can be deleted.
 * ------------------------------------------------------------------ */

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* Old pages mark up buttons and links alike as .action-button. */
.action-button {
    font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
    background: var(--panel2); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px; padding: 9px 16px;
    transition: background .12s, border-color .12s;
    display: inline-block; text-decoration: none;
}
.action-button:hover:not(:disabled) { background: var(--hover); border-color: var(--hover-line); text-decoration: none; }
.action-button:disabled { opacity: .55; cursor: default; }
.action-button.primary {
    background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent);
}
.action-button.primary:hover:not(:disabled) { background: var(--accent-soft2); }

/* Explanatory panel at the top of configure_systems / quota_history. */
.callout {
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
    border-left: 4px solid var(--accent-line);
    border-radius: 12px; padding: 15px 18px; margin-bottom: 20px;
    font-size: .85rem; line-height: 1.6;
}
.callout h4 { font-size: .95rem; font-weight: 650; margin-bottom: 8px; }
.callout ol, .callout ul { margin: 0 0 10px 20px; }
.callout li { margin-bottom: 5px; }
.callout p { margin: 0 0 10px; }
.callout p:last-child { margin-bottom: 0; }
.callout-note { color: var(--dim); }
.callout code, .batch-id, code {
    background: var(--panel2); border: 1px solid var(--line); border-radius: 5px;
    padding: 1px 6px; font-size: .8em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.callout-example > summary {
    cursor: pointer; color: var(--accent); font-weight: 600; padding: 4px 0;
    /* The marker is kept: it is the only cue the block expands. */
}
.callout-example > summary:hover { text-decoration: underline; }

/* Old pages use bare <table>; scope to body so panel .data tables are unaffected. */
body > table, .callout table, form > table, table#params-table, table.leg-mode-table,
table#history-table, .system-bounce-table table {
    width: 100%; border-collapse: collapse; font-size: .82rem;
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
    border-radius: 12px; overflow: hidden; margin-bottom: 16px;
}
body > table th, body > table td,
.callout table th, .callout table td,
form > table th, form > table td,
table#params-table th, table.leg-mode-table th, table#params-table td, table.leg-mode-table td,
table#history-table th, table#history-table td,
.system-bounce-table table th, .system-bounce-table table td {
    padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--line);
}
body > table th, .callout table th, form > table th,
table#params-table th, table.leg-mode-table th, table#history-table th, .system-bounce-table table th {
    color: var(--dim); font-size: .66rem; text-transform: uppercase; letter-spacing: .07em;
    font-weight: 700; white-space: nowrap;
}
body > table tbody tr:last-child td,
.callout table tbody tr:last-child td,
form > table tbody tr:last-child td,
table#params-table tbody tr:last-child td, table.leg-mode-table tbody tr:last-child td,
table#history-table tbody tr:last-child td,
.system-bounce-table table tbody tr:last-child td { border-bottom: 0; }
table#history-table tbody tr:hover td,
table#params-table tbody tr:hover td, table.leg-mode-table tbody tr:hover td,
.system-bounce-table table tbody tr:hover td { background: var(--panel2); }

/* Numeric columns: bounce counts/percentages and the quota fields are compared
   down the column, so the digits have to line up. */
.system-bounce-table td:nth-child(3),
.system-bounce-table td:nth-child(4) { font-variant-numeric: tabular-nums; }

/* Secondary text: "(x1.05)", "66 skipped", "= 4 days". */
.derived { color: var(--dim); font-size: .93em; }

.instance-tag {
    color: var(--dim); font-size: .75rem; font-weight: 500;
}

/* The system name anchors each row of the config table; the row is otherwise
   all numeric inputs, so it needs the weight to stay findable. */
td.system-name { font-weight: 600; white-space: nowrap; }
td.params-loading { color: var(--dim); }

/* The worked example sits inside a .callout and must read as illustration
   rather than a second table of live data — hence flat, no card treatment. */
.callout .example-table {
    background: transparent; border: 0; box-shadow: none;
    border-radius: 0; margin: 10px 0 4px; font-size: .8rem;
}
.callout .example-table th { padding: 6px 10px; }
.callout .example-table td {
    padding: 6px 10px; border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.callout .example-table td:last-child {
    font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* .badge in these pages is a text pill, not the dotted status badge above, so
   it is re-specified rather than inherited. */
.badge, .status-applied, .status-reversed {
    display: inline-block; font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    padding: 3px 9px; border-radius: 20px; border: 0;
    background: var(--panel2); color: var(--dim); line-height: 1.5;
}
.badge.status-applied { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge.status-reversed { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }

/* An edited field must stand out from its untouched neighbours. */
input.changed {
    border-color: var(--amber);
    background: color-mix(in srgb, var(--amber) 10%, var(--panel2));
}
.dirty-indicator { color: var(--amber); font-size: .82rem; font-weight: 600; }

/* These inputs are injected by JS without a class, so they are sized here.
   Wide enough for "876000" (the auto-resume-disabled sentinel) without the
   column stretching to fit it. */
table#params-table input[type="number"] {
    width: 104px; font-variant-numeric: tabular-nums;
}

.form-footer {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 20px;
}

.history-filter {
    display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 16px;
}
.history-filter label { color: var(--dim); font-size: .82rem; }

.error-message { color: var(--red); font-size: .85rem; }
.no-data-message { color: var(--dim); font-size: .85rem; padding: 4px 0 14px; }

/* Result pane at the foot of the old pages (= .output on the new ones). */
.command-output {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    padding: 14px 16px; font-size: .82rem; line-height: 1.55; color: var(--text);
    max-height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.command-output p { margin: 0 0 8px; }
.command-output p:last-child { margin-bottom: 0; }

/* Old modal markup: .modal-overlay wraps .modal, and visibility is driven by
   the [hidden] attribute rather than an .open class. */
.modal-overlay {
    position: fixed; inset: 0; z-index: 50; background: var(--scrim);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-overlay > .modal {
    display: block; position: static; inset: auto; padding: 20px 22px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto;
}
.modal-overlay > .modal h3 { font-size: 1rem; font-weight: 650; margin-bottom: 10px; }
.modal-overlay > .modal p { font-size: .87rem; line-height: 1.55; margin-bottom: 12px; }
.modal-overlay > .modal ul { margin: 6px 0 0 20px; }
.modal-overlay > .modal li { font-size: .84rem; line-height: 1.6; }

.confirm-diff { font-size: .85rem; }
.confirm-system { margin-bottom: 10px; }
.confirm-diff .from { color: var(--dim); text-decoration: line-through; }
.confirm-diff .to { color: var(--green); font-weight: 600; }
.plan-line { margin-bottom: 6px; line-height: 1.55; }
.plan-conflict {
    border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent);
    background: color-mix(in srgb, var(--amber) 9%, transparent);
    border-radius: 8px; padding: 10px 12px; margin-top: 10px;
}
.force-label {
    display: flex; align-items: center; gap: 7px; margin-top: 10px;
    font-size: .82rem; color: var(--amber); cursor: pointer;
}

/* bounces.php: one block per system. */
.bounce-stats-container { display: grid; gap: 4px; }
.system-bounce-table { margin-bottom: 22px; }
.system-bounce-table h3 {
    font-size: .95rem; font-weight: 650; margin-bottom: 9px;
    display: flex; align-items: center; gap: 9px;
}

/* ------------------------------------------------------------------ *
 * Responsive
 *
 * These pages get opened on a phone to check on a system mid-incident, so
 * the layout has to survive a 360px viewport. Two things break first: the
 * toolbar (a long row of buttons) and any wide table. The table keeps its
 * horizontal scroll with a pinned first column (see .table-wrap above);
 * everything else reflows.
 * ------------------------------------------------------------------ */

@media (max-width: 820px) {
    body { padding: 16px 14px 72px; }
    h1 { font-size: 1.2rem; }
    .grid { grid-template-columns: 1fr; gap: 13px; }
}

@media (max-width: 560px) {
    :root { font-size: 14px; }
    body { padding: 14px 11px 64px; }

    /* Buttons go full-width in a two-per-row grid: a wrapped flex row leaves
       ragged gaps and tap targets that drift under the thumb. */
    .toolbar {
        display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
        align-items: stretch;
    }
    .toolbar button, .toolbar .btn, .toolbar input, .toolbar select {
        width: 100%; text-align: center;
        /* 44px minimum touch target (WCAG 2.5.5 / iOS HIG). */
        min-height: 44px; padding: 11px 12px;
    }
    /* A spacer used to push actions right on desktop has no meaning in a
       grid; collapse it rather than letting it eat a cell. */
    .toolbar > span[style*="flex"] { display: none; }
    .toolbar label { grid-column: 1 / -1; margin-bottom: -4px; }

    .summary { gap: 7px; }
    .chip { padding: 5px 11px; font-size: .78rem; }

    .card { padding: 13px 14px; border-radius: 10px; }
    .card-head .name { font-size: 1rem; word-break: break-word; }

    /* Two tiles per row keeps the numbers legible; auto-fit at 96px would
       squeeze four onto a narrow phone and truncate the labels. */
    .facts { grid-template-columns: 1fr 1fr; gap: 8px; }

    .modal { padding: 12px; align-items: flex-end; }
    .modal-box { border-radius: 12px 12px 0 0; max-height: 88vh; overflow-y: auto; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions button { width: 100%; min-height: 44px; }

    table.data th, table.data td { padding: 9px 10px; }
    .output { max-height: 320px; font-size: .78rem; }

    /* --- legacy vocabulary --- */
    .page-header { gap: 10px; }
    .page-actions, .form-footer { width: 100%; }
    .page-actions .action-button, .form-footer .action-button {
        flex: 1; text-align: center; min-height: 44px; padding: 11px 12px;
    }
    .callout { padding: 13px 14px; }
    .callout ol, .callout ul { margin-left: 17px; }

    /* Wrapping these tables would mangle them; scroll sideways instead, which
       is what the primary .table-wrap does. */
    body > table, form > table, table#params-table, table.leg-mode-table,
    table#history-table, .system-bounce-table table { display: block; overflow-x: auto; }
    body > table th, body > table td,
    form > table th, form > table td,
    table#params-table th, table.leg-mode-table th, table#params-table td, table.leg-mode-table td,
    table#history-table th, table#history-table td,
    .system-bounce-table table th, .system-bounce-table table td {
        padding: 9px 10px; white-space: nowrap;
    }
    /* The description column carries the only prose in the bounce table and is
       the one thing worth wrapping rather than scrolling past. */
    .system-bounce-table td:nth-child(5) { white-space: normal; min-width: 190px; }

    table#params-table input[type="number"] { width: 88px; min-height: 40px; }

    .modal-overlay { padding: 12px; align-items: flex-end; }
    .modal-overlay > .modal { border-radius: 12px 12px 0 0; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .action-button { width: 100%; min-height: 44px; }

    .command-output { max-height: 320px; font-size: .78rem; }
}

/* Touch devices: hover styles stick after a tap and read as stuck selection,
   so only apply them where a real pointer exists. */
@media (hover: none) {
    button:hover:not(:disabled), .btn:hover, .action-button:hover:not(:disabled) {
        background: var(--panel2); border-color: var(--line);
    }
    table.data tbody tr:hover td { background: transparent; }
    table.data tbody tr:hover td:first-child { background: var(--panel); }
    table#history-table tbody tr:hover td,
    table#params-table tbody tr:hover td, table.leg-mode-table tbody tr:hover td,
    .system-bounce-table table tbody tr:hover td { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---- "Powered by" footer (secret/_panel_footer.php) ---- */
.panel-footer {
    margin-top: 48px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: .75rem;
    color: var(--dim);
}
.panel-footer-tm { margin: 0; max-width: 62ch; font-size: .6875rem; line-height: 1.45; text-align: center; }
.panel-footer a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: inherit;
}
.panel-footer a:hover { color: var(--text); text-decoration: none; }
.panel-footer b { font-weight: 600; }
/* Fox variant per theme: the light-tinted fox reads on dark, the standard one on light. */
.panel-footer .logo-on-light { display: none; }
:root[data-theme="light"] .panel-footer .logo-on-light { display: inline; }
:root[data-theme="light"] .panel-footer .logo-on-dark { display: none; }

/* ---- Page-title icons (secret/_panel_icon.php) — brand-gradient glyphs in the
   fox's style, replacing per-OS emoji. Sized to the heading's own font. ---- */
.ti {
    width: 1.1em; height: 1.1em; flex: none;
    vertical-align: -.17em; margin-right: .42em;
}
