/* ==========================================================================
   DARK PULSE — Design System
   --------------------------------------------------------------------------
   Reference mood : Linear — "midnight precision instrument".
   Rules          : near-black canvas, paper-white type, hairline borders
                    instead of shadows. Weights stay in the 400–590 band.
                    One chromatic action colour (acid lime) — one filled
                    primary button per view, never decoration.
                    Severity colours are data labels, not actions.
   Ownership      : shared by login / view / dashboard. Page-specific layout
                    lives in page-*.css, never here.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS
   -------------------------------------------------------------------------- */

:root {
    color-scheme: dark;

    /* --- surfaces (elevation = surface step + hairline, not shadow) ------ */
    --color-void:      #08090a;   /* page canvas                            */
    --color-carbon:    #0f1011;   /* cards, sidebar, nav                    */
    --color-obsidian:  #161718;   /* elevated panels, modal header          */
    --color-hover:     rgba(255, 255, 255, 0.03);
    --color-fill:      rgba(255, 255, 255, 0.05);   /* pills, badges        */
    --color-fill-strong: rgba(255, 255, 255, 0.08); /* active pill/pager    */

    /* --- text (all body copy sits on this grey ladder) ------------------ */
    --color-paper:     #ffffff;   /* headings, active labels                */
    --color-mist:      #d0d6e0;   /* body                                   */
    --color-fog:       #8a8f98;   /* muted meta, captions (6.3:1 on void)   */
    --color-ash:       #62666d;   /* placeholder, disabled ONLY (3.4:1)     */

    /* --- lines ---------------------------------------------------------- */
    --color-line:        #23252a; /* hairline dividers, card edges          */
    --color-line-strong: #383b3f; /* hover edges, section separators        */
    --color-line-input:  rgba(255, 255, 255, 0.08);

    /* --- action: the only chromatic UI element --------------------------- */
    --color-accent:       #e4f222;
    --color-accent-hover: #edf75c;
    --color-on-accent:    #08090a;
    --color-focus:        #6366f1; /* focus ring (iris), 4.3:1 on void      */

    /* --- data labels (badges, tags, indicators — never actions) --------- */
    --color-green:   #27a644;      /* live status dot                       */
    --color-green-text: #4cc26a;
    --color-red:     #eb5757;
    --color-iris:    #6366f1;
    --color-iris-text: #a5a7f7;
    --color-lavender:#8b5cf6;
    --color-teal:    #02b8cc;

    /* --- semantic severity: text colour + 12% wash for the badge fill --- */
    --sev-critical:      #f07474;
    --sev-critical-wash: rgba(235, 87, 87, 0.14);
    --sev-high:          #f2a15e;
    --sev-high-wash:     rgba(242, 153, 74, 0.13);
    --sev-medium:        #a5a7f7;
    --sev-medium-wash:   rgba(99, 102, 241, 0.16);
    --sev-low:           #8a8f98;
    --sev-low-wash:      rgba(255, 255, 255, 0.05);

    /* --- channel state --------------------------------------------------- */
    --state-ok:   #4cc26a;
    --state-warn: #f2a15e;
    --state-dead: #f07474;
    --state-idle: #8a8f98;

    /* --- type ------------------------------------------------------------
       Inter carries Latin; Hangul falls through to Pretendard, which is
       metrically close enough that mixed lines keep one baseline. */
    --font-sans: "Inter", "Pretendard Variable", Pretendard, -apple-system,
                 BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
                 "Malgun Gothic", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
                 Consolas, "Pretendard Variable", monospace;

    --text-2xs: 11px;
    --text-xs:  12px;
    --text-sm:  13px;
    --text-md:  14px;
    --text-base:15px;
    --text-lg:  16px;
    --text-xl:  20px;
    --text-2xl: 24px;
    --text-3xl: 32px;
    --text-4xl: 48px;
    --text-5xl: 64px;

    --weight-regular: 400;
    --weight-medium:  510;
    --weight-semi:    590;

    /* --- space: 4px base, 8/12/24/96 is the rhythm ----------------------- */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  20px;
    --space-6:  24px;
    --space-8:  32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-24: 96px;

    /* --- geometry: three radii are the whole vocabulary ----------------- */
    --radius-badge:  4px;
    --radius-button: 6px;
    --radius-card:   12px;
    --radius-pill:   9999px;

    --edge:        inset 0 0 0 1px var(--color-line);   /* card hairline    */
    --shadow-overlay: 0 4px 32px rgba(8, 9, 10, 0.6);
    --shadow-accent:  0 5px 2px rgba(0, 0, 0, 0.01), 0 3px 2px rgba(0, 0, 0, 0.04),
                      0 1px 1px rgba(0, 0, 0, 0.07), 0 0 1px rgba(0, 0, 0, 0.08);

    --measure: 72ch;
    --content-max: 1200px;
    --rail: 280px;
}

/* --------------------------------------------------------------------------
   2. RESET / BASE
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--color-void); }

/* Component rules below set `display` on elements that may also carry the
   `hidden` attribute; keep the attribute authoritative. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--color-void);
    color: var(--color-mist);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--weight-regular);
    line-height: 1.6;
    letter-spacing: -0.011em;
    font-feature-settings: "cv01" 1, "ss03" 1, "zero" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: var(--weight-medium);
    color: var(--color-paper);
    letter-spacing: -0.012em;
    line-height: 1.2;
}

p { margin: 0 0 var(--space-3); }

a {
    color: var(--color-mist);
    text-decoration: none;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}
a:hover { color: var(--color-paper); text-decoration: underline; }

code, pre, kbd {
    font-family: var(--font-mono);
    font-size: 0.9em;
    letter-spacing: -0.013em;
}
pre {
    margin: var(--space-1) 0 0;
    padding: var(--space-2) var(--space-3);
    background: var(--color-void);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-button);
    white-space: pre-wrap;
    word-break: break-word;
    font-size: var(--text-xs);
    line-height: 1.5;
    color: var(--color-mist);
}
code {
    background: var(--color-fill);
    padding: 1px 5px;
    border-radius: var(--radius-badge);
}
kbd {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: var(--radius-badge);
    background: var(--color-fill);
    box-shadow: var(--edge);
    color: var(--color-fog);
    font-size: var(--text-2xs);
    line-height: 18px;
    text-align: center;
}

::selection { background: rgba(99, 102, 241, 0.45); color: var(--color-paper); }

/* Visible keyboard affordance on every interactive element. */
:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHIC PRIMITIVES
   -------------------------------------------------------------------------- */

/* Small muted label: group headings in rails, field captions. */
.label {
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: var(--color-fog);
}

/* Section head. The numbered variant keeps its data-index for the markup
   contract but no longer prints it — Linear groups are unnumbered. */
.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    letter-spacing: 0;
    color: var(--color-fog);
}

.display {
    font-size: var(--text-4xl);
    font-weight: var(--weight-medium);
    line-height: 1.0;
    letter-spacing: -0.022em;
    color: var(--color-paper);
    max-width: 20ch;
}

.lede {
    font-size: var(--text-lg);
    line-height: 1.5;
    color: var(--color-fog);
    max-width: 56ch;
}

.measure { max-width: var(--measure); }

.rule       { height: 1px; background: var(--color-line); border: 0; margin: 0; }
.rule-hard  { height: 1px; background: var(--color-line-strong); border: 0; margin: 0; }

/* --------------------------------------------------------------------------
   4. UTILITIES
   Small, closed set — replaces the eight Bootstrap helpers the markup used.
   -------------------------------------------------------------------------- */

.d-flex            { display: flex; }
.flex-column       { flex-direction: column; }
.flex-wrap         { flex-wrap: wrap; }
.align-items-center{ align-items: center; }
.gap-1             { gap: var(--space-1); }
.gap-3             { gap: var(--space-3); }
.mb-3              { margin-bottom: var(--space-3); }
.mb-4              { margin-bottom: var(--space-6); }
.stack > * + *     { margin-top: var(--space-2); }

/* --------------------------------------------------------------------------
   5. BUTTONS
   Primary = acid lime, one per view. Everything else is neutral: ghost
   outline or plain text. Hover changes fill/edge, never lifts or glows.
   -------------------------------------------------------------------------- */

.btn,
.btn-primary,
.btn-danger,
.btn-quiet {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-button);
    background: transparent;
    color: var(--color-mist);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-regular);
    letter-spacing: -0.01em;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover, .btn-quiet:hover {
    background: var(--color-hover);
    border-color: var(--color-line-strong);
    color: var(--color-paper);
}

/* Primary — the only chromatic fill in the interface. */
.btn-primary {
    padding: 10px 16px;
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: var(--color-on-accent);
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    letter-spacing: -0.011em;
    box-shadow: var(--shadow-accent);
}
.btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }

/* Danger — ghost with a red label: destruction is quiet and deliberate. */
.btn-danger { color: var(--color-red); }
.btn-danger:hover {
    background: rgba(235, 87, 87, 0.08);
    border-color: rgba(235, 87, 87, 0.45);
    color: var(--sev-critical);
}

/* Quiet — the default neutral control. */
.btn-quiet { background: rgba(255, 255, 255, 0.02); }

.btn-block { width: 100%; }

/* Text button: nav-style, no chrome. */
.btn-text {
    border: 0;
    background: none;
    padding: var(--space-1) var(--space-2);
    color: var(--color-mist);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    cursor: pointer;
    border-radius: var(--radius-button);
}
.btn-text:hover { color: var(--color-paper); text-decoration: underline; text-underline-offset: 3px; }

/* Mini — dense modal/table actions. Below the 44px rule by design: these
   only appear inside pointer-driven admin modals (grown in section 14). */
.btn-mini {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: 28px;
    padding: 4px 10px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-button);
    background: rgba(255, 255, 255, 0.02);
    color: var(--color-mist);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease;
}
.btn-mini:hover { border-color: var(--color-line-strong); color: var(--color-paper); background: var(--color-hover); }
.btn-mini.approve { color: var(--color-green-text); }
.btn-mini.approve:hover { border-color: rgba(39, 166, 68, 0.5); background: rgba(39, 166, 68, 0.08); }
.btn-mini.skip    { color: var(--color-fog); }
.btn-mini.rearm   { color: var(--state-warn); }
.btn-mini.delete  { color: var(--color-red); }
.btn-mini.delete:hover { border-color: rgba(235, 87, 87, 0.45); background: rgba(235, 87, 87, 0.08); }
.btn-mini[disabled] {
    color: var(--color-ash);
    border-style: dashed;
    cursor: not-allowed;
}
.btn-mini[disabled]:hover { border-color: var(--color-line); background: none; color: var(--color-ash); }

/* Filters — pill row. The active pill is a neutral fill; lime stays reserved
   for the primary action (a 6px lime dot marks the active item instead). */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-3) 0;
}
.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 0;
    border-radius: var(--radius-pill);
    background: none;
    color: var(--color-fog);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    line-height: 1.6;
    cursor: pointer;
    transition: color 120ms ease, background-color 120ms ease;
}
.filter-btn:hover { color: var(--color-mist); background: var(--color-hover); }
.filter-btn.active {
    color: var(--color-paper);
    background: var(--color-fill-strong);
    font-weight: var(--weight-medium);
}
.filter-btn.active::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent);
}

/* Pagination — compact squares, tabular figures. */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-1);
    flex-wrap: wrap;
}
.btn-page {
    min-width: 32px;
    min-height: 32px;
    padding: 0 var(--space-2);
    border: 1px solid transparent;
    border-radius: var(--radius-button);
    background: none;
    color: var(--color-fog);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}
.btn-page:hover { color: var(--color-paper); background: var(--color-hover); }
.btn-page.active {
    color: var(--color-paper);
    background: var(--color-fill-strong);
    border-color: var(--color-line);
    font-weight: var(--weight-medium);
}
.page-gap {
    color: var(--color-ash);
    padding: 0 var(--space-1);
}

/* --------------------------------------------------------------------------
   6. FORMS
   Near-invisible fill, 8% white edge, edge brightens on focus.
   -------------------------------------------------------------------------- */

.form-control {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-line-input);
    border-radius: var(--radius-button);
    color: var(--color-mist);
    font-family: var(--font-sans);
    font-size: var(--text-md);
    line-height: 1.5;
    resize: vertical;
    transition: border-color 120ms ease, background-color 120ms ease;
}
textarea.form-control {
    min-height: 96px;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.6;
}
.form-control::placeholder { color: var(--color-ash); }
.form-control:hover { border-color: rgba(255, 255, 255, 0.14); }
.form-control:focus {
    outline: none;
    border-color: var(--color-mist);
    background: rgba(255, 255, 255, 0.03);
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-mist);
}

.field + .field { margin-top: var(--space-4); }

.field-note {
    margin: 6px 0 0;
    font-size: var(--text-xs);
    color: var(--color-fog);
}

/* Search — an input box with a leading icon. */
.search-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-3);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-line-input);
    border-radius: var(--radius-button);
    transition: border-color 120ms ease;
}
.search-bar > i { color: var(--color-fog); font-size: var(--text-sm); }
.search-bar input {
    flex: 1;
    min-width: 0;
    min-height: 38px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-paper);
    font-family: var(--font-sans);
    font-size: var(--text-md);
    letter-spacing: -0.01em;
}
.search-bar input::placeholder { color: var(--color-ash); }
.search-bar input:focus { outline: none; }
.search-bar:hover { border-color: rgba(255, 255, 255, 0.14); }
.search-bar:focus-within { border-color: var(--color-mist); }
.search-clear {
    min-width: 28px;
    min-height: 28px;
    border: 0;
    border-radius: var(--radius-badge);
    background: none;
    color: var(--color-fog);
    font-size: var(--text-lg);
    line-height: 1;
    cursor: pointer;
}
.search-clear:hover { color: var(--color-paper); background: var(--color-hover); }

/* --------------------------------------------------------------------------
   7. BADGES / TAGS / CHIPS
   Mono codes on a soft wash — read like issue IDs, not like buttons.
   -------------------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-badge);
    background: var(--sev-low-wash);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1;
    color: var(--sev-low);
    white-space: nowrap;
}

/* Severity colour is derived from the card's severity class so the badge
   always agrees with the record, whichever template rendered it. */
.badge-critical,
.threat-card.critical .badge:first-child { color: var(--sev-critical); background: var(--sev-critical-wash); }
.badge-high,
.threat-card.high     .badge:first-child { color: var(--sev-high);     background: var(--sev-high-wash); }
.badge-medium,
.threat-card.medium   .badge:first-child { color: var(--sev-medium);   background: var(--sev-medium-wash); }
.badge-low,
.threat-card.low      .badge:first-child { color: var(--sev-low);      background: var(--sev-low-wash); }

/* Category is a filing code: always neutral. */
.badge-category {
    color: var(--color-fog);
    background: transparent;
    box-shadow: var(--edge);
}

.keyword-tag {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    background: rgba(99, 102, 241, 0.14);
    color: var(--color-iris-text);
    font-size: var(--text-xs);
}

.reason-tag,
.status-tag {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-badge);
    background: var(--color-fill);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--color-fog);
    white-space: nowrap;
}
.status-tag.ok            { color: var(--state-ok);   background: rgba(39, 166, 68, 0.12); }
.status-tag.stale,
.status-tag.stale_14d     { color: var(--state-warn); background: var(--sev-high-wash); }
.status-tag.dead          { color: var(--state-dead); background: var(--sev-critical-wash); }
.status-tag.never,
.status-tag.never_polled  { color: var(--state-idle); background: transparent; box-shadow: var(--edge); }

.reason-tag { margin-right: var(--space-1); }
.reason-tag.username_invalid { color: var(--state-dead); background: var(--sev-critical-wash); }
.reason-tag.channel_private  { color: var(--state-warn); background: var(--sev-high-wash); }
.reason-tag.stale_14d        { color: var(--color-fog); background: transparent; box-shadow: var(--edge); }

/* Health chips: a pill readout with a state dot. */
.health-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    background: var(--color-fill);
    font-size: var(--text-xs);
    color: var(--color-fog);
}
.health-chip::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--state-idle);
}
.health-chip strong {
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
    color: var(--color-paper);
}
.health-chip.ok::before    { background: var(--state-ok); }
.health-chip.stale::before { background: var(--state-warn); }
.health-chip.dead::before  { background: var(--state-dead); }
.health-chip.never::before { background: transparent; box-shadow: inset 0 0 0 1px var(--state-idle); }

/* Count badge on a rail button. */
.review-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    background: #5558e3;   /* iris, one step darker: white label clears 4.5:1 */
    color: var(--color-paper);
    border-radius: var(--radius-pill);
    font-size: var(--text-2xs);
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   8. FIGURE TABLE (stats)
   Numbers in a hairline grid inside a card — no four identical tiles.
   -------------------------------------------------------------------------- */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--color-line);
    border-radius: var(--radius-card);
    box-shadow: var(--edge);
    overflow: hidden;
}
.stat-card {
    padding: var(--space-3) var(--space-4);
    background: var(--color-carbon);
}
.stat-value {
    font-size: var(--text-xl);
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.012em;
    line-height: 1.2;
    color: var(--color-paper);
}
.stat-label {
    margin-top: 2px;
    font-size: var(--text-xs);
    color: var(--color-fog);
}

/* --------------------------------------------------------------------------
   9. THREAT RECORDS
   Rows inside one card, hairline separated. Severity rides on the badge;
   critical/high also get a 2px inset rule at the row's left edge so they
   can be spotted while scrolling.
   -------------------------------------------------------------------------- */

.threat-card {
    position: relative;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--color-line);
    transition: background-color 120ms ease;
}
.threat-card:last-child { border-bottom: 0; }

/* Result count for a search / category filter, above the feed. The "Total
   Records" tile always shows the all-time total (loadStats). */
.records-count {
    margin: 0 0 var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-fog);
    letter-spacing: 0.02em;
}
/* While a search / page load is in flight: spinner before the line, feed dimmed. */
.records-count.is-loading { color: var(--color-mist); }
.records-count.is-loading::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 8px;
    vertical-align: -1px;
    border: 1.5px solid var(--color-line-strong);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#threatsContainer.is-loading {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 120ms ease;
}
.threat-card:hover { background: var(--color-hover); }
.threat-card.critical { box-shadow: inset 2px 0 0 var(--color-red); }
.threat-card.high     { box-shadow: inset 2px 0 0 #f2994a; }

.threat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}
.threat-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.threat-time {
    flex: none;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    color: var(--color-fog);
    white-space: nowrap;
}
.threat-time i { margin-right: 2px; }
.threat-content {
    max-width: var(--measure);
    color: var(--color-mist);
    font-size: var(--text-base);
    line-height: 1.6;
    letter-spacing: -0.011em;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    /* Raw Telegram posts routinely run 700–2600 characters. Left unbounded, a
       single page of 20 records is ~15,000px tall and stops being an index.
       The record is CLIPPED, never given its own scrollbar: an inner scroller
       swallows the mouse wheel whenever the cursor is over a long record,
       which makes the feed feel stuck. Full text is reached with the explicit
       .threat-expand control instead.
       Cap is an exact multiple of the line box (1.6em x 10) so the clip
       lands between lines rather than slicing a glyph in half. */
    max-height: 16em;
    overflow: hidden;
}
.threat-card.is-expanded .threat-content { max-height: none; }

/* Only rendered for records that are actually clipped — the class is set by
   the feed script after measuring, so short records show no affordance. */
.threat-expand {
    display: none;
    border: 0;
    background: none;
    padding: 2px 0;
    color: var(--color-fog);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    cursor: pointer;
}
.threat-card.is-clipped .threat-expand { display: inline-block; }
.threat-expand:hover { color: var(--color-paper); }

/* "원문 보기": the pre-translation text, fetched only when asked for. The
   button is always shown when an original exists (unlike .threat-expand,
   which only appears on clipped records). */
.threat-orig-btn {
    border: 0;
    background: none;
    padding: 2px 0;
    color: var(--color-fog);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    cursor: pointer;
}
.threat-orig-btn:hover { color: var(--color-paper); }

/* Attached file (name, size, type). Links to the Telegram message; the file
   itself is never downloaded to the server. A file-only post has an empty
   body, which is hidden so the file line reads as the record. */
.threat-content:empty { display: none; }
.threat-file {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    max-width: var(--measure);
    margin-top: var(--space-3);
    padding: 6px 12px;
    border-radius: var(--radius-button);
    background: var(--color-fill);
    box-shadow: var(--edge);
    color: var(--color-mist);
    font-size: var(--text-sm);
    transition: background-color 120ms ease;
}
.threat-file:hover { background: var(--color-fill-strong); color: var(--color-paper); }
.threat-file i { color: var(--color-fog); }
.threat-file-name {
    font-family: var(--font-mono);
    word-break: break-all;
}
.threat-file-meta {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-fog);
}
.threat-orig-btn:disabled { cursor: progress; }
.threat-original {
    max-width: var(--measure);
    margin-top: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-left: 2px solid var(--color-line-strong);
    background: var(--color-fill);
    border-radius: 0 var(--radius-button) var(--radius-button) 0;
}
.threat-original-label {
    margin-bottom: 6px;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-fog);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.threat-original-text {
    color: var(--color-mist);
    font-size: var(--text-sm);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* A clipped record gets a soft bottom edge so the cut reads as intentional. */
.threat-card.is-clipped:not(.is-expanded) .threat-content {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.6em), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 1.6em), transparent);
}
.threat-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--space-3);
    max-width: var(--measure);
}

/* Which alert keyword(s) a keyword_alert record matched, directly under the
   badges. Matching runs on the original (pre-translation) text, so the word
   may not appear in the record body -- hence a line of its own. */
.threat-match {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 var(--space-3);
}
/* Matched keywords are red, both as chips and where they occur in the body,
   so the chip and the word it caught read as one thing. */
.keyword-tag.keyword-hit {
    background: var(--sev-critical-wash);
    color: var(--sev-critical);
}
.keyword-mark {
    background: var(--sev-critical-wash);
    color: var(--sev-critical);
    font-weight: var(--weight-semi);
    border-radius: 2px;
    /* no padding: a match inside a word ("Leak"ed) must not split it */
}
.threat-match-label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-fog);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-right: 2px;
}
.threat-footer {
    margin-top: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-4);
}
.threat-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-sm);
    color: var(--color-mist);
    transition: color 120ms ease;
}
.threat-link i { font-size: var(--text-xs); color: var(--color-fog); }
.threat-link:hover { color: var(--color-paper); }

.empty-state {
    padding: var(--space-16) var(--space-6);
    font-size: var(--text-md);
    color: var(--color-fog);
    text-align: center;
}
.empty-state::before {
    content: "No records";
    display: block;
    margin-bottom: var(--space-1);
    font-size: var(--text-lg);
    font-weight: var(--weight-medium);
    color: var(--color-mist);
}

/* --------------------------------------------------------------------------
   10. OVERLAYS
   Flat dark scrim (no blur), carbon panel with a hairline edge.
   -------------------------------------------------------------------------- */

.review-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.64);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-12) var(--space-4);
    overflow-y: auto;
}
.review-modal {
    width: 100%;
    max-width: 920px;
    background: var(--color-carbon);
    border-radius: var(--radius-card);
    box-shadow: var(--edge), var(--shadow-overlay);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--space-24));
    overflow: hidden;
}
.review-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--color-line);
}
.review-modal-header h3 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    color: var(--color-paper);
}
.review-modal-header h3 i { color: var(--color-fog); }
.review-modal-body {
    padding: 0 var(--space-5);
    overflow-y: auto;
    flex: 1;
}
.review-modal-footer {
    padding: var(--space-2) var(--space-5);
    border-top: 1px solid var(--color-line);
}
.modal-note,
.modal-empty {
    font-size: var(--text-xs);
    color: var(--color-fog);
}
.modal-empty { padding: var(--space-12) 0; text-align: center; }

/* --------------------------------------------------------------------------
   11. ADMIN RECORD ROWS (candidate queue / channel health)
   Table density without a table: hairline rows, tabular figures, mono meta.
   -------------------------------------------------------------------------- */

.meta {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    line-height: 1.6;
    color: var(--color-fog);
    word-break: break-word;
}
.meta .kind, .kind { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--color-fog); }
.fig-a { color: var(--color-green-text); }
.fig-b { color: var(--color-mist); }
.fig-c { color: var(--color-fog); }

.actions {
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
}

.review-item {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-line);
}
.review-item strong,
.review-item .name {
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    color: var(--color-paper);
}
.review-item .actions { margin-top: var(--space-3); }

.health-row {
    display: grid;
    /* Timestamps are `YYYY-MM-DD HH:MM UTC (Nd 전)` — 132px keeps each on
       two lines instead of three. */
    grid-template-columns: minmax(0, 1fr) 132px 132px 84px;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-2);
    margin: 0 calc(var(--space-2) * -1);
    border-bottom: 1px solid var(--color-line);
    border-radius: var(--radius-button);
}
.health-row:hover { background: var(--color-hover); }
.health-row .name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-paper);
    word-break: break-all;
}
.channel-detail {
    margin: var(--space-2) 0 var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-button);
    background: rgba(255, 255, 255, 0.02);
    box-shadow: var(--edge);
}

/* Raw channel text can be arbitrarily long; clamp it so one noisy record
   cannot push the rest of the queue off screen. */
.review-item pre    { max-height: 96px; overflow: auto; }
.channel-detail pre { max-height: 132px; overflow: auto; }

/* --------------------------------------------------------------------------
   12. STATUS STRIP
   -------------------------------------------------------------------------- */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 26px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    background: var(--color-fill);
    font-size: var(--text-xs);
    color: var(--color-mist);
    white-space: nowrap;
}
.status-dot {
    width: 6px;
    height: 6px;
    background: var(--color-green);
    border-radius: 50%;
    animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Service lights next to System Active (Judgment / Trans). Green while the
   service works, yellow when it does not (the reason is in the title). Grey
   and still until the first /api/system/health answer. */
.status-badge[data-state="unknown"] .status-dot { background: var(--state-idle); animation: none; }
.status-badge[data-state="warn"] .status-dot { background: var(--state-warn); }
.status-badge[data-state="warn"] { color: var(--state-warn); }
.status-group {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.mode-tag {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    background: var(--color-fill);
    font-size: var(--text-xs);
    color: var(--color-mist);
}

/* --------------------------------------------------------------------------
   13. SHARED CHROME
   -------------------------------------------------------------------------- */

.logo {
    display: flex;
    white-space: nowrap;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-base);
    font-weight: var(--weight-semi);
    letter-spacing: -0.012em;
    color: var(--color-paper);
}
.logo i { font-size: var(--text-md); color: var(--color-paper); }
.logo .logo-mark {
    padding: 1px 6px;
    border-radius: var(--radius-badge);
    background: var(--color-fill);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 400;
    letter-spacing: 0;
    color: var(--color-fog);
}

.page-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-medium);
    color: var(--color-paper);
    letter-spacing: -0.012em;
}

/* --------------------------------------------------------------------------
   14. TOUCH
   Compact controls are sized for a mouse. On a touch device — or at phone
   width, where the layout is the phone layout regardless of what the pointer
   media query reports — they grow to the 44px minimum without changing type.
   -------------------------------------------------------------------------- */

@media (pointer: coarse), (max-width: 720px) {
    .filter-btn   { min-height: 44px; padding: 10px 14px; }
    .btn-page     { min-width: 44px; min-height: 44px; }
    .search-clear { min-width: 44px; min-height: 44px; }
    .search-bar input { min-height: 44px; }
    .btn-text     { min-height: 44px; padding: 12px var(--space-3); }
    .btn, .btn-primary, .btn-danger, .btn-quiet { min-height: 44px; }
    .threat-link  { min-height: 44px; }
    .threat-card.is-clipped .threat-expand { min-height: 44px; }
    .threat-orig-btn { min-height: 44px; }
    .threat-file { min-height: 44px; }
    .btn-mini     { min-height: 40px; padding: 8px var(--space-3); }
}

/* --------------------------------------------------------------------------
   15. MOTION
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
