:root {
  --bg: #f3f4f7; --panel: #fff; --text: #1b1d23; --muted: #6b7280; --line: #e3e6ec;
  --accent: #2f6fed; --accent-ink: #1f4fb8; --warn: #b45309; --err: #c62828; --err-soft: #fdecec;
  --calm: #15803d; --calm-soft: #e7f6ec; --watch: #a16207; --watch-soft: #fdf3d7; --alarm: #c62828; --alarm-soft: #fdecec;
  --tag: #eef0f4; --mono: ui-monospace, Menlo, Consolas, monospace; --r: 10px; --gap: 12px;
  /* график: цвета уровней проверены на различимость (в т. ч. при дальтонизме) для светлой и тёмной панели */
  --lv-harmful: #d03b3b; --lv-atypical: #eda100; --lv-typical: #2a78d6; --lv-unscored: #c3c2b7; --bar: #6250d6; --grid: #e9ebf0;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121419; --panel: #1a1d24; --text: #e8eaf0; --muted: #98a1b3; --line: #2a2f3a;
    --accent: #6b9cff; --accent-ink: #9dbcff; --warn: #f0b35a; --err: #f87171; --err-soft: #3a1c1c;
    --calm: #4ade80; --calm-soft: #15301f; --watch: #facc15; --watch-soft: #33290c; --alarm: #f87171; --alarm-soft: #3a1c1c;
    --tag: #262b36;
    --lv-harmful: #d03b3b; --lv-atypical: #c98500; --lv-typical: #3987e5; --lv-unscored: #5b6170; --bar: #9085e9; --grid: #262b36; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
#app { display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--accent-ink); }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.warn { color: var(--warn); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.err { color: var(--err); background: var(--err-soft); padding: 8px 10px; border-radius: 8px; font-size: 13px; margin: 0; }

.bar { display: flex; align-items: center; gap: var(--gap); padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { font-weight: 700; font-size: 16px; }
.btn { font: inherit; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.link { font: inherit; font-size: 13px; background: none; border: 0; color: var(--accent-ink); cursor: pointer; padding: 0; }

.login { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; }
.card { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px 28px; display: flex; flex-direction: column; gap: 12px; }
.card h1 { margin: 0; font-size: 22px; }
.key { font: inherit; font-family: var(--mono); padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }

.stage { flex: 1; display: flex; flex-direction: column; gap: var(--gap); padding: var(--gap) 16px 32px; max-width: 1400px; width: 100%; margin: 0 auto; }
.machine, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.machine { border-left: 5px solid var(--calm); }
.machine.threat-1 { border-left-color: var(--muted); }
.machine.threat-2 { border-left-color: var(--watch); }
.machine.threat-3 { border-left-color: var(--alarm); }
.machine-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.machine-head h2 { margin: 0; font-size: 18px; }
.threat { font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--calm-soft); color: var(--calm); }
.threat-1 .threat { background: var(--tag); color: var(--muted); }
.threat-2 .threat { background: var(--watch-soft); color: var(--watch); }
.threat-3 .threat { background: var(--alarm-soft); color: var(--alarm); }
.agent { font-size: 13px; color: var(--muted); }
.agent .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #22c55e; }
.agent.off { color: var(--warn); }
.agent.off .dot { background: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 24px; margin: 14px 0 8px; }
.stats div { min-width: 0; }
.stats dt { font-size: 12.5px; color: var(--muted); }
.stats dd { margin: 0; font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.machine-foot { margin: 0; }

.panel h3 { margin: 0 0 10px; font-size: 15px; display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.panel h3 .small { font-weight: 400; }
.scroll { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 4px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.req { min-width: 260px; max-width: 520px; }
.uri { overflow-wrap: anywhere; }
.level { font-size: 12.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; background: var(--watch-soft); color: var(--watch); }
.level.harmful { background: var(--alarm-soft); color: var(--alarm); }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; margin: 0 4px 3px 0; border-radius: 6px; background: var(--tag); color: var(--muted); white-space: nowrap; }
.tag.attack { background: var(--alarm-soft); color: var(--alarm); }
.foot { padding: 4px 2px; }
.tag.listed { background: var(--text); color: var(--panel); }
.tag.trusted { background: var(--calm-soft); color: var(--calm); }
h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.list-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.list-form select, .list-form input { font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); min-width: 0; }
.list-form input { flex: 1 1 220px; }
.list-form input.mono { font-family: var(--mono); font-size: 13px; }
.lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px 28px; margin: 12px 0 10px; }
.lists > div { min-width: 0; }

/* --- история (UC-02.1) --- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; font-weight: 400; padding: 4px 12px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--tag); color: var(--text); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 0 0 10px; padding: 0; font-size: 12.5px; color: var(--muted); }
.swatch, .tip-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
:is(.swatch, .tip-key, .seg-bar).harmful { background: var(--lv-harmful); }
:is(.swatch, .tip-key, .seg-bar).atypical { background: var(--lv-atypical); }
:is(.swatch, .tip-key, .seg-bar).typical { background: var(--lv-typical); }
:is(.swatch, .tip-key, .seg-bar).unscored { background: var(--lv-unscored); }
.chart { display: flex; gap: 8px; padding-top: 8px; }
.y-axis { position: relative; width: 34px; height: var(--plot); flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.y-axis span { position: absolute; right: 0; transform: translateY(50%); }
.plot { position: relative; flex: 1; min-width: 0; display: flex; align-items: flex-start; }
.gridlines i { position: absolute; left: 0; right: 0; height: 1px; background: var(--grid); }
.gridlines { position: absolute; left: 0; right: 0; top: 0; height: var(--plot); pointer-events: none; }
.col { position: relative; flex: 1 1 0; min-width: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; border-radius: 4px; }
.col:hover, .col:focus-visible { background: color-mix(in srgb, var(--text) 6%, transparent); outline: none; }
.col.on { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.stack { height: var(--plot); width: min(24px, calc(100% - 2px)); display: flex; flex-direction: column-reverse; gap: 2px; }
.seg-bar { display: block; width: 100%; flex: none; }
.seg-bar.cap { border-radius: 4px 4px 0 0; }
.x-tick { height: 20px; padding-top: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tip { display: none; position: absolute; bottom: calc(20px + var(--plot) * .35); left: 50%; transform: translateX(-50%); z-index: 3; min-width: 170px; padding: 8px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, .18); text-align: left; font-size: 12.5px; color: var(--muted); pointer-events: none; }
.col.left .tip { left: 0; transform: none; } .col.right .tip { left: auto; right: 0; transform: none; }
.col:hover .tip, .col:focus-visible .tip { display: block; }
.tip > b { display: block; margin-bottom: 4px; color: var(--text); }
.tip-row { display: block; white-space: nowrap; } .tip-row b { color: var(--text); }
.tip-key { height: 3px; vertical-align: middle; }
.table-view { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.table-view summary { cursor: pointer; width: max-content; }
.table-view .grid { margin-top: 6px; color: var(--text); font-variant-numeric: tabular-nums; }
.attacks-title { margin-top: 16px; }
.attacks-title .link { font-size: 11px; text-transform: none; letter-spacing: 0; margin-left: 6px; }
.attacks { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 2px; }
.attack-row { width: 100%; display: grid; grid-template-columns: minmax(150px, 260px) minmax(60px, 1fr) minmax(150px, max-content); align-items: center; gap: 12px; padding: 5px 8px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.attack-row:hover, .attack-row:focus-visible { background: color-mix(in srgb, var(--text) 6%, transparent); outline: none; }
.attack-row.on { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.attack-track { display: block; height: 10px; }
.attack-track i { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; }
.attack-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 640px) {
  .attack-row { grid-template-columns: 1fr max-content; }
  .attack-track { grid-column: 1 / -1; grid-row: 2; }
  .x-tick { font-size: 10px; }
}

/* --- копия в Log Anthill (UC-07.1) --- */
.mirror-where { margin: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.mirror-stats { margin: 10px 0 8px; }
.mirror-stats dd { font-size: 22px; }
.mirror-stats dd.small-dd { font-size: 15px; font-weight: 500; padding-top: 6px; }
.list-form input.short { flex: 0 1 140px; }

/* --- сигнатуры (UC-02.2) --- */
.sigs tbody tr { cursor: pointer; }
.sigs tbody tr:hover, .sigs tbody tr:focus-visible { background: color-mix(in srgb, var(--text) 5%, transparent); outline: none; }
.sigs tbody tr.on { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.sig-name { font-weight: 600; overflow-wrap: anywhere; }
