/* AiLookout design system: tokens, base, components, app shell.
   Plain CSS, no framework, system fonts (the CSP forbids CDN fonts).
   Page-specific pieces (wizard stepper, pick callouts, remote view chrome, admin chart) live in pages.css.

   TOKENS (all on :root)
     Colour      --bg --surface --surface-2 --surface-3 --border --border-strong
                 --text --text-2 --text-3 --accent --accent-strong --accent-soft --accent-ink
     Status      --{ok|info|warn|danger|muted}-{bg|fg|border}; --healed-* is an alias of --info-*.
                 Solid marks (dots, bars): --ok --info --warn --danger --muted
     Space       --space-1..8 = 4 8 12 16 24 32 48 64 px (in rem)
     Type        --text-xs .75  --text-sm .8125  --text-base .875  --text-md 1  --text-lg 1.125
                 --text-xl 1.375  --text-2xl 1.75 (rem)
     Radius      --radius-xs 4  --radius-sm 6  --radius 10  --radius-lg 16  --radius-full
     Shadow      --shadow-xs --shadow --shadow-md --shadow-lg
     Focus       --focus-ring (box-shadow); :focus-visible draws a 2px accent outline by default
     Z-index     --z-sticky 20  --z-sidebar 30  --z-overlay 40  --z-menu 50  --z-toast 60  --z-top 1000
     Motion      --dur-fast 120ms  --dur 180ms  --ease ; all motion is off under prefers-reduced-motion
     Legacy      --ok-soft --warn-soft --bad --bad-soft --info-soft --slate --slate-soft --ring --vivid* --grad
                 still resolve; prefer the names above in new code.

   Dark mode: every colour is written once as  var(--L, light) var(--D, dark). --L/--D are the
   "space toggle" pair flipped by prefers-color-scheme and by :root[data-theme] (js/theme.js).

   COMPONENTS
     Button      .btn + .btn-primary | .btn-secondary | .btn-ghost ; .btn-danger (red text, add to ghost or
                 secondary) ; .btn-danger-solid ; sizes .btn-sm .btn-lg ; .btn-icon (square, needs aria-label) ;
                 .btn-block ; loading: .is-loading or aria-busy="true" ; group: .btn-group
     Badge       .badge + .badge-ok | -info | -warn | -danger | -muted | -accent | -outline ; optional
                 <span class="dot"> first. Also one class per WatchHealth, EventType, SnapshotStatus and
                 DeliveryStatus name, lower-cased (badge-broken, badge-watchhealed, badge-sent ...).
     Card        .card ; .card-head (h2 + actions) ; .card-head.flush + .card.pad-0 for edge-to-edge tables ;
                 .card-foot ; .card-link ; .card-grid
     Stat tile   a.card.stat-tile > .label .value .caption .icon ; tone .t-ok .t-info .t-warn .t-danger
     Table       .table-wrap > table.tbl (.tbl-compact) ; cells .num .trunc .actions .muted-cell ; .empty-row ;
                 table.tbl.table-cards stacks rows as cards on phones, labels from td[data-label] ;
                 td.cell-main marks the card title cell
     Form        .field > label|span.lbl + input.text-input + .hint + .field-error ; .field.has-error ;
                 .check ; .check-list ; .form-grid(.two) ; .form-actions ; .form-card
     Switch      label.switch > input[type=checkbox role=switch] + span + optional span.switch-label
                 (no visible label: put aria-label on the input)
     Tabs        .tabs > a.tab | button.tab ; active = .active | .is-active | aria-selected="true" ; .tab .count
     Alert       .alert + .alert-info | .alert-ok | .alert-warn | .alert-danger | .alert-muted ; plain text inside,
                 or .alert.alert-rich > .alert-icon + .alert-body (.alert-title, .alert-actions). Aliases: .alert-success .alert-warning .alert-error, .msg +
                 .msg-ok | .msg-err | .msg-info, .alert-inline.block, .callout. .alert-inline alone is
                 inline error text.
     Empty       .empty-state (alias .empty) > .empty-icon, h2, p, .empty-actions ; .empty-state.compact
     Page head   .page-head > div (.breadcrumb, h1, p) + .actions ; .toolbar (+ .toolbar-end) ; .breadcrumb > ol
     Timeline    .timeline > .tl-item > .tl-dot(.ok|.info|.warn|.danger or an EventType name) + .tl-body
                 (.title, .meta) + .tl-time
     Meta list   dl.kv > div > dt + dd (alias .meta-list) ; .kv.tight ; dd.wrap for long values
     Loading     .skeleton (.skeleton-text .skeleton-title .skeleton-block) ; .loading (spinner + text)
     Error text  .error-text : wraps, never truncated. Do not hide errors in a title attribute.
     Utilities   .stack .row .split .grow .muted .mono .strong .danger .hint .ellipsis .sr-only
                 .section-title .hide-sm (hidden under 640px) .show-sm */

/* ---------- Tokens ---------- */

:root {
    --L: initial; --D: ;
    color-scheme: light;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    --bg: var(--L, #f5f7fa) var(--D, #0b0f15);
    --surface: var(--L, #ffffff) var(--D, #131922);
    --surface-2: var(--L, #f0f2f6) var(--D, #1b2330);
    --surface-3: var(--L, #e3e8ef) var(--D, #242e3c);
    --border: var(--L, #dde2ea) var(--D, #273140);
    --border-strong: var(--L, #c6cdd8) var(--D, #364254);
    --text: var(--L, #141a22) var(--D, #e6eaf0);
    --text-2: var(--L, #465060) var(--D, #b4bcc8);
    --text-3: var(--L, #667182) var(--D, #8a94a3);

    --accent: var(--L, #0f766e) var(--D, #2dd4bf);
    --accent-strong: var(--L, #0b5f59) var(--D, #5eead4);
    --accent-soft: var(--L, #d8f1ee) var(--D, #10302e);
    --accent-ink: var(--L, #ffffff) var(--D, #06201e);

    --ok: var(--L, #15803d) var(--D, #4ade80);
    --ok-fg: var(--L, #166534) var(--D, #86efac);
    --ok-bg: var(--L, #e3f6e9) var(--D, #0d2f23);
    --ok-border: var(--L, #b4e2c2) var(--D, #1d5a3d);

    --info: var(--L, #1d4ed8) var(--D, #7fb2ff);
    --info-fg: var(--L, #1e429f) var(--D, #a9cbff);
    --info-bg: var(--L, #e6effe) var(--D, #0f1f3d);
    --info-border: var(--L, #bbd1fa) var(--D, #24427e);

    --warn: var(--L, #b45309) var(--D, #fbbf24);
    --warn-fg: var(--L, #8a4b08) var(--D, #fcd34d);
    --warn-bg: var(--L, #fdf2d3) var(--D, #33260a);
    --warn-border: var(--L, #f1d58b) var(--D, #6b4e0f);

    --danger: var(--L, #b42318) var(--D, #f87171);
    --danger-fg: var(--L, #a11c12) var(--D, #fca5a5);
    --danger-bg: var(--L, #fdeae8) var(--D, #3b1518);
    --danger-border: var(--L, #f4c0bb) var(--D, #7a2424);

    --muted: var(--L, #64748b) var(--D, #94a3b8);
    --muted-fg: var(--L, #475569) var(--D, #c3ccd9);
    --muted-bg: var(--L, #e9edf2) var(--D, #232d3b);
    --muted-border: var(--L, #d3d9e2) var(--D, #364254);

    --healed-fg: var(--info-fg); --healed-bg: var(--info-bg); --healed-border: var(--info-border);

    /* Second hue: brand gradient and the public pages only. Not a status colour. */
    --vivid: var(--L, #6366f1) var(--D, #818cf8);
    --vivid-strong: var(--L, #4f46e5) var(--D, #a5b4fc);
    --vivid-soft: var(--L, #e0e7ff) var(--D, #1e1b4b);
    --grad: var(--L, linear-gradient(135deg, #0f766e 0%, #2563eb 60%, #6366f1 100%))
            var(--D, linear-gradient(135deg, #14b8a6 0%, #3b82f6 60%, #818cf8 100%));

    --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
    --space-5: 1.5rem; --space-6: 2rem; --space-7: 3rem; --space-8: 4rem;

    --text-xs: 0.75rem; --text-sm: 0.8125rem; --text-base: 0.875rem; --text-md: 1rem;
    --text-lg: 1.125rem; --text-xl: 1.375rem; --text-2xl: 1.75rem;
    --leading-tight: 1.25; --leading: 1.5;

    --radius-xs: 4px; --radius-sm: 6px; --radius: 10px; --radius-lg: 16px; --radius-full: 999px;

    --shadow-xs: var(--L, 0 1px 2px rgba(16, 24, 40, 0.05)) var(--D, 0 1px 2px rgba(0, 0, 0, 0.4));
    --shadow: var(--L, 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 4px rgba(16, 24, 40, 0.04))
              var(--D, 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3));
    --shadow-md: var(--L, 0 4px 12px rgba(16, 24, 40, 0.08), 0 12px 32px rgba(16, 24, 40, 0.08))
                 var(--D, 0 4px 12px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.4));
    --shadow-lg: var(--L, 0 12px 32px rgba(16, 24, 40, 0.14)) var(--D, 0 12px 32px rgba(0, 0, 0, 0.55));
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);

    --z-sticky: 20; --z-sidebar: 30; --z-overlay: 40; --z-menu: 50; --z-toast: 60; --z-top: 1000;

    --dur-fast: 120ms; --dur: 180ms; --ease: cubic-bezier(0.2, 0, 0.2, 1);

    --gutter: 1rem;
    --max: 1120px;
    --sidebar: 240px;
    --topbar: 56px;

    /* Legacy names, kept so older markup and scoped CSS keep resolving. */
    --ok-soft: var(--ok-bg); --warn-soft: var(--warn-bg); --info-soft: var(--info-bg);
    --bad: var(--danger); --bad-soft: var(--danger-bg);
    --slate: var(--muted-fg); --slate-soft: var(--muted-bg);
    --ring: var(--focus-ring);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --L: ; --D: initial; color-scheme: dark; }
}
:root[data-theme="dark"] { --L: ; --D: initial; color-scheme: dark; }

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.55;
    color: var(--text); background: var(--bg); overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 0.5em; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; height: auto; display: block; }
ul { margin: 0; padding: 0; list-style: none; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.4em; border-radius: var(--radius-xs); }
button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Blazor focuses the page h1 after navigation for screen readers; no visible ring for that. */
h1:focus, h1:focus-visible { outline: none; }

.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;
}
.skip-link {
    position: absolute; left: var(--gutter); top: -100px; z-index: var(--z-top);
    background: var(--accent); color: var(--accent-ink); padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm); font-weight: 600; font-size: var(--text-base);
}
.skip-link:focus { top: var(--space-2); }

.container { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }

.ico { width: 1rem; height: 1rem; flex: none; display: inline-block; vertical-align: -0.15em; }
.ico-sm { width: 0.875rem; height: 0.875rem; }
.ico-lg { width: 1.25rem; height: 1.25rem; }
.ico-xl { width: 1.5rem; height: 1.5rem; }

/* ---------- Utilities ---------- */

.stack { display: grid; gap: var(--space-4); align-content: start; }
.stack-sm { display: grid; gap: var(--space-2); align-content: start; }
.split { display: grid; gap: var(--space-4); align-items: start; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 0.85em; }
.strong { font-weight: 600; color: var(--text); }
.danger { color: var(--danger-fg); }
.hint { margin: 0; font-size: var(--text-sm); color: var(--text-3); line-height: var(--leading); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; display: inline-block; vertical-align: bottom; }
.section-title { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin: 0 0 var(--space-2); font-weight: 600; }
.mb-16 { margin-bottom: var(--space-4); }
.mb-24 { margin-bottom: var(--space-5); }
.mt-16 { margin-top: var(--space-4); }
.show-sm { display: none; }
.error-text { color: var(--danger-fg); overflow-wrap: anywhere; white-space: normal; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: 2.25rem; padding: 0.4375rem 0.875rem; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-weight: 500; font-size: var(--text-base); line-height: 1.25;
    cursor: pointer; text-decoration: none; white-space: nowrap; background: transparent; color: var(--text);
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 1rem; height: 1rem; flex: none; }

.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { border-color: var(--text-3); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); padding-inline: 0.625rem; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger-fg); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-border); }
.btn-danger-solid { background: var(--danger); color: var(--L, #fff) var(--D, #2a0b0b); }
.btn-danger-solid:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 86%, var(--text)); }
.btn-lg { min-height: 2.875rem; padding: 0.75rem 1.5rem; font-size: 1.05rem; border-radius: var(--radius); }
.btn-sm { min-height: 1.875rem; padding: 0.25rem 0.625rem; font-size: var(--text-sm); }
.btn-icon { padding: 0; width: 2.25rem; height: 2.25rem; }
.btn-icon.btn-sm { width: 1.875rem; height: 1.875rem; }
.btn-icon svg { width: 1.125rem; height: 1.125rem; }
.btn-block { width: 100%; }

.btn.is-loading, .btn[aria-busy="true"] { pointer-events: none; opacity: 0.8; }
.btn.is-loading::before, .btn[aria-busy="true"]::before {
    content: ""; width: 0.875rem; height: 0.875rem; flex: none; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.btn.is-loading > svg, .btn[aria-busy="true"] > svg { display: none; }

.btn-group { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.btn-group-label { font-size: var(--text-xs); font-weight: 600; color: var(--text-3); padding: 0 var(--space-2); }

/* Two-step confirm (ConfirmButton.razor) */
.confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.confirm-question { font-size: var(--text-sm); font-weight: 500; color: var(--text); white-space: normal; }

/* ---------- Brand ---------- */

.brand { display: inline-flex; align-items: center; gap: 0.625rem; color: var(--text); font-weight: 600; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; flex: none; }
/* Mark colours are fixed in BrandMark.razor (brand gradient tile, white mark) so they hold in both themes. */

/* ---------- Badges ---------- */

.badge {
    display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.0625rem 0.5rem; border-radius: var(--radius-full);
    font-size: var(--text-xs); font-weight: 600; line-height: 1.6; white-space: nowrap;
    background: var(--muted-bg); color: var(--muted-fg); border: 1px solid var(--muted-border);
}
.badge .dot { width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: currentColor; flex: none; }
.badge svg { width: 0.8125rem; height: 0.8125rem; flex: none; }

/* tones */
.badge-ok, .badge-sent, .badge-on, .badge-watchhealed { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-border); }
.badge-info, .badge-healed, .badge-pending, .badge-nowmatches, .badge-fieldchanged { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-border); }
.badge-warn, .badge-unreachable, .badge-siteunreachable, .badge-suspicious { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-border); }
.badge-danger, .badge-bad, .badge-broken, .badge-failed, .badge-watchbroken, .badge-loginrequired { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-border); }
.badge-muted, .badge-slate, .badge-new, .badge-test { background: var(--muted-bg); color: var(--muted-fg); border-color: var(--muted-border); }
.badge-accent, .badge-newitem { background: var(--accent-soft); color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.badge-vivid { background: var(--vivid-soft); color: var(--vivid-strong); border-color: color-mix(in srgb, var(--vivid) 28%, transparent); }
.badge-outline, .badge-paused, .badge-off { background: transparent; color: var(--text-3); border-color: var(--border-strong); }
/* "Not checked yet": hollow dot, so it never reads as a result. */
.badge-new .dot { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.badge-paused .dot { border-radius: 1px; width: 0.375rem; height: 0.4375rem; background: linear-gradient(90deg, currentColor 35%, transparent 35% 65%, currentColor 65%); }

/* ---------- Cards ---------- */

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: var(--space-5); box-shadow: var(--shadow);
}
.card h2 { margin-bottom: var(--space-2); }
.card.pad-0 { padding: 0; overflow: hidden; }
.card .card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-4); }
.card .card-head h2 { margin: 0; }
.card .card-head.flush { padding: var(--space-3) var(--space-4); margin: 0; border-bottom: 1px solid var(--border); }
.card .card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.card.pad-0 .card-foot { margin: 0; padding: var(--space-3) var(--space-4); }
.card-link { display: block; color: inherit; transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.card-link:hover { text-decoration: none; box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card-grid { display: grid; gap: var(--space-4); }

/* ---------- Stat tiles ---------- */

.stat-tile {
    --tile: var(--muted-fg); --tile-soft: var(--surface-2);
    position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--space-3);
    padding: var(--space-4) var(--space-4) var(--space-4) var(--space-5); color: inherit;
}
.stat-tile .label { grid-column: 1; font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); }
.stat-tile .value { grid-column: 1; font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--text); }
.stat-tile .caption { grid-column: 1; font-size: var(--text-sm); color: var(--text-3); min-height: 1.2em; }
.stat-tile .caption .warn { color: var(--danger-fg); font-weight: 600; }
.stat-tile .icon {
    grid-column: 2; grid-row: 1 / span 3; align-self: start; width: 2.25rem; height: 2.25rem; border-radius: var(--radius-sm);
    display: grid; place-items: center; background: var(--tile-soft); color: var(--tile); vertical-align: 0;
}
.stat-tile .icon svg { width: 1.125rem; height: 1.125rem; }
.stat-tile.t-ok { --tile: var(--ok-fg); --tile-soft: var(--ok-bg); }
.stat-tile.t-info, .stat-tile.t-vivid { --tile: var(--info-fg); --tile-soft: var(--info-bg); }
.stat-tile.t-warn { --tile: var(--warn-fg); --tile-soft: var(--warn-bg); }
.stat-tile.t-bad, .stat-tile.t-danger { --tile: var(--danger-fg); --tile-soft: var(--danger-bg); }
.stat-tile.t-accent { --tile: var(--accent-strong); --tile-soft: var(--accent-soft); }
/* A tile that reports trouble carries a status edge; calm tiles stay neutral. */
.stat-tile.t-warn::before, .stat-tile.t-bad::before, .stat-tile.t-danger::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tile);
    border-radius: var(--radius) 0 0 var(--radius);
}

/* ---------- Tables ---------- */

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.tbl th, .tbl td { padding: 0.625rem var(--space-4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.tbl thead th {
    font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); font-weight: 600;
    background: var(--surface-2); white-space: nowrap;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background var(--dur-fast) var(--ease); }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .actions, td.actions { white-space: nowrap; text-align: right; width: 1%; }
.tbl .actions .btn { min-height: 1.875rem; padding: 0.25rem 0.625rem; font-size: var(--text-sm); }
.tbl .actions .btn svg { width: 0.9375rem; height: 0.9375rem; }
.tbl-compact th, .tbl-compact td { padding: var(--space-2) var(--space-3); font-size: var(--text-sm); }
.tbl .err { color: var(--danger-fg); }
.tbl a.row-link { color: var(--text); font-weight: 600; }
.tbl a.row-link:hover { color: var(--accent); }
.tbl td.muted-cell { color: var(--text-3); }
.tbl .empty-row td { text-align: center; color: var(--text-3); padding: var(--space-6) var(--space-4); }
.tbl .empty-row:hover td { background: none; }
.tbl-title { padding: var(--space-3) var(--space-4); margin: 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.tbl-title h2 { margin: 0; }

/* ---------- Forms ---------- */

.form-grid { display: grid; gap: var(--space-4); }
.field { display: grid; gap: 0.375rem; margin: 0; min-width: 0; }
.field + .field { margin-top: var(--space-4); }
.form-grid .field + .field { margin-top: 0; }
.field > span, .field > label, .field > .lbl { font-size: var(--text-sm); font-weight: 600; color: var(--text-2); }
.field > span .muted, .field > label .muted, .field .optional { font-weight: 400; color: var(--text-3); }
.field > label.check { font-size: var(--text-base); font-weight: 400; }
.text-input,
.field input[type="text"], .field input[type="password"], .field input[type="url"], .field input[type="email"],
.field input[type="number"], .field input[type="search"], .field input[type="time"], .field input[type="tel"],
.field select, .field textarea {
    width: 100%; min-height: 2.25rem; padding: 0.4375rem 0.75rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-base); line-height: 1.4;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.text-input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.text-input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--text-3); }
.text-input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.text-input:disabled, .field input:disabled, .field select:disabled, .field textarea:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
.field input[type="checkbox"], .field input[type="radio"] { width: auto; min-height: 0; }
select.text-input, .field select {
    appearance: none; padding-right: 2.25rem; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.625rem center; background-size: 1rem;
}
.field small, .field .hint { color: var(--text-3); font-size: var(--text-sm); }
.field small a, .hint a { font-weight: 500; }
.field-error, .validation-message { display: block; color: var(--danger-fg); font-size: var(--text-sm); font-weight: 500; overflow-wrap: anywhere; }
.field.has-error .text-input, .field.has-error input, .field.has-error select, .field.has-error textarea,
.text-input.invalid, .text-input[aria-invalid="true"] { border-color: var(--danger); }
.field.has-error .text-input:focus, .text-input.invalid:focus, .text-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
.check { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-base); color: var(--text-2); cursor: pointer; min-height: 1.5rem; }
.check input { width: 1rem; height: 1rem; margin: 0; flex: none; accent-color: var(--accent); }
.check-list { display: grid; gap: var(--space-2); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-5); }
.form-actions .saved, .saved { display: inline-flex; align-items: center; gap: 0.375rem; color: var(--ok-fg); font-size: var(--text-base); font-weight: 500; }
.saved svg { width: 0.9375rem; height: 0.9375rem; }
.saved-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); min-height: 2.25rem; }

.form-card h2 { margin: 0 0 var(--space-4); }
.form-card h2 + .muted { margin-top: calc(-1 * var(--space-2)); }
.form-card h3 { margin: var(--space-5) 0 var(--space-2); }
.form-card.narrow { max-width: 600px; }
.form-card .section-break { margin: var(--space-5) 0 var(--space-4); padding-top: var(--space-5); border-top: 1px solid var(--border); }

/* ---------- Switch ---------- */

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); min-height: 1.5rem; flex: none; vertical-align: middle; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 2.375rem; height: 1.375rem; margin: 0; left: 0; cursor: pointer; }
.switch input + span { position: relative; flex: none; width: 2.375rem; height: 1.375rem; border-radius: var(--radius-full); background: var(--border-strong); transition: background var(--dur-fast) var(--ease); }
.switch input + span::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 1rem; height: 1rem; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform var(--dur-fast) var(--ease);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(1rem); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled, .switch input:disabled + span { cursor: not-allowed; }
.switch input:disabled + span { opacity: 0.5; }
.switch-label { font-size: var(--text-base); font-weight: 500; color: var(--text-2); }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: var(--space-1); margin: 0 0 var(--space-4); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    display: inline-flex; align-items: center; gap: var(--space-2); flex: none; min-height: 2.5rem; padding: 0 var(--space-3);
    margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
    color: var(--text-2); font: inherit; font-size: var(--text-base); font-weight: 500; white-space: nowrap;
    transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text); text-decoration: none; border-bottom-color: var(--border-strong); }
.tab.active, .tab.is-active, .tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--accent-strong); border-bottom-color: var(--accent); font-weight: 600; }
.tab:focus-visible { outline-offset: -2px; border-radius: var(--radius-xs); }
.tab .count, .count-pill { font-size: var(--text-xs); font-weight: 600; padding: 0 0.4375rem; border-radius: var(--radius-full); background: var(--surface-2); color: var(--text-3); line-height: 1.6; }

/* ---------- Alerts / banners (one system) ---------- */

.alert, .msg, .alert-inline.block, .callout {
    --a-fg: var(--info-fg); --a-bg: var(--info-bg); --a-border: var(--info-border);
    display: block; margin: 0 0 var(--space-4);
    padding: 0.625rem 0.875rem; border-radius: var(--radius-sm); border: 1px solid var(--a-border);
    background: var(--a-bg); color: var(--a-fg); font-size: var(--text-base); line-height: var(--leading); overflow-wrap: anywhere;
}
.alert-ok, .alert-success, .msg-ok { --a-fg: var(--ok-fg); --a-bg: var(--ok-bg); --a-border: var(--ok-border); }
.alert-warn, .alert-warning { --a-fg: var(--warn-fg); --a-bg: var(--warn-bg); --a-border: var(--warn-border); }
.alert-danger, .alert-error, .msg-err, .alert-inline.block { --a-fg: var(--danger-fg); --a-bg: var(--danger-bg); --a-border: var(--danger-border); }
.alert-info, .msg-info { --a-fg: var(--info-fg); --a-bg: var(--info-bg); --a-border: var(--info-border); }
.alert-muted { --a-fg: var(--text-2); --a-bg: var(--surface-2); --a-border: var(--border); }
/* Icon + body layout: what Alert.razor renders. Plain text or a list straight inside .alert stays a block. */
.alert-rich, .callout { display: flex; gap: var(--space-2) var(--space-3); align-items: flex-start; }
.alert > svg, .alert-icon, .callout > svg { width: 1.125rem; height: 1.125rem; flex: none; margin-top: 0.125rem; }
.alert-body { flex: 1; min-width: 0; }
.alert-body > :last-child, .callout p { margin-bottom: 0; }
.alert-title { display: block; font-weight: 600; }
.alert-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; }
.alert .btn { text-decoration: none; }
.alert ul { margin: 0; padding-left: 1.125rem; list-style: disc; }
.alert-dismiss { flex: none; margin: -0.25rem -0.375rem -0.25rem 0; color: inherit; }
.msg { margin: var(--space-3) 0 0; }
.callout { color: var(--text-2); }
.callout > svg { color: var(--info); }
/* Inline error text next to a control. */
.alert-inline { display: inline-flex; align-items: center; gap: 0.375rem; color: var(--danger-fg); font-size: var(--text-base); font-weight: 500; }

/* Blazor error bar (template behaviour, restyled) */
#blazor-error-ui {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-top);
    padding: var(--space-3) 3rem var(--space-3) var(--gutter); background: var(--L, #b42318) var(--D, #7a1d16); color: #fff;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); font-size: var(--text-base);
}
#blazor-error-ui a { color: #fff; text-decoration: underline; margin-left: var(--space-2); }
#blazor-error-ui .dismiss {
    cursor: pointer; position: absolute; right: var(--space-2); top: 50%; transform: translateY(-50%);
    width: 2.25rem; height: 2.25rem; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: none; color: #fff;
}
#blazor-error-ui .dismiss:hover { background: rgba(255, 255, 255, 0.15); }
#blazor-error-ui .dismiss svg { width: 1.125rem; height: 1.125rem; }

/* ---------- Empty state ---------- */

.empty-state, .empty {
    text-align: center; padding: var(--space-7) var(--space-5); color: var(--text-2);
    border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.empty-state h2, .empty h2, .empty-state h3 { color: var(--text); font-size: var(--text-lg); margin: var(--space-4) 0 var(--space-1); }
.empty-state p, .empty p { max-width: 48ch; margin: 0 auto var(--space-4); }
.empty-state > :last-child, .empty > :last-child { margin-bottom: 0; }
.empty .row, .empty-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.empty-icon { width: 3rem; height: 3rem; margin: 0 auto; border-radius: var(--radius); display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.empty-icon svg { width: 1.5rem; height: 1.5rem; }
.empty-state.compact { padding: var(--space-5) var(--space-4); border: 0; background: none; }
.empty-state.compact h2, .empty-state.compact h3 { font-size: var(--text-md); margin-top: var(--space-3); }
.empty-art { width: 160px; margin: 0 auto; }
.empty-art .a { stroke: var(--accent); }
.empty-art .v { stroke: var(--vivid); }
.empty-art .f { fill: var(--surface-2); stroke: var(--border-strong); }
.empty-art .g { fill: var(--accent-soft); }

/* ---------- Page header, breadcrumb, toolbar ---------- */

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--space-3) var(--space-4); margin-bottom: var(--space-5); }
.page-head > div:first-child, .page-head-main { min-width: 0; flex: 1 1 18rem; }
.page-head h1 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); overflow-wrap: anywhere; }
.page-head p { margin: var(--space-1) 0 0; color: var(--text-2); max-width: 64ch; }
.page-head .actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

.breadcrumb, .crumbs { min-width: 0; font-size: var(--text-sm); color: var(--text-3); }
.breadcrumb ol, .crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; margin: 0; padding: 0; list-style: none; }
.breadcrumb li, .crumbs li { display: inline-flex; align-items: center; gap: 0.375rem; min-width: 0; }
.breadcrumb li + li::before, .crumbs li + li::before { content: "/"; color: var(--border-strong); }
.breadcrumb a, .crumbs a { color: var(--text-2); }
.breadcrumb a:hover, .crumbs a:hover { color: var(--text); }
.breadcrumb li[aria-current="page"], .crumbs li[aria-current="page"] { display: block; }
.breadcrumb [aria-current="page"], .crumbs [aria-current="page"] { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head .breadcrumb { margin-bottom: var(--space-1); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-4); }
.toolbar .text-input { width: auto; flex: 1 1 12rem; max-width: 22rem; }
.toolbar-end { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* ---------- Timeline ---------- */

.timeline { display: grid; position: relative; margin: 0; padding: 0; list-style: none; }
.tl-item { position: relative; display: grid; grid-template-columns: 1.25rem minmax(0, 1fr) auto; gap: 0 var(--space-3); padding: var(--space-2) 0; }
.tl-item::before { content: ""; position: absolute; left: calc(0.625rem - 1px); top: 0; bottom: 0; width: 2px; background: var(--border); }
.tl-item:first-child::before { top: 1rem; }
.tl-item:last-child::before { bottom: calc(100% - 1rem); }
.tl-item:only-child::before { display: none; }
.tl-dot {
    --dot: var(--muted);
    position: relative; z-index: 1; width: 0.75rem; height: 0.75rem; border-radius: 50%; margin: 0.3125rem 0.25rem 0;
    background: var(--dot); box-shadow: 0 0 0 3px var(--surface);
}
.tl-dot.ok, .tl-dot.watchhealed, .tl-dot.sent { --dot: var(--ok); }
.tl-dot.info, .tl-dot.nowmatches, .tl-dot.fieldchanged, .tl-dot.healed { --dot: var(--info); }
.tl-dot.warn, .tl-dot.siteunreachable, .tl-dot.unreachable, .tl-dot.suspicious { --dot: var(--warn); }
.tl-dot.danger, .tl-dot.watchbroken, .tl-dot.loginrequired, .tl-dot.broken, .tl-dot.failed { --dot: var(--danger); }
.tl-dot.accent, .tl-dot.newitem { --dot: var(--accent); }
.tl-dot.muted, .tl-dot.test { --dot: var(--muted); }
.tl-body { min-width: 0; }
.tl-body .title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem var(--space-2); }
.tl-body .meta { color: var(--text-3); font-size: var(--text-sm); margin-top: 2px; overflow-wrap: anywhere; }
.tl-time { color: var(--text-3); font-size: var(--text-sm); white-space: nowrap; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- Lists ---------- */

.list { display: grid; }
.list-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.375rem var(--space-3); padding: 0.625rem 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.list-item > div { min-width: 0; }
.list-item .title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem var(--space-2); }
.list-item .meta { color: var(--text-3); font-size: var(--text-sm); }
.list-item .meta.err { color: var(--danger-fg); overflow-wrap: anywhere; }

/* ---------- Key-value meta list ---------- */

.kv, .meta-list { margin: 0; display: grid; gap: 0.375rem; font-size: var(--text-base); }
.kv > div, .meta-list > div { display: flex; gap: var(--space-2); min-width: 0; }
.kv dt, .meta-list dt { color: var(--text-3); flex: none; min-width: 7rem; }
.kv dd, .meta-list dd { margin: 0; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv dd.wrap, .meta-list dd.wrap, .kv.wrap dd { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
.kv.tight { gap: 2px; font-size: var(--text-sm); }
.kv.tight dt { min-width: 0; }
.kv.tight dt::after { content: ":"; }

/* ---------- Loading ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.loading { display: inline-flex; align-items: center; gap: 0.625rem; color: var(--text-3); padding: var(--space-5) 0; margin: 0; }
.loading::before {
    content: ""; width: 1rem; height: 1rem; flex: none; border-radius: 50%;
    border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite;
}
.skeleton {
    display: block; min-height: 0.875rem; border-radius: var(--radius-xs); color: transparent; user-select: none;
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%) 0 0 / 200% 100%;
    animation: shimmer 1.4s linear infinite;
}
.skeleton-text { height: 0.875rem; width: 60%; margin: 0.375rem 0; }
.skeleton-title { height: 1.375rem; width: 40%; margin-bottom: var(--space-3); }
.skeleton-block { height: 6rem; border-radius: var(--radius); }
.running-dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--accent); animation: pulse 1.1s ease-in-out infinite; margin-right: 0.375rem; vertical-align: middle; }

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

.app { min-height: 100vh; display: flex; font-size: var(--text-base); line-height: var(--leading); }
.app h1 { font-size: var(--text-xl); letter-spacing: -0.015em; line-height: var(--leading-tight); }
.app h2 { font-size: var(--text-md); letter-spacing: 0; }
.app h3 { font-size: var(--text-base); letter-spacing: 0; }
.app-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Mobile nav: a real checkbox (keyboard: Tab to it, Space toggles). The visible hamburger is its label. */
.nav-check { position: fixed; top: 0.625rem; left: var(--gutter); z-index: calc(var(--z-sidebar) + 2); width: 2.25rem; height: 2.25rem; margin: 0; opacity: 0; cursor: pointer; }
.nav-toggle { display: inline-flex; flex: none; }
.nav-toggle svg { width: 1.25rem; height: 1.25rem; }
.nav-check:focus-visible ~ .app-col .nav-toggle { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-check:checked ~ .app-col .nav-toggle { background: var(--surface-2); color: var(--text); }

.app-topbar {
    position: sticky; top: 0; z-index: var(--z-sidebar); height: var(--topbar); flex: none;
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    padding-inline: var(--gutter);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.app-topbar .left, .app-topbar .right { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.app-topbar .left { flex: 1; }
.app-topbar .right { flex: none; }
.app-topbar .crumbs { font-size: var(--text-base); }
.app-topbar .crumbs ol { flex-wrap: nowrap; }
.app-topbar .crumbs li:not(:last-child) { display: none; }
.app-topbar .crumbs li + li::before { display: none; }
.app-topbar form { display: inline; margin: 0; }
.user-chip { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; color: var(--text-2); font-size: var(--text-sm); }
.user-chip .avatar {
    flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: var(--text-xs); text-transform: uppercase;
}
.user-chip .email { display: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 15rem; }

.sidebar {
    position: fixed; top: var(--topbar); bottom: 0; left: 0; z-index: calc(var(--z-sidebar) + 1);
    width: min(17rem, 85vw); display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--border);
    padding: var(--space-3); overflow-y: auto;
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.nav-check:checked ~ .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition-delay: 0s; }
.sidebar-backdrop { display: none; position: fixed; inset: var(--topbar) 0 0 0; z-index: var(--z-sidebar); background: rgba(8, 12, 20, 0.45); }
.nav-check:checked ~ .sidebar-backdrop { display: block; }

.sidebar-brand { display: none; align-items: center; gap: 0.625rem; padding: var(--space-1) var(--space-2) var(--space-4); }
.sidebar-brand .tag {
    margin-left: auto; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
    padding: 1px 0.4375rem; border-radius: var(--radius-full); background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border);
}
.sidebar-section { padding: var(--space-4) var(--space-3) var(--space-1); font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.sidebar-brand + .sidebar-section, .sidebar > .sidebar-section:first-child { padding-top: var(--space-1); }
.sidebar-nav { display: grid; gap: 2px; }
.sidebar-nav a, .sidebar-foot .help {
    position: relative; display: flex; align-items: center; gap: 0.625rem; min-height: 2.25rem; padding: 0.375rem var(--space-3);
    border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; font-size: var(--text-base);
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sidebar-nav a svg, .sidebar-foot .help svg { width: 1.125rem; height: 1.125rem; flex: none; color: var(--text-3); }
.sidebar-nav a:hover, .sidebar-foot .help:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.sidebar-nav a.active svg { color: currentColor; }
.sidebar-nav a.active::before {
    content: ""; position: absolute; left: calc(-1 * var(--space-3)); top: 0.5rem; bottom: 0.5rem; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--accent);
}
.sidebar-nav a .count { margin-left: auto; font-size: var(--text-xs); font-weight: 600; padding: 0 0.4375rem; border-radius: var(--radius-full); background: var(--surface-2); color: var(--text-3); }
.sidebar-foot { margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.sidebar-foot .help { flex: 1; min-width: 0; }

.app-main { flex: 1; min-width: 0; width: 100%; max-width: 1280px; margin-inline: auto; padding: var(--space-5) var(--gutter) var(--space-7); }
.app-main:focus { outline: none; }

/* Background-checker status in the top bar (SchedulerPill.razor). */
.sched-pill {
    position: relative; display: inline-flex; align-items: center; gap: 0.4375rem; min-height: 1.75rem; padding: 0 0.6875rem; border-radius: var(--radius-full);
    font-size: var(--text-xs); font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); white-space: nowrap;
}
.sched-pill .dot { width: 0.5rem; height: 0.5rem; flex: none; border-radius: 50%; background: var(--muted); }
.sched-running .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); animation: pulse 2.4s ease-in-out infinite; }
.sched-degraded { color: var(--warn-fg); border-color: var(--warn-border); background: var(--warn-bg); }
.sched-degraded .dot { background: var(--warn); }
.sched-stalled { color: var(--danger-fg); border-color: var(--danger-border); background: var(--danger-bg); }
.sched-stalled .dot { background: var(--danger); }
.sched-attn { color: var(--warn-fg); padding-left: 0.5rem; margin-left: 0.0625rem; border-left: 1px solid var(--border-strong); text-decoration: none; }
.sched-attn:hover { text-decoration: underline; }
.sched-pill.has-attn { border-color: var(--warn-border); background: var(--warn-bg); }
.sched-stalled .sched-attn { color: inherit; border-left-color: var(--danger-border); }
.sched-stalled.has-attn { border-color: var(--danger-border); background: var(--danger-bg); }

/* ======================================================================
   Public layout chrome (header, nav, footer) shared by landing, guide and account pages.
   Landing/guide content styles live in public.css.
   ====================================================================== */

.site-header {
    position: sticky; top: 0; z-index: var(--z-sticky);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: var(--space-3); }
.site-nav { display: flex; align-items: center; gap: var(--space-2); }
.site-nav .nav-links { display: none; gap: var(--space-1); margin-right: var(--space-3); }
.site-nav .nav-links a { color: var(--text-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-weight: 500; font-size: 0.95rem; }
.site-nav .nav-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.site-main { min-height: 60vh; }
.site-footer { border-top: 1px solid var(--border); padding: 2.5rem 0 2rem; color: var(--text-3); font-size: 0.9rem; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-6); justify-content: space-between; align-items: center; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--space-2) 1.25rem; }
.site-footer a { color: var(--text-2); }
.site-footer .brand + p { margin: var(--space-2) 0 0; }

/* ---------- Responsive ---------- */

/* Touch: every control gets a 44px target. */
@media (pointer: coarse) {
    .btn { min-height: 2.75rem; }
    .btn-sm, .tbl .actions .btn { min-height: 2.5rem; padding-inline: 0.75rem; }
    .btn-icon { width: 2.75rem; height: 2.75rem; }
    .btn-icon.btn-sm { width: 2.5rem; height: 2.5rem; }
    .text-input, .field input:not([type="checkbox"]):not([type="radio"]), .field select { min-height: 2.75rem; }
    .sidebar-nav a, .sidebar-foot .help { min-height: 2.75rem; }
    .tab { min-height: 2.75rem; }
    .check { min-height: 2.75rem; }
    .nav-check { top: 0.375rem; width: 2.75rem; height: 2.75rem; }
}

@media (max-width: 639.98px) {
    .hide-sm { display: none !important; }
    .show-sm { display: revert; }
    /* iOS zooms the page when a focused input is under 16px. */
    .text-input, .field input, .field select, .field textarea { font-size: 1rem; }
    .card { padding: var(--space-4); }
    .card.pad-0 { padding: 0; }
    .page-head { align-items: stretch; }
    .page-head .actions { width: 100%; }
    .page-head .actions .btn-primary { flex: 1 1 auto; }
    .toolbar .text-input { max-width: none; flex-basis: 100%; }
    .toolbar-end { margin-left: 0; }
    .form-actions .btn-primary { flex: 1 1 auto; }
    .tl-item { grid-template-columns: 1.25rem minmax(0, 1fr); }
    .tl-time { grid-column: 2; }
    .kv > div, .meta-list > div { flex-direction: column; gap: 0; }
    .kv.tight > div { flex-direction: row; gap: var(--space-1); }
    .kv dt, .meta-list dt { min-width: 0; font-size: var(--text-sm); }
    .kv dd, .meta-list dd { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
    .empty-state, .empty { padding: var(--space-6) var(--space-4); }
    .sched-pill .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
    .sched-pill { padding: 0 0.5625rem; }
    .sched-attn { padding-left: 0; margin-left: 0; border-left: 0; }

    /* table.table-cards: each row becomes a card, each cell a "label: value" line. */
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: auto; }
    .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .table-cards tbody tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
    .table-cards tbody tr:last-child { border-bottom: 0; }
    .table-cards tbody tr:hover td { background: none; }
    .table-cards td, .tbl.table-cards td { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-1) var(--space-3); padding: 0.1875rem 0; border: 0; text-align: right; max-width: none; white-space: normal; overflow: visible; overflow-wrap: anywhere; }
    .table-cards td[data-label]::before { content: attr(data-label); flex: none; font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); text-align: left; }
    .table-cards td:not([data-label]), .table-cards td.cell-main { justify-content: flex-start; text-align: left; }
    .table-cards td.cell-main { font-size: var(--text-md); font-weight: 600; padding-bottom: var(--space-1); }
    .table-cards td.cell-main::before { display: none; }
    .table-cards td:empty { display: none; }
    .table-cards td.actions { justify-content: flex-start; gap: var(--space-2); padding-top: var(--space-2); width: auto; white-space: normal; }
    .table-cards td.actions::before { display: none; }
    .table-cards .empty-row td { justify-content: center; text-align: center; }
}

@media (min-width: 640px) {
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .user-chip .email { display: block; }
    .app-topbar .right { gap: var(--space-3); }
}

@media (min-width: 900px) {
    :root { --gutter: 1.5rem; }
    .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .split { grid-template-columns: minmax(0, 1fr) 340px; }
    .split-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .nav-check, .nav-toggle { display: none; }
    .app-topbar { z-index: var(--z-sticky); }
    .app-topbar .crumbs li:not(:last-child) { display: inline-flex; }
    .app-topbar .crumbs li + li::before { display: inline; }
    .sidebar {
        position: sticky; top: 0; height: 100vh; flex: none; width: var(--sidebar); z-index: auto;
        transform: none; visibility: visible; padding: var(--space-4) var(--space-3) var(--space-3); transition: none;
    }
    .sidebar-brand { display: flex; }
    .nav-check:checked ~ .sidebar { box-shadow: none; }
    .sidebar-backdrop, .nav-check:checked ~ .sidebar-backdrop { display: none; }
    .app-main { padding: var(--space-6) var(--space-6) var(--space-8); }
    .site-nav .nav-links { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Password box with a show/hide eye (PasswordToggle.razor) ---------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap > .text-input { padding-right: 44px; }
/* The wrapper is a span inside a field, where a bare span is a label. It is not one. */
.field > span.pw-wrap, label > span.pw-wrap {
    font-size: inherit; font-weight: 400; text-transform: none; letter-spacing: normal; color: inherit; margin: 0;
}
.pw-wrap > .text-input { font-weight: 400; letter-spacing: normal; text-transform: none; }
.pw-toggle {
    position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0;
    border: 0; border-radius: var(--radius-sm); background: transparent;
    color: var(--text-3); cursor: pointer;
}
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.pw-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* Shown: the eye is struck through, meaning "press to hide". */
.pw-toggle.is-shown { color: var(--accent); }
.pw-toggle.is-shown::after {
    content: ""; position: absolute; width: 22px; height: 2px; border-radius: 2px;
    background: currentColor; transform: rotate(-45deg);
}
