:root {
  --bg: #070d14; --bg-2: #0b1420; --panel: rgba(13, 25, 38, .82); --line: rgba(148, 188, 205, .16);
  --text: #e8f2f4; --muted: #8ea5b0; --accent: #38bdf8; --accent-2: #f0b35b;
  --sev-critical: #ef4444; --sev-high: #f97316; --sev-medium: #f59e0b; --sev-low: #10b981; --sev-info: #64748b;
  --radius: 16px; --field: rgba(148, 188, 205, .08); --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --c-ssh-probe: #a5b4fc; color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f0f4f8; --bg-2: #e2eaf0; --panel: rgba(255, 255, 255, .88); --line: rgba(15, 31, 38, .13);
  --text: #0f1f26; --muted: #536b75; --accent: #0284c7; --accent-2: #d97706; --field: rgba(15, 31, 38, .05);
  --shadow: 0 10px 30px rgba(15, 31, 38, .10); --c-ssh-probe: #6366f1; color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f0f4f8; --bg-2: #e2eaf0; --panel: rgba(255, 255, 255, .88); --line: rgba(15, 31, 38, .13);
    --text: #0f1f26; --muted: #536b75; --accent: #0284c7; --accent-2: #d97706; --field: rgba(15, 31, 38, .05);
    --shadow: 0 10px 30px rgba(15, 31, 38, .10); --c-ssh-probe: #6366f1; color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; min-height: 100%; background: var(--bg-2); }
body {
  margin: 0; min-height: 100vh; color: var(--text); font: 14px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1100px 500px at 15% 0, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%) no-repeat,
    linear-gradient(180deg, var(--bg), var(--bg-2));
  overflow-x: hidden;
}
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 16px; }
header.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 0; }
.brand img { width: 44px; height: 44px; border-radius: 12px; flex: none; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: .02em; }
.brand small { display: block; color: var(--muted); font-size: 12px; max-width: 46ch; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn, select, .seg button, input[type="text"], input[type="number"], input[type="password"] {
  background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; min-height: 36px;
}
.btn, .seg button { cursor: pointer; }
.btn:hover, .seg button:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #04121c; border-color: transparent; font-weight: 600; }
.seg { display: inline-flex; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.seg button { border: 0; border-radius: 0; background: transparent; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #04121c; font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sev-info); display: inline-block; flex: none; }
.dot.on { background: var(--sev-low); box-shadow: 0 0 8px var(--sev-low); }
.dot.off { background: var(--sev-critical); }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 14px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); backdrop-filter: blur(10px); min-width: 0;
}
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.kpi .v { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.hot .v { color: var(--sev-critical); }
.kpi.warn .v { color: var(--sev-high); }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mt { margin-top: 14px; }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: 230px; display: block; }
.chart-wrap .tip {
  position: absolute; pointer-events: none; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; z-index: 5; min-width: 130px; box-shadow: var(--shadow);
}
.tip[hidden] { display: none; }
.tip div { display: flex; justify-content: space-between; gap: 12px; }
.axis { fill: var(--muted); font-size: 10px; }
.gridline { stroke: var(--line); stroke-width: 1; }
.hover-col { fill: transparent; }
.hover-col:hover { fill: color-mix(in srgb, var(--text) 8%, transparent); }
.b-notfound { fill: var(--sev-info); } .b-scanner { fill: var(--sev-medium); } .b-bruteforce { fill: var(--sev-high); }
.b-exploit { fill: var(--sev-critical); } .b-ssh-fail { fill: var(--accent); } .b-ssh-probe { fill: var(--c-ssh-probe); }
.b-ban { fill: var(--accent-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.legend button { background: none; border: 0; padding: 2px 0; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text); font-size: 12px; }
.legend button[aria-pressed="false"] { opacity: .4; text-decoration: line-through; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.b-notfound { background: var(--sev-info); } .sw.b-scanner { background: var(--sev-medium); } .sw.b-bruteforce { background: var(--sev-high); }
.sw.b-exploit { background: var(--sev-critical); } .sw.b-ssh-fail { background: var(--accent); } .sw.b-ssh-probe { background: var(--c-ssh-probe); }
.sw.b-ban { background: var(--accent-2); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 6px 8px; white-space: nowrap; }
th button { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; }
td { padding: 8px; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
tr.row { cursor: pointer; }
tr.row:hover td, tr.row:focus-visible td { background: var(--field); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.lv-hostile { background: color-mix(in srgb, var(--sev-critical) 22%, transparent); color: var(--sev-critical); border-color: var(--sev-critical); }
.lv-suspicious { background: color-mix(in srgb, var(--sev-medium) 20%, transparent); color: var(--sev-medium); border-color: var(--sev-medium); }
.lv-low { background: color-mix(in srgb, var(--sev-low) 16%, transparent); color: var(--sev-low); border-color: var(--sev-low); }
.chip { display: inline-block; margin: 0 4px 2px 0; padding: 0 6px; border-radius: 6px; background: var(--field); font-size: 11px; white-space: nowrap; }
.banned { color: var(--accent-2); font-weight: 600; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 5px 0; border-top: 1px solid var(--line); }
.bar-row:first-of-type { border-top: 0; }
.bar-row .k { overflow-wrap: anywhere; }
.bar-row .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-row .bar { grid-column: 1 / -1; height: 3px; border-radius: 2px; background: var(--field); overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--accent); }
.empty { color: var(--muted); padding: 8px 0; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; }
.feed li { padding: 6px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 2px 8px; align-items: baseline; }
.feed li:first-child { border-top: 0; }
.feed .t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.feed .what { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.feed a, .linkish { color: var(--accent); cursor: pointer; background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.cat { display: inline-block; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 600; color: #04121c; }
.cat.b-notfound { background: var(--sev-info); color: #fff; } .cat.b-scanner { background: var(--sev-medium); } .cat.b-bruteforce { background: var(--sev-high); }
.cat.b-exploit { background: var(--sev-critical); color: #fff; } .cat.b-ssh-fail { background: var(--accent); } .cat.b-ssh-probe { background: var(--c-ssh-probe); }
.cat.b-ban { background: var(--accent-2); } .cat.b-ssh-ok { background: var(--sev-low); } .cat.b-ok { background: var(--sev-low); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar input[type="text"] { flex: 1 1 140px; min-width: 0; }
.toolbar input[type="number"] { width: 84px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.hosts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.host { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.host h3 { margin: 0 0 4px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.host .meta { color: var(--muted); font-size: 12px; }
.host dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin: 8px 0 0; font-size: 12.5px; }
.host dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.host dt { color: var(--muted); }
.st-following, .st-ok { color: var(--sev-low); } .st-waiting, .st-backfill { color: var(--sev-medium); } .st-error { color: var(--sev-critical); }
aside#detail {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--bg-2); border-left: 1px solid var(--line);
  box-shadow: var(--shadow); z-index: 20; padding: 18px 16px; overflow-y: auto; overflow-x: hidden;
}
aside#detail[hidden] { display: none; }
aside#detail h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; overflow-wrap: anywhere; }
aside#detail dl { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 10px; margin: 14px 0; }
aside#detail dt { color: var(--muted); }
aside#detail dd { margin: 0; overflow-wrap: anywhere; }
aside#detail ul { margin: 0; padding-left: 16px; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 15; }
.scrim[hidden] { display: none; }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 20px 0 6px; }
.err-banner { background: color-mix(in srgb, var(--sev-critical) 18%, transparent); border: 1px solid var(--sev-critical); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
.err-banner[hidden] { display: none; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .panel { width: min(400px, 100%); padding: 26px 22px; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 20px; }
.login h1 { margin: 10px 0 2px; }
.login p { color: var(--muted); margin: 0 0 16px; }
.login form { display: grid; gap: 10px; }
.login .msg { color: var(--sev-critical); min-height: 1.4em; }
.login .controls { justify-content: center; margin-top: 14px; }
@media (max-width: 960px) {
  .cols-main, .cols-3 { grid-template-columns: 1fr; }
  .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .wrap { padding: 12px; }
  .brand small { display: none; }
  .kpi .v { font-size: 24px; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-top: 1px solid var(--line); padding: 8px 0; }
  table.stack td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; text-align: left; flex: none; }
  table.stack td > * { min-width: 0; }
  .chart-wrap svg { height: 190px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
#ips td:first-child, #ips td:nth-child(2), #sources td:nth-child(-n+2), #sources td:nth-child(n+4) { white-space: nowrap; overflow-wrap: normal; }
@media (max-width: 720px) {
  #ips td, #sources td { white-space: normal !important; max-width: none !important; }
  #ips td:first-child { font-weight: 600; }
}
.tabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.tabs button[role="tab"] { background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 8px 18px; cursor: pointer; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--accent); color: #04121c; border-color: transparent; }
.tabs select { margin-left: auto; max-width: 100%; }
.tabs select[hidden] { display: none; }
.mapbox { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.map svg { width: 100%; height: auto; display: block; }
.mapc { fill: var(--field); stroke: var(--line); stroke-width: .6; }
.mapc.hit { fill: var(--sev-critical); stroke: var(--line); }
.map.good .mapc.hit { fill: var(--accent); }
.maplist .bar-row { padding: 4px 0; }
.sw.t-req { background: color-mix(in srgb, var(--accent) 38%, transparent); }
.sw.t-pages { background: var(--accent); }
.b-treq { fill: color-mix(in srgb, var(--accent) 38%, transparent); }
.b-tpages { fill: var(--accent); }
.bar-row .sub { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.origin { display: block; }
.origin small, td small { display: block; color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
footer #attrib { margin-top: 4px; opacity: .8; }
@media (max-width: 960px) { .mapbox { grid-template-columns: 1fr; } }

/* compact IP table: one line per IP on desktop */
#ips td { padding: 5px 8px; }
#ips .origin { display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ips td:nth-child(4) { white-space: nowrap; }
#ips td:nth-child(4) .chip { margin-bottom: 0; }
@media (max-width: 720px) {
  #ips .origin { max-width: none; white-space: normal; }
}
