:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2430;
    --muted: #6a7382;
    --border: #e1e5eb;
    --accent: #1f6feb;
    --danger: #c62828;
    --ok-bg: #e5f5ea; --ok: #1e7a3c;
    --info-bg: #e7f0fd; --info: #1f5fbf;
    --warn-bg: #fff4e0; --warn: #9a5b00;
    --bad-bg: #fdeaea; --bad: #b3261e;
    --idle-bg: #eef0f3; --idle: #555d6b;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    color: var(--text);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151a; --surface: #1a1f26; --text: #e6e9ee; --muted: #98a1ae; --border: #2a313b;
        --accent: #6ea8ff; --danger: #ff6b6b;
        --ok-bg: #173523; --ok: #7fd69a; --info-bg: #182a45; --info: #8db8ff;
        --warn-bg: #3a2c12; --warn: #f0c060; --bad-bg: #3d1a1a; --bad: #ff8a80;
        --idle-bg: #262c35; --idle: #aab2be;
    }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 32px 0 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 16px; background: var(--surface);
    border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar .brand { font-weight: 600; color: var(--text); }
.topbar nav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); }
.topbar nav a.active { color: var(--text); font-weight: 600; }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden; }
/* Narrow screens: the table scrolls sideways instead of overflowing the page. */
@media (max-width: 760px) {
    table { display: block; overflow-x: auto; }
}
th, td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.status-queued, .status-expired { background: var(--idle-bg); color: var(--idle); }
.status-dispatched, .status-accepted { background: var(--warn-bg); color: var(--warn); }
.status-sent { background: var(--info-bg); color: var(--info); }
.status-delivered { background: var(--ok-bg); color: var(--ok); }
.status-failed { background: var(--bad-bg); color: var(--bad); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px;
    display: flex; flex-direction: column; gap: 4px; }
.tile-label { color: var(--muted); font-size: 0.85rem; }
.tile-value { font-size: 1.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-note { color: var(--muted); font-size: 0.78rem; }

/* ---- Overview chart (palette validated for colour-vision deficiencies, light and dark) ---- */
:root {
    --series-delivered: #0ca30c;
    --series-sent: #2a78d6;
    --series-failed: #d03b3b;
    --series-expired: #eda100;
    --chart-grid: #e8ebef;
}
@media (prefers-color-scheme: dark) {
    :root {
        --series-sent: #3987e5;
        --series-expired: #c98500;
        --chart-grid: #2a313b;
    }
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-top: 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head h2 { margin: 0; }
.legend { list-style: none; display: flex; gap: 16px; margin: 0; padding: 0; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: currentColor; margin-right: 2px; }
.swatch.series-delivered { background: var(--series-delivered); }
.swatch.series-sent { background: var(--series-sent); }
.swatch.series-failed { background: var(--series-failed); }
.swatch.series-expired { background: var(--series-expired); }
.chart-empty { margin: 24px 0; text-align: center; }
.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis-label, .chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart path.series-delivered { fill: var(--series-delivered); }
.chart path.series-sent { fill: var(--series-sent); }
.chart path.series-failed { fill: var(--series-failed); }
.chart path.series-expired { fill: var(--series-expired); }
.chart-hit { fill: transparent; }
.chart-bar { outline: none; cursor: default; }
.chart-bar.active .chart-hit, .chart-bar:focus-visible .chart-hit { fill: var(--chart-grid); opacity: 0.6; }
.chart-tooltip { position: absolute; top: -8px; transform: translateY(-100%); min-width: 160px; pointer-events: none;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 10px; font-size: 0.82rem; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); z-index: 2; }
.chart-tooltip table { border: none; display: table; width: 100%; margin-top: 4px; background: none; }
.chart-tooltip td { padding: 2px 0; border: none; }
.chart-tooltip .tip-total td { border-top: 1px solid var(--border); padding-top: 4px; font-weight: 600; }

input, select { font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); color: var(--text); }
button { font: inherit; padding: 7px 14px; border: none; border-radius: 6px; background: var(--accent);
    color: #fff; cursor: pointer; }
button.small { padding: 4px 10px; font-size: 0.85rem; }
button.danger { background: var(--danger); }
button.link { background: none; color: var(--muted); padding: 0; }
.filters, .inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.inline-form input { min-width: 260px; }

.notice { background: var(--info-bg); color: var(--text); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; }
.notice-error { background: var(--bad-bg); }
.secret { display: block; margin-top: 8px; padding: 8px; background: var(--surface); border-radius: 6px;
    word-break: break-all; user-select: all; }

.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 24px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin: 0 0 16px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; word-break: break-word; }

.pager { display: flex; gap: 16px; justify-content: center; margin-top: 16px; color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }

/* ---- Brand in the top bar ---- */
.topbar .brand { display: inline-flex; align-items: center; gap: 10px; }
.topbar .brand img { width: 28px; height: 28px; }

/* ---- Sign-in page: form on the left, brand panel on the right ---- */
body.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; background: var(--surface); }
.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-form-wrap { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.auth-brand div { display: flex; flex-direction: column; line-height: 1.15; }
.auth-brand-name { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.auth-brand-sub { font-size: 0.85rem; color: var(--accent); }
.auth h1 { font-size: 1.6rem; margin: 0 0 6px; letter-spacing: -0.01em; }
.auth-form-wrap > .muted { margin: 0 0 28px; }
.auth-form { gap: 18px; }
.auth-form label { color: var(--text); font-weight: 600; font-size: 0.9rem; gap: 6px; }
.auth-form .required { color: var(--danger); }
.auth-form input { width: 100%; padding: 11px 12px; font-weight: 400; }
.auth-form input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 44px; }
.password-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; color: var(--muted);
    padding: 6px; display: grid; place-items: center; }
.password-toggle:hover, .password-toggle[aria-pressed="true"] { color: var(--text); }
.auth-submit { margin-top: 6px; padding: 11px 14px; font-weight: 600; }
.auth-submit:hover { filter: brightness(1.08); }

.auth-hero { position: relative; overflow: hidden; color: #fff;
    background: linear-gradient(150deg, #3b8bff 0%, #1d4ed8 55%, #1a3aa8 100%);
    display: flex; align-items: center; padding: 48px clamp(32px, 6vw, 96px); }
.auth-hero-art { position: absolute; inset: 0; width: 100%; height: 100%; color: #fff; pointer-events: none; }
.auth-hero-content { position: relative; max-width: 520px; }
.auth-hero-brand { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; font-weight: 600; margin-bottom: 28px; }
.auth-hero h2 { font-size: clamp(1.5rem, 2.4vw, 2rem); line-height: 1.25; margin: 0 0 14px; letter-spacing: -0.01em; }
.auth-hero p { margin: 0 0 24px; opacity: 0.92; line-height: 1.5; }
.auth-hero ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 16px; line-height: 1.5; }
.auth-hero li { opacity: 0.95; }

@media (max-width: 860px) {
    body.auth { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
}

/* ---- Device pairing ---- */
button.secondary { background: none; color: var(--accent); border: 1px solid var(--border); }
.pairing { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 32px; align-items: start;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 24px; }
/* A QR code must stay dark on light to be readable, in dark mode too. */
.pairing-qr { background: #fff; border-radius: 8px; padding: 12px; }
.pairing-qr svg { display: block; width: 100%; height: auto; }
.pairing ol { margin: 0 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.5; }
.pairing-link { word-break: break-all; user-select: all; font-size: 0.8rem; }
@media (max-width: 760px) { .pairing { grid-template-columns: 1fr; } }

/* ---- Empty states: the component stays in place, with a line that says why it is empty ---- */
.empty-row td { text-align: center; color: var(--muted); padding: 28px 12px; white-space: normal; }
.chart-empty-note { position: absolute; inset: 0 0 28px 40px; display: grid; place-items: center; margin: 0; text-align: center;
    color: var(--muted); font-size: 0.9rem; pointer-events: none; }
.pager { align-items: center; }
.pager-link { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.pager-link:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.pager-link.disabled { color: var(--muted); opacity: 0.55; pointer-events: none; }
.pager-info { font-variant-numeric: tabular-nums; }

/* ---- Page header with its main action on the right ---- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Row actions ---- */
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; margin: 0; }
td.actions > * + * { margin-left: 6px; }
button.danger-solid { background: var(--danger); color: #fff; }

/* ---- Numbered pagination ---- */
.pager { flex-wrap: wrap; }
.pager-pages { display: inline-flex; gap: 4px; }
.pager-number { min-width: 34px; height: 34px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text); font-variant-numeric: tabular-nums; }
.pager-number:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.pager-number.current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pager-info { flex-basis: 100%; text-align: center; font-size: 0.85rem; }

/* ---- Dialogs (see js/ui.js) ---- */
dialog.modal { padding: 0; border: none; background: transparent; color: var(--text); max-width: min(560px, calc(100vw - 24px));
    width: 100%; max-height: calc(100vh - 32px); overflow: visible; }
dialog.modal.modal-small { max-width: min(420px, calc(100vw - 24px)); }
dialog.modal.modal-wide { max-width: min(880px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(8, 12, 24, .55); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: modal-in .22s cubic-bezier(.2, .7, .2, 1); }
dialog.modal[open]::backdrop { animation: modal-fade .22s ease; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog.modal[open], dialog.modal[open]::backdrop { animation: none; } }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 24px 64px rgba(8, 12, 24, .3);
    max-height: calc(100vh - 32px); overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-close { font-size: 1.5rem; line-height: 1; padding: 4px 8px !important; border-radius: 8px; color: var(--muted); }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 14px 20px 4px; }
.modal-body > p { margin: 0; }
.modal-body label input, .modal-body label select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 16px 20px 18px; }
.confirm-text { line-height: 1.5; }
body.is-busy { cursor: progress; }

/* ---- A wide table scrolls sideways inside its own frame instead of widening the page ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
.table-wrap > table { min-width: 100%; overflow: visible; }
@media (max-width: 760px) {
    .table-wrap > table { display: table; }
}
/* The row actions stay in view on the right while a wide table scrolls. */
.table-wrap th.actions, .table-wrap td.actions { position: sticky; right: 0; box-shadow: -10px 0 12px -12px rgba(16, 24, 48, .35); }
.table-wrap td.actions { background: var(--surface); }
.table-wrap th.actions { background: inherit; }

/* ---- Webhooks ---- */
.event-badge { background: var(--idle-bg); color: var(--idle); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 500; margin: 1px 4px 1px 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.head-actions form { margin: 0; }
form.inline { display: inline; margin-left: 10px; }
.details dd form.inline button { font-size: 0.85rem; color: var(--accent); }
.payload summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; }
.payload pre { margin: 8px 0 0; max-width: 520px; white-space: pre-wrap; word-break: break-all; font-size: 0.78rem;
    background: var(--bg); border-radius: 8px; padding: 10px; }
.code-block { margin: 8px 0 0; padding: 12px 14px; border-radius: 8px; background: #0b1020; color: #dbe3ff; font-size: 0.82rem; overflow-x: auto; }
.webhook-help h2, .danger-zone h2 { margin: 0 0 6px; font-size: 1rem; }
.webhook-help p, .danger-zone p { margin: 0; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); margin-top: 24px; }
.checks { border: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checks legend { padding: 0; margin-bottom: 6px; font-weight: 600; font-size: 0.88rem; color: var(--text); }
.checks label, .check-line { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; font-weight: 400 !important; cursor: pointer; }
.checks input, .check-line input { width: auto !important; accent-color: var(--accent); }
a.button-secondary { display: inline-block; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--accent); font-size: 0.85rem; }
a.button-secondary:hover { text-decoration: none; border-color: var(--accent); }

/* ==== Overview and phones in the look of the phone app ==== */
:root {
    --orange: #f28c28; --red: #d92d20; --bar: #c9d6ff; --online: #2bd47d;
    --hero: linear-gradient(120deg, #3a72f2 0%, #2f5fe0 55%, #3440c4 100%);
    --hero-down: linear-gradient(120deg, #5b6478 0%, #3a4253 100%);
}
@media (prefers-color-scheme: dark) {
    :root {
        --orange: #ffb062; --red: #ff8a80; --bar: #2e3a63;
        --hero: linear-gradient(120deg, #1b2a66 0%, #16224a 55%, #0e1638 100%);
        --hero-down: linear-gradient(120deg, #2a3045 0%, #1c2133 100%);
    }
}

/* The chart reads as on the phone: pale bars, today bright, failures in red. */
.chart path.series-delivered, .chart path.series-sent { fill: var(--bar); }
.chart .chart-today path.series-delivered, .chart .chart-today path.series-sent { fill: var(--accent); }
.chart path.series-failed, .swatch.series-failed { fill: var(--red); background: var(--red); }
.chart path.series-expired, .swatch.series-expired { fill: var(--orange); background: var(--orange); }
.swatch.series-delivered, .swatch.series-sent, .swatch-sent { background: var(--bar); }
.swatch-today { background: var(--accent); }

.overview { display: flex; flex-direction: column; gap: 16px; }
.overview h2 { margin: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-head a { font-weight: 600; font-size: 0.9rem; }
h2.with-icon { display: flex; align-items: center; gap: 8px; }
h2.with-icon svg { width: 18px; height: 18px; fill: var(--accent); }
.pill { padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 0.82rem; font-weight: 600; }

/* The blue band of the state, with the rings of the brand. */
.hero { position: relative; overflow: hidden; display: flex; align-items: center; gap: 24px; min-height: 128px; padding: 22px 28px;
    border-radius: 22px; background: var(--hero); color: #fff; }
.hero.hero-down { background: var(--hero-down); }
.hero-rings { position: absolute; left: -260px; top: -1180px; width: 2400px; height: 2400px; pointer-events: none; }
.hero-rings circle { fill: none; stroke: #fff; }
.hero-rings circle.core { fill: #fff; stroke: none; opacity: .09; }
.hero-rings circle.wave { stroke-width: 46px; opacity: 0; transform-box: fill-box; transform-origin: center; animation: hero-wave 4s cubic-bezier(.2, .6, .3, 1) infinite; vector-effect: non-scaling-stroke; }
.hero.hero-down .hero-rings circle.wave, .hero.hero-empty .hero-rings circle.wave { animation: none; }
@keyframes hero-wave { 0% { transform: scale(.07); opacity: 0; } 12% { opacity: .07; } 100% { transform: scale(1); opacity: 0; } }
.hero-text { position: relative; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.hero-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.hero-text p { margin: 0; color: #eaf0ff; font-size: 0.92rem; }
.hero-actions { position: relative; display: flex; gap: 10px; }
.hero-button { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 14px; background: #fff; color: #1d4ed8;
    font-weight: 600; font-size: 0.92rem; white-space: nowrap; }
.hero-button:hover { text-decoration: none; filter: brightness(.97); }
.hero-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* The badge of the phone app: green, a white disc with a tick. */
.state-badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 5px; border-radius: 999px; font-size: 0.75rem;
    font-weight: 700; letter-spacing: 0; white-space: nowrap; }
.state-badge.on { background: var(--online); color: #fff; animation: state-halo 4s ease-out infinite; }
.state-badge.off { background: var(--bad-bg); color: var(--bad); }
.state-dot { width: 15px; height: 15px; border-radius: 50%; display: grid; place-items: center; background: #fff; }
.state-badge.on .state-dot { color: var(--online); }
.state-badge.off .state-dot { background: var(--bad); color: var(--surface); }
.state-dot svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.hero .state-badge.off, .device-top .state-badge.off { background: rgba(255, 255, 255, .18); color: #fff; }
.hero .state-badge.off .state-dot, .device-top .state-badge.off .state-dot { background: #fff; color: #3a4253; }
@keyframes state-halo { 0% { box-shadow: 0 0 0 0 rgba(43, 212, 125, .6); } 45% { box-shadow: 0 0 0 8px rgba(43, 212, 125, 0); } 100% { box-shadow: 0 0 0 0 rgba(43, 212, 125, 0); } }

/* The counters: an icon tile, the value in its colour. */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.kpi:hover { text-decoration: none; border-color: color-mix(in srgb, var(--kpi) 40%, var(--border)); }
.kpi > span:last-child { display: flex; flex-direction: column; font-size: 0.85rem; font-weight: 500; }
.kpi strong { font-size: 1.65rem; line-height: 1.1; letter-spacing: -0.03em; color: var(--kpi); font-variant-numeric: tabular-nums; }
.kpi-icon { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--kpi) 14%, transparent); color: var(--kpi); }
.kpi-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.kpi-sent { --kpi: var(--accent); }
.kpi-waiting { --kpi: var(--orange); }
.kpi-failed { --kpi: var(--red); }
.kpi-online { --kpi: var(--ok); }

/* The chart and the live activity, side by side. */
.overview-row { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
.overview-row .panel { margin: 0; }
.live { display: flex; flex-direction: column; gap: 2px; }
.live-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.live-head h2 { flex: 1; font-size: 1rem; }
.live-head a { font-weight: 600; font-size: 0.85rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--online); animation: state-halo 4s ease-out infinite; }
.live-row { display: flex; align-items: center; gap: 12px; min-height: 58px; color: var(--text); border-bottom: 1px solid var(--border); }
.live-row:last-child { border-bottom: none; }
.live-row:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 5%, transparent); }
.live-icon { width: 36px; height: 36px; flex: none; border-radius: 11px; display: grid; place-items: center; }
.live-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.live-icon.kind-ok { background: var(--ok-bg); color: var(--ok); }
.live-icon.kind-sent { background: var(--info-bg); color: var(--info); }
.live-icon.kind-failed { background: var(--bad-bg); color: var(--bad); }
.live-icon.kind-waiting { background: var(--warn-bg); color: var(--warn); }
.live-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 0.8rem; }
.live-text strong { font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.live-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 0.75rem; }

/* A phone, as the app shows it: its state, then SIM, battery and signal. */
.phones-strip { display: flex; flex-direction: column; gap: 10px; }
.phone-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.phone-card { padding: 14px 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.phone-card-head { display: flex; align-items: center; gap: 10px; }
.phone-icon { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.phone-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.phone-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 0.78rem; }
.phone-name strong { font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vitals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.vital { display: flex; align-items: center; gap: 8px; min-width: 0; }
.vital > span { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; font-size: 0.72rem; color: var(--muted); }
.vital strong { font-size: 0.88rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vital-icon { flex: none; }
.vital-icon.sim path { fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.vital-icon.battery .battery-body { fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; }
.battery-fill.good { fill: #2bd47d; }
.battery-fill.medium { fill: #ffb547; }
.battery-fill.low { fill: #ff8a80; }
.battery-bolt { fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.battery-bolt.on-fill { stroke: #0b1020; }
.vital-icon.signal rect { fill: color-mix(in srgb, var(--muted) 30%, transparent); }
.vital-icon.signal rect.on { fill: var(--muted); }

@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .overview-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .hero { flex-direction: column; align-items: flex-start; }
    .kpis { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .hero-rings circle.wave, .state-badge.on, .live-dot { animation: none; }
}

/* ==== Phones page: one card per phone, in the look of the home screen of the app ==== */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.device-card { overflow: hidden; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; }
.device-top { position: relative; overflow: hidden; padding: 16px 18px; background: var(--hero); color: #fff; display: flex; flex-direction: column; gap: 10px; }
.device-card.offline .device-top, .device-card.revoked .device-top { background: var(--hero-down); }
.device-card.revoked { opacity: .75; }
.device-top .hero-rings { left: -1000px; top: -1140px; }
.device-card.offline .hero-rings circle.wave, .device-card.revoked .hero-rings circle.wave { animation: none; }
.device-title { position: relative; display: flex; align-items: center; gap: 10px; }
.device-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 0.75rem; color: #eaf0ff; }
.device-name strong { font-size: 1rem; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-since { position: relative; margin: 0; font-size: 0.82rem; color: #eaf0ff; }
.vitals.on-blue { position: relative; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .22); }
.vitals.on-blue .vital > span { color: #eaf0ff; }
.vitals.on-blue .vital strong { color: #fff; }
.vitals.on-blue .vital-icon.sim path, .vitals.on-blue .battery-body, .vitals.on-blue .battery-bolt { stroke: #fff; }
.vitals.on-blue .battery-bolt.on-fill { stroke: #0b1020; }
.vitals.on-blue .vital-icon.signal rect { fill: rgba(255, 255, 255, .35); }
.vitals.on-blue .vital-icon.signal rect.on { fill: #fff; }
.device-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; }
.device-actions form { margin: 0; }
.device-add { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 20px;
    border: 2px dashed var(--border) !important; border-radius: 18px; background: transparent !important; color: var(--text) !important; cursor: pointer; text-align: center; }
.device-add:hover { border-color: var(--accent) !important; }
.device-add-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; font-weight: 400;
    background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
