/* Rubix Alerting — operator console.
 *
 * The SecureGuard design language, so the two products feel like one suite: 44px charcoal
 * header, 6px brand strip, 210px sidebar, 26px rows, square corners everywhere except buttons,
 * 1px borders instead of shadows, and .12s colour-only transitions.
 *
 * The one deliberate divergence is the brand hue. SecureGuard is azure #0ba4e8; this is
 * amethyst #7c5cf0, so an operator with both open never mistakes one for the other. Amethyst
 * also stays clear of the severity scale — red, orange, amber, blue, grey all have fixed
 * meanings here, and a brand colour that collided with any of them would make chrome read as
 * status.
 *
 * Unlike SecureGuard the palette lives in real :root blocks rather than being written from JS.
 * These pages are server-rendered, so there is no React to apply a palette after mount, and
 * CSS avoids the first-frame flash that approach carries.
 */

/* ---- fonts (self-hosted, same faces as SecureGuard) ---- */

@font-face {
    font-family: Lato;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/Lato-Regular.woff2') format('woff2');
}

@font-face {
    font-family: Lato;
    font-style: normal;
    font-weight: 600 700;
    font-display: swap;
    src: url('/fonts/Lato-Bold.woff2') format('woff2');
}

/* ---- palette ----------------------------------------------------------- */

:root {
    --font-ui: Lato, 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --bg: #f2f3f4;
    --panel: #ffffff;
    --panel-alt: #edeeee;
    --titlebar: #dadcde;
    --border: #e4e6e8;
    --border-strong: #c8cbce;
    --th-rule: #a4a9ad;
    --input-border: #b6babd;

    --fg: #2a3138;
    --fg-body: #49535b;
    --fg-muted: #6b7580;
    --fg-subtle: #999999;

    --accent: #7c5cf0;
    --accent-fg: #ffffff;
    --accent-hover: #6a49e0;
    --accent-active: #5b3ccc;
    --accent-chip-bg: #ebe6fd;
    --focus-ring: #7c5cf0;
    --link: #5b3ccc;
    --brand: #7c5cf0;

    /* Charcoal chrome in both themes — the appliance header never lightens. */
    --header-bg: #19222e;
    --header-fg: #ffffff;
    --tab-fg: #a2a9b0;
    --tab-fg-active: #ffffff;
    --tab-hover: rgba(255, 255, 255, .06);
    --tab-active-bg: #2f3742;

    --chip-bg: #edeeee;
    --chip-fg: #49535b;

    --danger-bg: rgba(205, 56, 63, .10);
    --danger-fg: #cd383f;
    --danger-hover: #d95b61;
    --ok: #6ba243;
    --ok-bg: rgba(164, 196, 81, .18);
    --ok-fg: #4e7a2e;
    --warn-bg: rgba(255, 196, 37, .20);
    --warn-fg: #8a6400;

    --row-alt: #f5f3fd;
    --row-hover: #eeeafc;

    --input-bg: #ffffff;
    --track: #dadcde;

    --shadow-pop: 0 0 1px rgba(25, 34, 46, .10), 0 8px 24px rgba(25, 34, 46, .10);
    --shadow-modal: 0 0 1px rgba(25, 34, 46, .10), 0 12px 48px rgba(25, 34, 46, .16);
    --scrim: rgba(0, 0, 0, .35);
    --modal-bg: #ffffff;

    --sidebar-bg: #f9f9f9;
    --nav-sel: #dadcde;
    --term-bg: #131416;
    --term-fg: #dee0e3;

    /* Severity. Fixed meanings, independent of the brand hue.
       Critical and High must survive being read at a glance on a phone at 3am, so they are
       the most saturated things on the page. */
    --sev-critical: #cd383f;
    --sev-high: #c2610f;
    --sev-moderate: #8a6400;
    --sev-low: #346a88;
    --sev-info: #6b7580;

    /* Shadow mode gets its own tone, distinct from both brand and severity, because
       "computed but not sent" is neither chrome nor status. */
    --shadow-tone: #7d44a0;
    --shadow-bg: rgba(125, 68, 160, .12);
}

:root[data-theme="dark"] {
    --bg: #10161d;
    --panel: #1a222c;
    --panel-alt: #202832;
    --titlebar: #232b35;
    --border: #232c36;
    --border-strong: #3a444f;
    --th-rule: #4a545f;
    --input-border: #3a444f;

    --fg: #d6dade;
    --fg-body: #c3c9cf;
    --fg-muted: #9aa4ad;
    --fg-subtle: #6b7580;

    --accent: #7c5cf0;
    --accent-fg: #ffffff;
    --accent-hover: #9377f4;
    --accent-active: #5b3ccc;
    --accent-chip-bg: #241d47;
    --focus-ring: #7c5cf0;
    --link: #a893f7;
    --brand: #7c5cf0;

    --chip-bg: #232b35;
    --chip-fg: #c3c9cf;

    --danger-bg: rgba(205, 56, 63, .18);
    --danger-fg: #e05a61;
    --danger-hover: #ea7d83;
    --ok: #8ab55e;
    --ok-bg: rgba(164, 196, 81, .15);
    --ok-fg: #a4c451;
    --warn-bg: rgba(255, 196, 37, .14);
    --warn-fg: #ffc425;

    --row-alt: #171d28;
    --row-hover: #241f3a;

    --input-bg: #121a22;
    --track: #3a444f;

    --shadow-pop: 0 0 1px rgba(255, 255, 255, .08), 0 8px 24px rgba(0, 0, 0, .85);
    --shadow-modal: 0 0 1px rgba(255, 255, 255, .08), 0 12px 48px rgba(0, 0, 0, .9);
    --scrim: rgba(0, 0, 0, .6);
    --modal-bg: #1a222c;

    --sidebar-bg: #141b23;
    --nav-sel: #2a333e;
    --term-bg: #0c1116;
    --term-fg: #d6dade;

    --sev-critical: #e05a61;
    --sev-high: #f6851f;
    --sev-moderate: #ffc425;
    --sev-low: #5b93b0;
    --sev-info: #9aa4ad;

    --shadow-tone: #a97fc9;
    --shadow-bg: rgba(169, 127, 201, .16);
}

/* ---- reset + base ------------------------------------------------------ */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-ui);
    font-size: 12.5px;
    -webkit-font-smoothing: antialiased;
}

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

input, select, textarea, button { font-family: inherit; font-size: 12.5px; }

/* Fields get a border-colour change, not a ring. Only non-field controls get the ring. */
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: none;
}

:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
::placeholder { color: var(--fg-subtle); opacity: 1; }

/* ---- shell ------------------------------------------------------------- */

.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    color: var(--fg);
}

.header {
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    padding: 0 12px 0 16px;
    background: var(--header-bg);
    color: var(--header-fg);
    position: relative;
    z-index: 60;
}

.header-brand { display: flex; align-items: center; gap: 10px; margin-right: 20px; }

.tab-row {
    display: flex;
    align-items: stretch;
    min-width: 0;
    flex: 0 1 auto;
    overflow-x: auto;
}

.tab-btn {
    display: flex;
    align-items: center;
    padding: 0 18px;
    background: transparent;
    border: 0;
    height: 100%;
    color: var(--tab-fg);
    font-size: 12.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background .12s ease, color .12s ease;
}

.tab-btn:hover { background: var(--tab-hover); color: #fff; text-decoration: none; }
.tab-btn.active { background: var(--tab-active-bg); color: var(--tab-fg-active); font-weight: 600; }

.wordmark {
    letter-spacing: .2px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

.wordmark span { color: var(--brand); }

.header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.badge {
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    background: rgba(255, 255, 255, .10);
    color: #d0d3d6;
    padding: 2px 8px;
    border-radius: 3px;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-warn { background: rgba(255, 196, 37, .18); color: #ffc425; }
.badge-shadow { background: rgba(169, 127, 201, .20); color: #cbb0e4; }

.h-icon-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    border: none;
    background: transparent;
    color: #a2a9b0;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}

.h-icon-btn:hover { background: var(--tab-hover); color: #fff; }
.h-icon-btn.on { background: var(--tab-active-bg); color: var(--brand); }

.brand-strip { height: 6px; flex-shrink: 0; background: var(--brand); }

.body { display: flex; flex: 1; min-height: 0; }

.sidebar {
    width: 210px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 6px 0;
}

.sidebar-head {
    padding: 6px 12px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--fg-muted);
}

.nav-tenant { padding: 2px 12px 8px; }
.nav-tenant .tenant-switch { display: block; margin: 0; }
.nav-tenant .tenant-switch select {
    width: 100%;
    min-width: 0;
    height: 26px;
    font-size: 12px;
    background-color: var(--panel);
    border: 1px solid var(--border-strong);
    color: var(--fg);
}

.sidebar nav { flex: 1; overflow-y: auto; min-height: 0; }

.side-item {
    height: 26px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border-radius: 0;
    font-size: 12.5px;
    color: var(--fg-body);
    cursor: pointer;
    user-select: none;
    transition: background .12s ease, color .12s ease;
}

.side-item:hover { background: var(--panel-alt); text-decoration: none; }
.side-item.active { background: var(--nav-sel); font-weight: 700; color: var(--fg); }

.sidebar-foot {
    padding: 8px 12px 4px;
    font-size: 11px;
    color: var(--fg-muted);
    border-top: 1px solid var(--border);
}

.main {
    flex: 1;
    min-width: 0;
    padding: 20px 32px;
    overflow-y: auto;
    overflow-x: auto;
    background: var(--bg);
    color: var(--fg);
}

.page-head { display: flex; align-items: center; gap: 12px; margin: 0 0 4px; }
.page-head h1 { font-size: 15px; font-weight: 700; margin: 0; }
.page-head .spacer { flex: 1; }

/* ---- banners ----------------------------------------------------------- */

.banner {
    padding: 10px 14px;
    border-radius: 3px;
    margin-bottom: 12px;
    font-size: 12.5px;
    border: 1px solid;
}

.banner strong { display: block; margin-bottom: 2px; font-weight: 700; }
.banner-body { opacity: .9; }
.banner-shadow { background: var(--shadow-bg); border-color: var(--shadow-tone); color: var(--shadow-tone); }
.banner-demo { background: var(--warn-bg); border-color: var(--warn-fg); color: var(--warn-fg); }

/* ---- cards ------------------------------------------------------------- */

.card {
    background: var(--panel);
    border-radius: 3px;
    padding: 16px;
    border: 1px solid var(--border-strong);
    min-width: 0;
}

/* The signature move: negative margins cancel the card's padding so the title band
   bleeds edge to edge, with the radius matched on the top two corners only. */
.card-title {
    margin: -16px -16px 12px;
    padding: 9px 16px;
    background: var(--titlebar);
    border-bottom: 1px solid var(--border-strong);
    border-radius: 3px 3px 0 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--fg);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title .hint { font-size: 11.5px; font-weight: 400; color: var(--fg-muted); }

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.kpi {
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    padding: 12px 14px;
}

.kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 700;
    color: var(--fg-muted);
}

.big-num { font-size: 34px; font-weight: 700; line-height: 1; margin: 6px 0 4px; }
.kpi-note { font-size: 11.5px; color: var(--fg-muted); }

.panel {
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    margin-bottom: 12px;
    overflow: hidden;
}

.panel-head {
    padding: 9px 16px;
    background: var(--titlebar);
    border-bottom: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.panel-head h2 { font-size: 13.5px; font-weight: 600; margin: 0; color: var(--fg); }
.panel-head .hint { font-size: 11.5px; color: var(--fg-muted); }

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

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

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }

th {
    text-align: left;
    height: 26px;
    padding: 0 8px;
    background: var(--panel-alt);
    border-bottom: 1px solid var(--th-rule);
    color: var(--fg);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}

td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color: var(--fg-body);
}

tbody tr { transition: background .12s ease; }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--row-hover); }

.mono { font-family: var(--font-mono); font-size: 12px; }
.dim { color: var(--fg-body); }
.faint { color: var(--fg-muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* The most important column on the screen. Never truncated, never behind a click. */
.reason { color: var(--fg-body); font-size: 12px; max-width: 520px; }

.empty { padding: 28px 16px; text-align: center; color: var(--fg-muted); font-size: 12.5px; }

/* ---- severity + status ------------------------------------------------- */

.sev { font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
.sev-Critical { color: var(--sev-critical); }
.sev-High { color: var(--sev-high); }
.sev-Moderate { color: var(--sev-moderate); }
.sev-Low { color: var(--sev-low); }
.sev-Informational, .sev-Unspecified { color: var(--sev-info); }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--chip-bg);
    border: 1px solid var(--border-strong);
    border-radius: 2px;
    padding: 1px 7px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--chip-fg);
    white-space: nowrap;
}

.pill-ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok-fg); }
.pill-warn { background: var(--warn-bg); border-color: var(--warn-fg); color: var(--warn-fg); }
.pill-bad { background: var(--danger-bg); border-color: var(--danger-fg); color: var(--danger-fg); }
.pill-shadow { background: var(--shadow-bg); border-color: var(--shadow-tone); color: var(--shadow-tone); }
.pill-idle { background: var(--panel-alt); border-color: var(--border-strong); color: var(--fg-muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.ack {
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: .08em;
    background: var(--accent-chip-bg);
    border: 1px solid var(--border-strong);
    border-radius: 2px;
    padding: 1px 6px;
    font-size: 11.5px;
    color: var(--link);
}

a.ack:hover { text-decoration: none; border-color: var(--accent); }

/* ---- timestamps --------------------------------------------------------
   Every time on screen carries its UTC instant in a data attribute, so the display mode can
   be switched client-side without a round trip and without the server guessing the viewer's
   zone. The rendered text is the tenant's zone by default: that is the zone the building is
   in, and it is the one an operator reasons in. */

time.ts { font-family: var(--font-mono); font-size: 12px; white-space: nowrap; cursor: help; }
time.ts .tz { color: var(--fg-subtle); font-size: 10.5px; margin-left: 3px; }

.ts-mode {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 2px;
    overflow: hidden;
}

.ts-mode button {
    background: var(--panel);
    color: var(--fg-body);
    border: 0;
    border-right: 1px solid var(--border-strong);
    padding: 0 9px;
    height: 22px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}

.ts-mode button:last-child { border-right: 0; }
.ts-mode button:hover { background: var(--panel-alt); }
.ts-mode button.on { background: var(--accent); color: var(--accent-fg); }

/* ---- detail ------------------------------------------------------------ */

.kv-grid { display: grid; grid-template-columns: 160px 1fr; gap: 5px 18px; padding: 14px 16px; font-size: 12.5px; }
.kv-grid dt { color: var(--fg-muted); font-weight: 600; }
.kv-grid dd { margin: 0; color: var(--fg-body); }

pre.body-text {
    margin: 0;
    padding: 12px 16px;
    background: var(--term-bg);
    color: var(--term-fg);
    border-top: 1px solid var(--border-strong);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.proof {
    font-size: 11.5px;
    color: var(--fg-body);
    font-style: italic;
    border-left: 2px solid var(--border-strong);
    padding-left: 9px;
    max-width: 620px;
}

.back { font-size: 11.5px; color: var(--fg-muted); display: inline-block; margin-bottom: 10px; }

/* ---- forms + buttons ---------------------------------------------------
   Buttons are the one pill in a square design language. Everything else is radius 2 or 3. */

.form { padding: 16px; display: grid; gap: 10px; max-width: 620px; }

label.f {
    display: block;
    font-size: 12px;
    color: var(--fg-muted);
    margin: 0 0 4px;
    font-weight: 600;
}

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=search], input[type=url], textarea, select {
    width: 100%;
    height: 28px;
    padding: 0 9px;
    border: 1px solid var(--input-border);
    border-radius: 3px;
    background: var(--input-bg);
    color: var(--fg);
}

textarea {
    height: auto;
    padding: 7px 9px;
    font-family: var(--font-mono);
    font-size: 12px;
    resize: vertical;
    min-height: 76px;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'><path d='M1 1l4 4 4-4' stroke='%236b7580' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

:root[data-theme="dark"] select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'><path d='M1 1l4 4 4-4' stroke='%239aa4ad' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

button.primary, a.primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    height: 28px;
    background: var(--accent);
    color: var(--accent-fg);
    border: 0;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .25px;
    cursor: pointer;
    justify-self: start;
    transition: background .12s ease;
}

button.primary:hover:not(:disabled), a.primary:hover { background: var(--accent-hover); }
button.primary:active:not(:disabled), a.primary:active { background: var(--accent-active); }
a.primary { text-decoration: none; color: var(--accent-fg); }
button:disabled { opacity: .45; cursor: not-allowed; }

.outcome {
    padding: 10px 12px;
    border-radius: 3px;
    font-size: 12.5px;
    background: var(--panel-alt);
    border: 1px solid var(--border-strong);
}

/* ---- scrollbars -------------------------------------------------------- */

* { scrollbar-width: thin; scrollbar-color: var(--track) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--track); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); }
::-webkit-scrollbar-track { background: transparent; }

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

@media (max-width: 820px) {
    .body { flex-direction: column; }
    .sidebar { width: 100%; flex: none; border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar nav { display: flex; flex-wrap: wrap; overflow: visible; }
    .sidebar-head, .sidebar-foot { display: none; }
    .tab-btn { padding: 0 12px; font-size: 11.5px; }
    .nav-tenant { width: 100%; }
    .side-item { padding: 0 10px; }
    .main { padding: 12px 14px; }
    .kv-grid { grid-template-columns: 1fr; gap: 2px 0; }
    .kv-grid dt { margin-top: 8px; }
}

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

/* ---- admin: header extras ---------------------------------------------- */

.badge-admin { background: var(--shadow-bg); color: #cbb0e4; }

.tenant-switch { display: inline-flex; margin: 0; }
.tenant-switch select {
    height: 26px;
    width: auto;
    min-width: 150px;
    background-color: rgba(255, 255, 255, .08);
    border-color: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 12px;
}
.tenant-switch select:focus { border-color: var(--brand); box-shadow: none; }

.op-name { font-size: 12px; color: #a2a9b0; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
a.op-name:hover { color: #fff; text-decoration: none; }

.h-text-link {
    font-size: 12px;
    font-weight: 600;
    color: #d0d3d6;
    padding: 0 10px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    border-radius: 2px;
    text-decoration: none;
    white-space: nowrap;
}
.h-text-link:hover { background: var(--tab-hover); color: #fff; text-decoration: none; }
.logout-form { display: inline-flex; margin: 0; }

/* ---- admin: forms + tables --------------------------------------------- */

label.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fg-body); cursor: pointer; }
label.check input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); }

.locked { padding: 5px 9px; background: var(--panel-alt); border: 1px dashed var(--border-strong); border-radius: 3px; color: var(--fg-body); }

.row-act { font-size: 12px; color: var(--link); cursor: pointer; }
.row-act:hover { text-decoration: underline; }
.row-act-danger { color: var(--danger-fg); background: none; border: 0; font: inherit; padding: 0; }
.row-editing { background: var(--row-alt); }

.danger-zone { margin-top: 6px; padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.danger-btn {
    height: 28px;
    padding: 0 14px;
    background: transparent;
    color: var(--danger-fg);
    border: 1px solid var(--danger-fg);
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s ease, color .12s ease;
}
.danger-btn:hover { background: var(--danger-fg); color: #fff; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.nowrap { white-space: nowrap; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.phone-row { align-items: end; grid-template-columns: 1fr 1fr auto; }
.phone-row [data-remove-phone] { height: 28px; margin-bottom: 1px; }
@media (max-width: 620px) {
    .field-row { grid-template-columns: 1fr; }
    .phone-row { grid-template-columns: 1fr; }
}

.validation-message { color: var(--danger-fg); font-size: 11.5px; display: block; margin-top: 3px; }

/* ---- login ------------------------------------------------------------- */

.bare { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.bare-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 28px 26px 26px;
    box-shadow: var(--shadow-pop);
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-word { font-size: 18px; font-weight: 700; color: var(--fg); }
.login-word span { color: var(--brand); }
.login-sub { font-size: 12px; color: var(--fg-muted); margin: 2px 0 20px; }
.login-form { display: grid; gap: 14px; }
.login-form button.primary { width: 100%; justify-self: stretch; margin-top: 4px; }
.login-error { background: var(--danger-bg); border: 1px solid var(--danger-fg); color: var(--danger-fg); font-size: 12px; padding: 8px 10px; border-radius: 3px; margin-bottom: 16px; }
.login-split {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 12px;
    color: var(--fg-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.login-split::before, .login-split::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-strong);
}
.secondary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    text-decoration: none;
}
.secondary-btn:hover { background: var(--panel-alt); }

.setup-steps {
    display: flex;
    gap: 18px;
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    font-size: 12px;
    color: var(--fg-muted);
}
.setup-steps li { display: flex; align-items: center; gap: 6px; }
.setup-steps li.is-current { color: var(--fg); font-weight: 600; }
.setup-steps .n {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}
.setup-steps li.is-current .n {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.optin-card {
    width: 100%;
    max-width: 480px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 28px 26px 26px;
    box-shadow: var(--shadow-pop);
}

.disclosure {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--fg-body);
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 10px 12px;
}
.setup-copy { font-size: 13px; color: var(--fg-body); margin: 0 0 12px; line-height: 1.45; }
a.primary.setup-cta { width: 100%; margin-top: 8px; height: 32px; }

/* ---- admin: tabs + inline forms ---------------------------------------- */

.tab {
    height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    font-size: 12.5px;
    color: var(--fg-body);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    background: var(--panel);
}
.tab:hover { text-decoration: none; background: var(--panel-alt); }
.tab-on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.tab-on:hover { background: var(--accent-hover); }

.inline-form { display: inline; margin: 0; }

.zap-step {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 12px;
    padding: 4px 0 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.zap-step:last-of-type { border-bottom: 0; margin-bottom: 0; }
.zap-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-fg);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.zap-title { font-size: 14px; font-weight: 700; margin: 4px 0 0; }

.template-input { width: 100%; min-height: 88px; font-family: var(--font-mono); font-size: 13px; }
.tag-group { font-size: 11px; color: var(--muted); margin: 10px 0 4px; letter-spacing: 0.02em; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
    font-family: var(--font-mono);
    font-size: 12px;
    border: 1px solid var(--border-strong);
    background: var(--panel);
    color: inherit;
    padding: 2px 8px;
    border-radius: 2px;
    cursor: pointer;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---- logs + timeline --------------------------------------------------- */

.filter-tabs {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 2px;
    overflow: hidden;
}

.filter-tabs a {
    background: var(--panel);
    color: var(--fg-body);
    border-right: 1px solid var(--border-strong);
    padding: 0 9px;
    height: 22px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.filter-tabs a:last-child { border-right: 0; }
.filter-tabs a:hover { background: var(--panel-alt); text-decoration: none; }
.filter-tabs a.on { background: var(--accent); color: var(--accent-fg); }

.log-table td { vertical-align: top; }

tr.log-error td:first-child,
li.log-error { box-shadow: inset 3px 0 0 var(--danger-fg); }
tr.log-warn td:first-child,
li.log-warn { box-shadow: inset 3px 0 0 var(--warn-fg); }

.timeline {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.timeline li {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.timeline li:last-child { border-bottom: 0; }
.timeline-when { font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); }
