/* Ransomware.live Attack Map — dark (default) & light themes, toggled via
   data-theme on <html> (same mechanism as t-pot-attack-map). Chrome tokens
   follow the validated palette for each surface. */

:root {
  color-scheme: dark;
  --page:           #0d0d0d;
  --surface:        rgba(26, 26, 25, 0.92);
  --surface-solid:  #1a1a19;
  --ink:            #ffffff;
  --ink-2:          #c3c2b7;
  --muted:          #898781;
  --hairline:       rgba(255, 255, 255, 0.10);
  --row-line:       rgba(255, 255, 255, 0.04);
  --wash:           rgba(255, 255, 255, 0.08);
  --grid:           #2c2c2a;
  --attr-bg:        rgba(13, 13, 13, 0.70);
  --surface-trans:  rgba(26, 26, 25, 0.55);
  --chart:          #3987e5;
  --good:           #0ca30c;
  --critical:       #d03b3b;
  --accent:         #d03b3b;                  /* t-pot header uses its primary green here */
  --accent-wash:    rgba(208, 59, 59, 0.10);
  --accent-line:    rgba(208, 59, 59, 0.30);
  --mono:           ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --navbar-h:       70px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page:           #f9f9f7;
  --surface:        rgba(252, 252, 251, 0.92);
  --surface-solid:  #fcfcfb;
  --ink:            #0b0b0b;
  --ink-2:          #52514e;
  --muted:          #898781;
  --hairline:       rgba(11, 11, 11, 0.10);
  --row-line:       rgba(11, 11, 11, 0.05);
  --wash:           rgba(11, 11, 11, 0.08);
  --grid:           #e1e0d9;
  --attr-bg:        rgba(252, 252, 251, 0.70);
  --surface-trans:  rgba(252, 252, 251, 0.55);
  --chart:          #2a78d6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ---------- top navbar ---------- */

/* header styled after t-pot-attack-map: 70px blurred bar, counters grouped
   in an accent-tinted pill, mono accent values, 40px ghost buttons */
.top-navbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--navbar-h);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 16px;
  background: var(--surface);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}

.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-logo { height: 44px; width: auto; border-radius: 8px; }
/* wordmark, same as www.ransomware.live (.rl-brand-word) */
.rl-brand-word {
  font-family: 'Sora', 'Inter', system-ui, sans-serif;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.1;
}
.rl-brand-word .tld {
  background: linear-gradient(90deg, #4ade80, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #4ade80;
}
.brand-sub  { color: var(--ink-2); font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; }

.nav-stats {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
  padding: 7px 18px;
  background: var(--accent-wash);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  backdrop-filter: blur(5px);
}
.stat { display: flex; flex-direction: row; align-items: baseline; gap: 7px; }
.stat-value {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  transition: color 0.6s;
}
.stat-value.bump { color: var(--ink); }
.stat-label {
  order: -1;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-controls { display: flex; align-items: center; gap: 14px; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.conn-dot.up   { background: var(--good);     box-shadow: 0 0 6px var(--good); }
.conn-dot.down { background: var(--critical); box-shadow: 0 0 6px var(--critical); }

.clock { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.nav-btn {
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--ink-2);
  width: 40px; height: 40px;
  font-size: 18px;
  cursor: pointer;
}
.nav-btn:hover { background: var(--wash); color: var(--ink); }
.speed-btn { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- replay progress ---------- */

#replay-progress {
  position: fixed;
  top: var(--navbar-h);
  left: 0; right: 0;
  height: 3px;
  z-index: 1090;
  background: transparent;
}
#replay-progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s linear;
}
#replay-progress-bar.live { background: var(--good); }
#replay-progress-label {
  position: fixed;
  top: calc(var(--navbar-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1090;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  color: var(--ink-2);
  font-size: 11px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
#replay-progress-label:empty { display: none; }

/* ---------- map ---------- */

/* full-screen map: the navbar and panels float over it */
#map {
  position: fixed;
  inset: 0;
  background: var(--page);
  z-index: 1;
}

/* leaflet top controls (attribution) sit just below the navbar */
.leaflet-top { top: calc(var(--navbar-h) + 6px); }

/* faint centered watermark, above the whole map (tiles + markers + popups);
   appended directly to .leaflet-container in map.js so it never pans/zooms.
   Note: Leaflet's own CSS puts a single z-index:400 on its internal
   map-pane wrapper, which bundles tiles/markers/popups into one atomic
   layer — there is no z-index that slots between them from outside that
   wrapper, so we sit above all of it instead. Low opacity + pointer-events:
   none keep it from visually or functionally competing with markers. */
#map-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 38%;
  max-width: 460px;
  min-width: 220px;
  opacity: 0.05;
  z-index: 450;
  pointer-events: none;
  user-select: none;
}

.leaflet-container { font: inherit; background: var(--page); }
.leaflet-control-attribution {
  background: var(--attr-bg) !important;
  color: var(--muted) !important;
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--ink-2) !important; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface-solid);
  color: var(--ink);
  border: 1px solid var(--hairline);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.leaflet-popup-content { margin: 10px 14px; font-size: 12.5px; line-height: 1.5; }
.popup-victim { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.popup-row { color: var(--ink-2); }
.popup-row .k { color: var(--muted); }
.popup-approx { color: var(--muted); font-style: italic; font-size: 11px; }

/* ---------- shared panel chrome ---------- */

.panel {
  position: fixed;
  z-index: 1050;
  background: var(--surface);
  backdrop-filter: blur(6px);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--hairline);
}
.panel-header small { color: var(--muted); font-weight: 400; letter-spacing: 0.5px; }

.panel-toggle {
  background: none; border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
}
.panel-toggle:hover { color: var(--ink); }

.panel.collapsed > *:not(.panel-header) { display: none; }
.panel.collapsed .panel-header { border-bottom: none; }

/* ---------- legend (left) ---------- */

#side-panel {
  top: calc(var(--navbar-h) + 14px);
  left: 14px;
  width: 210px;
  max-height: calc(100vh - var(--navbar-h) - 40vh);
}

.legend { list-style: none; padding: 8px 12px; overflow-y: auto; }
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  margin: 0 -6px;
  font-size: 12.5px;
  color: var(--ink-2);
  border-radius: 6px;
  cursor: pointer;
}
.legend li:hover { background: var(--wash); }
.legend li.active { background: var(--wash); color: var(--ink); }
#country-tracking tr { cursor: pointer; }
#country-tracking tr:hover td { background: var(--row-line); }
#country-tracking tr.active td { background: var(--wash); color: var(--ink); }
.legend .swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex: none;
}
.legend .count {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- bottom panel ---------- */

.bottom-panel {
  left: 14px;
  right: 14px;
  bottom: 14px;
  height: 226px;          /* ~6 feed rows by default; drag the burger to resize */
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-trans);   /* see-through: the map runs underneath */
  backdrop-filter: blur(8px);
}
.bottom-panel th { background: var(--surface-trans); backdrop-filter: blur(8px); }
.bottom-panel.hidden { display: none; }

/* keep leaflet's bottom controls (zoom, attribution) above the panel */
.leaflet-bottom { bottom: calc(var(--bottom-panel-h, 226px) + 22px); }

.panel-resize {
  cursor: ns-resize;
  color: var(--muted);
  padding: 2px 10px;
  font-size: 13px;
  touch-action: none;
  user-select: none;
}
.panel-resize:hover { color: var(--ink); }

.tabs { display: flex; gap: 4px; }
.tab {
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 4px 10px;
  cursor: pointer;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--ink); background: var(--wash); }

.tab-body { display: none; overflow-y: auto; }
.tab-body.active { display: block; flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 5px 12px;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 340px;
}
th {
  position: sticky;
  top: 0;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}
td { color: var(--ink-2); border-top: 1px solid var(--row-line); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.time { color: var(--muted); font-variant-numeric: tabular-nums; }
td .victim { color: var(--ink); }

tr.fresh td { animation: freshRow 2.5s ease-out; }
@keyframes freshRow {
  0% { background: rgba(208, 59, 59, 0.25); }
  100% { background: transparent; }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip .swatch {
  width: 9px; height: 9px;
  border-radius: 3px;
  flex: none;
}

.victim-link {
  color: var(--muted);
  font-size: 10px;
  margin-left: 6px;
  text-decoration: none;
}
.victim-link:hover { color: var(--accent); }

.badge-new {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--critical);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  vertical-align: 1px;
}

.flag {
  width: 14px;
  height: 10px;
  object-fit: cover;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
}

.bar {
  display: inline-block;
  height: 4px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 8px;
  background: var(--grid);
}

/* ---------- dashboard tab ---------- */

.dash {
  display: flex;
  gap: 32px;
  padding: 12px 16px 16px;
  height: 100%;
  box-sizing: border-box;
}
.dash-block { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dash-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.dash-timeline {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-height: 90px;
}
.dash-timeline .tl-bar {
  flex: 1;
  min-width: 2px;
  background: var(--chart);
  border-radius: 2px 2px 0 0;
}
.dash-timeline .tl-bar.empty { opacity: 0.35; }
.tl-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.dash-sectors { overflow-y: auto; }
.sector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2.5px 0;
  font-size: 12px;
  color: var(--ink-2);
}
.sector-row .sector-name {
  width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sector-row .sector-bar { height: 6px; background: var(--chart); border-radius: 3px; }
.sector-row .sector-count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- toasts (t-pot style notifications) ---------- */

#toast-container {
  position: fixed;
  top: calc(var(--navbar-h) + 44px);
  right: 14px;
  z-index: 1150;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 280px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--chart);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  animation: toastIn 0.25s ease-out;
  pointer-events: auto;
}
.toast.success { border-left-color: var(--good); }
.toast.alert   { border-left-color: var(--critical); }
.toast.out     { opacity: 0; transition: opacity 0.3s; }
.toast-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.toast-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toast-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.toast-close:hover { color: var(--ink); }
.toast-msg  { font-size: 12px; color: var(--ink-2); margin: 2px 0; word-break: break-word; }
.toast-time { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes toastIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
body.embed #toast-container { display: none !important; }

/* ---------- embed & kiosk modes ---------- */

body.embed .top-navbar,
body.embed #side-panel,
body.embed .bottom-panel,
body.embed #replay-progress,
body.embed #replay-progress-label { display: none !important; }
body.embed .leaflet-top { top: 6px; }

body.kiosk { font-size: 16px; }
body.kiosk .stat-value { font-size: 22px; }
body.kiosk .stat-label { font-size: 12px; }
body.kiosk th { font-size: 12px; }
body.kiosk td { font-size: 14.5px; }
body.kiosk .legend li { font-size: 14px; }

/* ---------- settings modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}
.modal.open { display: flex; }

.modal-card {
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--surface-solid);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.modal-body {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.setting-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.setting-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.setting-group input { accent-color: var(--accent); }

.modal-btn {
  background: var(--accent-wash);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 7px 14px;
  cursor: pointer;
}
.modal-btn:hover { background: var(--accent-line); }

.about-text {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}
.about-text a {
  color: var(--accent);
  text-decoration: none;
}
.about-text a:hover { text-decoration: underline; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .nav-stats { display: none; }
  .brand-sub, .clock { display: none; }
  #side-panel { display: none; }
  .bottom-panel { left: 8px; right: 8px; bottom: 8px; max-height: 40vh; }
}
