:root {
  --bg: #0f1215;
  --panel: #171b20;
  --ink: #d8dde3;
  --muted: #8b949e;
  --line: #2a3138;
  --hot: #c24b3c;
  --mid: #c9a24a;
  --ok: #5f8f6b;
  --ssh: #c24b3c;
  --scan: #6d8ea3;
  --flood: #c9a24a;
  --mail: #5f8f6b;
  --login: #a86b52;
  --probe: #8b949e;
  color: var(--ink);
  background: var(--bg);
  font-family: "DejaVu Sans", "Nimbus Sans", Arial, sans-serif;
  font-size: 13px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr) 58px;
  background: var(--bg);
  transition: grid-template-rows 260ms ease;
}

body.live-mode {
  grid-template-rows: 40px minmax(0, 1fr) 88px;
}

button { font: inherit; color: inherit; }

header, aside, footer { background: var(--panel); }

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 0 10px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
  flex: 0 0 auto;
}

.brand img {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.link-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.link-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5a6570;
}

.link-status.is-live::before { background: var(--ok); }
.link-status.is-boot::before { background: var(--mid); }
.link-status.is-down::before { background: var(--hot); }

.rate-label {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.top-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.top-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 120px;
  padding: 2px 7px 2px 4px;
  border: 1px solid var(--line);
  background: #12161a;
  color: var(--ink);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.top-chip img {
  width: 12px;
  height: 9px;
  object-fit: cover;
  flex: 0 0 auto;
}

.top-chip strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}


.toasts {
  position: fixed;
  top: 48px;
  right: 12px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: min(340px, calc(100vw - 24px));
}

.toast {
  pointer-events: auto;
  padding: 8px 10px;
  background: #171b20;
  border: 1px solid var(--line);
  border-left: 3px solid var(--mid);
  color: var(--ink);
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: toastIn 180ms ease;
}

.toast.hot { border-left-color: var(--hot); }
.toast.ok { border-left-color: var(--ok); }

.toast strong { font-weight: 600; }
.toast .toast-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.top-ips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.top-ips:empty { display: none; }

.ip-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px 3px 5px;
  border: 1px solid var(--line);
  background: #12161a;
  color: var(--ink);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
}

.ip-chip img {
  width: 12px;
  height: 9px;
  object-fit: cover;
  flex: 0 0 auto;
}

.ip-chip .mono {
  color: var(--muted);
  font-family: "DejaVu Sans Mono", "Noto Sans Mono", monospace;
  font-size: 10px;
}
.ip-chip strong { font-weight: 600; color: var(--muted); }
.ip-chip.hot { border-color: #5a3030; }
.ip-chip.burst { border-color: #5a4a28; }

.search-wrap {
  display: block;
  margin-top: 7px;
}

.search-wrap input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: #0b0e11;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.search-wrap input::placeholder { color: #66707a; }
.search-wrap input:focus {
  outline: none;
  border-color: #4a5560;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: 0; }

h1 { font-size: 15px; font-weight: 600; line-height: 1; }

main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
}

main > * { min-height: 0; }

.stage {
  position: relative;
  background: #0b0e11;
  border-right: 1px solid var(--line);
}

canvas { width: 100%; height: 100%; display: block; touch-action: none; }
canvas.panning { cursor: grabbing !important; }

.flag-layer { display: none; }

.host-badge {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px 2px 3px;
  background: #12161a;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}

.host-badge img {
  width: 14px;
  height: 14px;
  display: block;
}

.loading, .quiet {
  position: absolute;
  left: 10px;
  bottom: 10px;
  margin: 0;
  padding: 3px 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.tip {
  position: absolute;
  z-index: 4;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 3px 7px;
  margin: 0;
  min-width: 180px;
  max-width: 260px;
  padding: 7px 9px;
  background: #0f1215;
  color: var(--ink);
  border: 1px solid #9aa3ad;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transform: translate(12px, 14px);
  transition: opacity 120ms ease, transform 160ms ease;
}

.tip.show { opacity: 1; }

.tip .tip-flag {
  width: 20px;
  height: 14px;
  object-fit: cover;
  display: block;
  grid-row: 1 / span 5;
  margin-top: 2px;
}

.tip strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.tip .tip-meta, .tip .tip-kinds {
  color: var(--muted);
  grid-column: 2;
}

h2 img, .detail img.flag {
  width: 18px;
  height: 12px;
  object-fit: cover;
  display: block;
}

.country-card {
  position: absolute;
  z-index: 3;
  top: 10px;
  left: 10px;
  width: min(280px, calc(100% - 20px));
  margin: 0;
  padding: 9px 10px 10px;
  background: #0f1215;
  border: 1px solid var(--line);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 200ms ease, transform 240ms ease;
}

.country-card.open { opacity: 1; transform: none; }

.country-card h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
}

.country-figures { margin: 7px 0; color: var(--muted); font-size: 12px; }
.country-figures strong { color: var(--ink); font-weight: 700; }

.country-meta,
.dossier-meta {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 2px 8px;
  margin: 0 0 6px;
  font-size: 11px;
}

.country-meta dt,
.dossier-meta dt { color: var(--muted); }

.country-meta dd,
.dossier-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.country-card ul,
.dossier-kinds,
.dossier-tops { list-style: none; margin: 0; padding: 0; }

.country-card li,
.dossier-kinds li,
.dossier-tops li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.country-tops .top-head,
.dossier-tops .top-head {
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  justify-content: flex-start;
  border-top: 0;
  padding-top: 6px;
}

.country-tops .mono,
.dossier-tops .mono,
.detail dd.mono {
  font-family: "DejaVu Sans Mono", "Noto Sans Mono", monospace;
  font-size: 11px;
}

aside { display: flex; flex-direction: column; overflow: hidden; }

.summary, .loghead { border-bottom: 1px solid var(--line); }

.summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 9px 10px;
}

.summary-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.stat strong {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.summary-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex: 0 0 auto;
}

.clock {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.export-btn {
  border: 1px solid var(--line) !important;
  background: transparent !important;
  color: var(--muted) !important;
  padding: 3px 8px !important;
  font-size: 10px !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.export-btn:hover {
  color: var(--ink) !important;
  background: #1a2026 !important;
  border-color: #3a4450 !important;
}

.loghead { padding: 7px; }

.roles, .filters, .speeds, .windows { display: flex; flex-wrap: wrap; gap: 3px; }
.filters { margin-top: 5px; }

button {
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 4px 7px;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
}

button:hover { color: var(--ink); background: #22282f; }

button.active, button.solid {
  color: var(--ink);
  background: #2a323a;
  border-color: #3a4450;
}

.feed,
.detail,
.whois-raw {
  scrollbar-width: thin;
  scrollbar-color: #4a5664 #12161a;
}

.feed::-webkit-scrollbar,
.detail::-webkit-scrollbar,
.whois-raw::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.feed::-webkit-scrollbar-track,
.detail::-webkit-scrollbar-track,
.whois-raw::-webkit-scrollbar-track {
  background: #12161a;
  border-left: 1px solid var(--line);
}

.feed::-webkit-scrollbar-thumb,
.detail::-webkit-scrollbar-thumb,
.whois-raw::-webkit-scrollbar-thumb {
  background: #3a4450;
  border: 2px solid #12161a;
  border-radius: 0;
}

.feed::-webkit-scrollbar-thumb:hover,
.detail::-webkit-scrollbar-thumb:hover,
.whois-raw::-webkit-scrollbar-thumb:hover {
  background: #5a6a7a;
}

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  min-height: 0;
  flex: 1;
}

.feed li {
  display: grid;
  grid-template-columns: 18px 14px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.feed li.selected { background: #22282f; }
.feed li.burst { background: rgba(201, 162, 74, 0.08); }
.feed li.hot { background: rgba(194, 75, 60, 0.1); }
.feed li.empty { display: block; color: var(--muted); cursor: default; }

.feed img.flag { width: 18px; height: 12px; object-fit: cover; display: block; }
.feed img.mark { width: 14px; height: 14px; display: block; }
.feed strong { display: block; font-weight: 700; font-size: 12px; }
.feed span, .feed time { color: var(--muted); font-size: 11px; }
.feed span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed .feed-ip {
  color: #6f7a86;
  font-family: "DejaVu Sans Mono", "Noto Sans Mono", monospace;
  font-size: 10px;
}
.feed time { font-variant-numeric: tabular-nums; }

.detail {
  border-top: 1px solid var(--line);
  padding: 8px 10px 10px;
  max-height: 58%;
  overflow: auto;
  background: #12161a;
}

.detail h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: 12px;
}

.detail .threat {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
}

.detail .threat strong { color: var(--ink); }

.detail img.mark,
.detail img.flag { width: 14px; height: 14px; }
.detail img.flag { width: 18px; height: 12px; object-fit: cover; }

.detail dl {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 3px 8px;
  margin: 0;
  font-size: 11px;
}

.detail dt { color: var(--muted); }
.detail dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.country-dossier {
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.dossier-figures {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
}

.dossier-figures strong { color: var(--ink); font-weight: 700; }

.packet-block h3 { margin-top: 2px; }

.lookup-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.whois-raw {
  margin: 8px 0 0;
  padding: 8px;
  max-height: 160px;
  overflow: auto;
  background: #0b0e11;
  border: 1px solid var(--line);
  color: var(--muted);
  font: 10px/1.35 "DejaVu Sans Mono", "Noto Sans Mono", monospace;
  white-space: pre-wrap;
}

.ctx {
  position: fixed;
  z-index: 40;
  min-width: 210px;
  padding: 4px;
  background: #14181d;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.ctx button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.ctx button:hover { background: #22282f; }

footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-top: 1px solid var(--line);
}

.transport {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #0b0e11;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.icon-btn svg {
  width: 11px;
  height: 11px;
  display: block;
  flex: none;
}

.icon-btn .icon-pause { display: none; }
.icon-btn.is-playing .icon-play { display: none; }
.icon-btn.is-playing .icon-pause { display: block; }

#playBtn .icon-play { color: #3dba6e; }
#playBtn.is-playing .icon-pause { color: #ff3b30; }
#playBtn:not(.is-playing) { color: var(--ink); }
#playBtn:not(.is-playing) .icon-play { color: #3dba6e; }
#playBtn.is-playing { color: var(--ink); }
#playBtn.is-playing .icon-pause { color: #ff3b30; }

.maps-btn { margin-left: 2px; }
.maps-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.maps-btn:not(:disabled):hover { color: var(--ink); background: #22282f; }

.gmaps-icon {
  display: block;
  width: 14px;
  height: 14px;
  flex: none;
}

.maps-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 2px;
}

.detail-actions button,
.country-actions button {
  border: 1px solid var(--line);
  background: #1a1f25;
  color: var(--ink);
  padding: 5px 9px;
  font-size: 11px;
}

.country-actions { margin-top: 8px; }

#liveBtn.is-live svg {
  color: #ff3b30;
  filter: drop-shadow(0 0 5px rgba(255, 59, 48, 0.95));
  animation: livePulse 1.1s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.82); }
}

.speeds {
  overflow: hidden;
  max-width: 280px;
  opacity: 1;
  transition: max-width 260ms ease, opacity 180ms ease, margin 260ms ease;
}

footer.live .speeds {
  max-width: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

.wave-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line);
  background: #0b0e11;
  transition: height 260ms ease;
  overflow: hidden;
}

footer.live .wave-wrap { height: 76px; }

#wave { cursor: ew-resize; width: 100%; height: 100%; }

#cursorLabel {
  position: absolute;
  top: 2px;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  padding: 1px 7px;
  border: 1px solid var(--line);
  background: #171b20;
  color: var(--ink);
  font-size: 10px;
  line-height: 1.35;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

#cursorLabel[data-edge="left"] { transform: translateX(0); }
#cursorLabel[data-edge="right"] { transform: translateX(-100%); }

@media (max-width: 860px) {
  body, body.live-mode { height: auto; overflow: auto; grid-template-rows: auto auto auto; }
  main { grid-template-columns: 1fr; }
  .stage { height: 58vw; border-right: 0; border-bottom: 1px solid var(--line); }
  aside { max-height: 420px; }
  .wave-wrap, footer.live .wave-wrap { height: 64px; }
  .top-strip { display: none; }
  .rate-label { display: none; }
}
