/* Subscriber Watch — operator console.
   Design thesis: a network-operations control room. Deep slate surfaces, hairline
   structure, IBM Plex Mono for every piece of telemetry (IPs and counts align and
   scan fast under pressure), Space Grotesk for chrome. One bold element: the
   shared-fate public-IP strip — the thesis that one household burns the address
   everyone behind it shares. Everything else stays quiet. */

:root {
  --bg: #0E1418;
  --surface: #141B21;
  --surface-2: #1A232B;
  --surface-3: #212C35;
  --line: #26313B;
  --line-soft: #1E272F;
  --ink: #E7EDF3;
  --ink-2: #93A2B2;
  --ink-3: #5F6E7D;
  --accent: #2CC2B0;
  --accent-dim: #1c7d72;
  --accent-ink: #06110F;
  /* status ramp: hot -> neutral, so criticals shout and medium recedes */
  --crit: #FF5A6A;   --crit-bg: #2a1418;
  --high: #FF9838;   --high-bg: #2a1f10;
  --med:  #8896A6;   --med-bg:  #1c242c;
  /* categorical (validated) for multi-series where used */
  --c1: #2CC2B0; --c2: #5B8FF9; --c3: #F0953A; --c4: #E06BB0;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Space Grotesk", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --r: 8px; --r-sm: 5px;
  --shadow: 0 12px 40px -12px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* faint scanline/gradient atmosphere, kept subtle */
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(44,194,176,.06), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(91,143,249,.05), transparent 55%);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--sans); cursor: pointer; }
::selection { background: rgba(44,194,176,.3); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 58px;
  background: rgba(14,20,24,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 6px;
  background:
    linear-gradient(135deg, var(--accent), #1a6f66);
  position: relative; flex: none;
  box-shadow: 0 0 0 1px rgba(44,194,176,.4), 0 0 18px -4px var(--accent);
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px;
  border: 2px solid var(--accent-ink); border-radius: 2px;
  opacity: .5;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--sans); font-weight: 600; letter-spacing: .2px; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--ink-3); letter-spacing: .3px; }

.tabs { display: flex; gap: 4px; }
.tabs a {
  font-family: var(--sans); font-weight: 500; font-size: 13px;
  color: var(--ink-2); padding: 7px 14px; border-radius: 999px;
  border: 1px solid transparent; transition: .12s;
}
.tabs a:hover { color: var(--ink); background: var(--surface-2); }
.tabs a.active {
  color: var(--accent); background: rgba(44,194,176,.10);
  border-color: rgba(44,194,176,.3);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.ghost-btn {
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 7px 12px; font-size: 12.5px; font-weight: 500; transition: .12s;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--accent-dim); }

.live { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink-2); font-family: var(--mono); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); box-shadow: 0 0 0 0 rgba(44,194,176,.5); }
.live.on .live-dot { background: var(--accent); animation: pulse 2.4s infinite; }
.live.off .live-dot { background: var(--crit); }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(44,194,176,.45)} 70%{box-shadow:0 0 0 7px rgba(44,194,176,0)} 100%{box-shadow:0 0 0 0 rgba(44,194,176,0)} }

/* ---------- layout ---------- */
.view { padding: 20px; max-width: 1500px; margin: 0 auto; }
.eyebrow {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--ink-3);
}

/* ---------- shared-fate strip (signature) ---------- */
.fate {
  display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: stretch;
  margin-bottom: 18px;
}
.fate-summary {
  display: flex; gap: 10px; align-items: stretch;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 16px; min-width: 92px; display: flex; flex-direction: column; justify-content: center;
}
.kpi .n { font-family: var(--mono); font-size: 26px; font-weight: 600; line-height: 1; letter-spacing: -1px; }
.kpi .l { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 1px; margin-top: 6px; }
.kpi.crit .n { color: var(--crit); } .kpi.high .n { color: var(--high); }

.fate-ips {
  display: flex; gap: 12px; overflow-x: auto; padding: 2px;
}
.ipcard {
  flex: 1 1 0; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; position: relative; overflow: hidden;
}
.ipcard::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent);
}
.ipcard.burning::before { background: var(--crit); }
.ipcard.burning { box-shadow: inset 0 0 40px -20px var(--crit); border-color: rgba(255,90,106,.35); }
.ipcard .ip { font-family: var(--mono); font-size: 16px; font-weight: 600; letter-spacing: .3px; }
.ipcard .site { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.ipcard .rep { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; }
.rep-badge { font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 4px; letter-spacing: .5px; text-transform: uppercase; }
.rep-ok { background: rgba(44,194,176,.14); color: var(--accent); }
.rep-burn { background: var(--crit-bg); color: var(--crit); }
.ipcard .share { font-size: 11.5px; color: var(--ink-2); margin-top: 8px; }
.ipcard .share b { color: var(--ink); font-family: var(--mono); }

/* ---------- filters ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px;
}
.field { position: relative; }
select, input[type="search"], input[type="text"], textarea {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 11px; font-family: var(--body); font-size: 13px; outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(44,194,176,.12); }
input[type="search"] { min-width: 210px; font-family: var(--mono); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { background: transparent; border: none; color: var(--ink-2); padding: 8px 12px; font-size: 12.5px; }
.seg button.on { background: var(--surface-3); color: var(--ink); }
.spacer { flex: 1; }
.count-note { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }

/* ---------- board table ---------- */
.tablewrap { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
table.board { width: 100%; border-collapse: collapse; }
.board thead th {
  background: var(--surface-2);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--ink-3); font-weight: 500; text-align: right;
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none;
}
.board thead th.l { text-align: left; }
.board thead th:hover { color: var(--ink); }
.board thead th .arrow { color: var(--accent); margin-left: 3px; }
.board tbody td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); text-align: right; white-space: nowrap; }
.board tbody tr { cursor: pointer; transition: background .1s; }
.board tbody tr:hover { background: var(--surface-2); }
.board tbody tr:last-child td { border-bottom: none; }
.board td.hh { text-align: left; }
.board tr .stripe { padding: 0; width: 3px; }
.stripe span { display: block; width: 3px; height: 100%; min-height: 34px; background: transparent; }
tr.sev-critical .stripe span { background: var(--crit); }
tr.sev-high .stripe span { background: var(--high); }
tr.sev-medium .stripe span { background: var(--med); }
tr.acked { opacity: .62; }
tr.muted td.hh .ip { text-decoration: line-through; text-decoration-color: var(--ink-3); }

.ip-cell { display: flex; flex-direction: column; gap: 1px; }
.ip-cell .ip { font-family: var(--mono); font-size: 13.5px; font-weight: 500; letter-spacing: .2px; }
.ip-cell .meta { font-size: 10.5px; color: var(--ink-3); font-family: var(--mono); display: flex; gap: 6px; align-items: center; }
.newdot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; }

.score { font-family: var(--mono); font-weight: 600; font-size: 14px; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 4px; letter-spacing: .3px; }
.pill.critical { background: var(--crit-bg); color: var(--crit); }
.pill.high { background: var(--high-bg); color: var(--high); }
.pill.medium { background: var(--med-bg); color: var(--med); border: 1px solid var(--line); }
.pills { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }

/* discriminator cell hints (§8) — text-color only, quiet */
td.num b { font-weight: 600; }
.hint-p2p { color: var(--c1); }        /* low bytes/flow, fan-out = peer discovery */
.hint-scan { color: var(--crit); }      /* high SYN ratio = unanswered probes */
.hint-quiet { color: var(--ink-3); }
.sat { color: var(--high); font-weight: 600; }
.smtp-hot { color: var(--crit); font-weight: 700; }

.spark { display: inline-block; vertical-align: middle; }

.badge-ack { font-family: var(--mono); font-size: 9.5px; color: var(--ink-3); border: 1px solid var(--line); padding: 1px 5px; border-radius: 3px; }
.badge-disp { font-family: var(--mono); font-size: 9.5px; padding: 1px 5px; border-radius: 3px; }
.disp-investigating { background: var(--high-bg); color: var(--high); }
.disp-contacted { background: rgba(91,143,249,.14); color: var(--c2); }
.disp-resolved { background: rgba(44,194,176,.14); color: var(--accent); }
.disp-false_positive { background: var(--med-bg); color: var(--med); }

.empty { padding: 60px; text-align: center; color: var(--ink-3); font-family: var(--mono); }

/* ---------- household detail ---------- */
.detail-head { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.back { font-family: var(--mono); font-size: 12px; color: var(--ink-2); margin-bottom: 12px; display: inline-flex; gap: 6px; align-items: center; }
.back:hover { color: var(--accent); }
.detail-title { display: flex; flex-direction: column; gap: 6px; }
.detail-title .ip { font-family: var(--mono); font-size: 30px; font-weight: 600; letter-spacing: -.5px; }
.detail-title .sub { color: var(--ink-2); font-size: 12.5px; font-family: var(--mono); display: flex; gap: 14px; flex-wrap: wrap; }
.nat-strip { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.nat-chip { font-family: var(--mono); font-size: 12px; padding: 4px 9px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); display: flex; gap: 7px; align-items: center; }
.nat-chip.primary { border-color: var(--accent-dim); }
.nat-chip .tag { font-size: 9px; color: var(--ink-3); letter-spacing: .5px; }
.nat-chip.down { color: var(--crit); border-color: rgba(255,90,106,.4); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 18px; }
.panel h3 { font-family: var(--sans); font-weight: 600; font-size: 13px; margin: 0 0 14px; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.panel h3 .eyebrow { margin-left: auto; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.tile .n { font-family: var(--mono); font-size: 24px; font-weight: 600; letter-spacing: -.5px; line-height: 1; }
.tile .l { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .8px; margin-top: 8px; }
.tile .read { font-size: 11px; color: var(--ink-2); margin-top: 8px; line-height: 1.3; min-height: 28px; }
.tile.flag-good .n { color: var(--accent); }
.tile.flag-bad .n { color: var(--crit); }
.tile.flag-warn .n { color: var(--high); }

.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chartcard { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 12px 6px; }
.chartcard .ttl { font-family: var(--mono); font-size: 11px; color: var(--ink-2); display: flex; justify-content: space-between; margin-bottom: 6px; }
.chartcard .ttl .cur { color: var(--ink); font-weight: 600; }

.evlist { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 12px; }
.evlist li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.evlist li:last-child { border: none; }
.evlist .k { color: var(--ink-2); }
.evlist .v { color: var(--ink); text-align: right; word-break: break-all; }

.ahist { width: 100%; border-collapse: collapse; font-size: 12px; }
.ahist th { text-align: left; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.ahist td { padding: 8px; border-bottom: 1px solid var(--line-soft); font-family: var(--mono); }
.ahist tr:last-child td { border: none; }
.dot-firing, .dot-cleared { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.dot-firing { background: var(--crit); } .dot-cleared { background: var(--ink-3); }

/* workflow */
.wf-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: var(--r-sm); padding: 8px 13px; font-size: 12.5px; font-weight: 500; transition: .12s; }
.btn:hover { border-color: var(--accent-dim); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger:hover { border-color: var(--crit); color: var(--crit); }
.btn.on { border-color: var(--accent); color: var(--accent); }
textarea { width: 100%; min-height: 70px; resize: vertical; font-family: var(--body); }

/* evidence box */
.evidence { font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; color: var(--ink-2); max-height: 240px; overflow: auto; }

/* ---------- sites ---------- */
.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 18px; }
.sitecard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.sitecard.silent { border-color: var(--crit); box-shadow: 0 0 0 1px var(--crit), inset 0 0 60px -30px var(--crit); }
.sitecard-head { padding: 14px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.status-lamp { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.lamp-ok { background: var(--accent); box-shadow: 0 0 10px -1px var(--accent); }
.lamp-bad { background: var(--crit); box-shadow: 0 0 12px -1px var(--crit); animation: pulse-bad 1.4s infinite; }
@keyframes pulse-bad { 50% { opacity: .35; } }
.sitecard-head .title { font-family: var(--sans); font-weight: 600; font-size: 14px; }
.sitecard-head .sub { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.silent-banner { background: var(--crit-bg); color: var(--crit); font-family: var(--mono); font-size: 12px; padding: 8px 16px; border-bottom: 1px solid rgba(255,90,106,.3); display: flex; gap: 8px; align-items: center; }
.site-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line-soft); }
.site-metrics .m { background: var(--surface); padding: 12px 14px; }
.site-metrics .m .n { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.site-metrics .m .l { font-size: 9.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .6px; margin-top: 4px; }
.exp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.exp-table th { text-align: left; font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); padding: 8px 14px; border-bottom: 1px solid var(--line); }
.exp-table td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); font-family: var(--mono); }
.exp-table tr:last-child td { border: none; }
.exp-down { color: var(--crit); }
.exp-badge { font-size: 9px; padding: 1px 5px; border-radius: 3px; letter-spacing: .4px; }
.exp-badge.up { background: rgba(44,194,176,.14); color: var(--accent); }
.exp-badge.down { background: var(--crit-bg); color: var(--crit); }
.exp-badge.pri { background: var(--surface-3); color: var(--ink-2); }

/* ---------- drawer / modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(6,10,13,.6); backdrop-filter: blur(2px); z-index: 50; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 92vw; background: var(--surface); border-left: 1px solid var(--line); z-index: 51; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slidein .2s cubic-bezier(.2,.7,.3,1); }
@keyframes slidein { from { transform: translateX(30px); opacity: .3; } }
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.drawer-head h2 { font-family: var(--sans); font-size: 15px; margin: 0; }
.drawer-head .x { margin-left: auto; background: none; border: none; color: var(--ink-3); font-size: 20px; }
.drawer-head .x:hover { color: var(--ink); }
.drawer-body { padding: 18px; overflow: auto; }
.th-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.th-row .tl { font-size: 13px; }
.th-row .tl small { display: block; color: var(--ink-3); font-family: var(--mono); font-size: 10.5px; margin-top: 2px; }
.th-row input { width: 100px; text-align: right; font-family: var(--mono); }
.rule-tag { font-family: var(--mono); font-size: 9.5px; color: var(--ink-3); }

/* ---------- toast ---------- */
.toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r-sm); padding: 12px 16px; min-width: 260px; box-shadow: var(--shadow); animation: slidein .2s; }
.toast.critical { border-left-color: var(--crit); }
.toast.high { border-left-color: var(--high); }
.toast .t { font-family: var(--sans); font-size: 13px; font-weight: 600; }
.toast .d { font-size: 12px; color: var(--ink-2); margin-top: 3px; font-family: var(--mono); }

/* chart svg bits */
.axis text { font-family: var(--mono); font-size: 9px; fill: var(--ink-3); }
.grid-line { stroke: var(--line-soft); stroke-width: 1; }
.crosshair { stroke: var(--ink-3); stroke-dasharray: 3 3; }
.chart-tt { position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 9px; font-family: var(--mono); font-size: 11px; z-index: 3; box-shadow: var(--shadow); white-space: nowrap; }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .fate { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
