:root {
  --bg: #071013;
  --panel: rgba(10, 20, 24, 0.82);
  --panel-strong: rgba(12, 26, 31, 0.96);
  --border: rgba(237, 244, 239, 0.1);
  --text: #edf4ef;
  --muted: #95ada3;
  --accent: #efb547;
  --accent-deep: #cb563d;
  --accent-cool: #0b5d5e;
  --shadow: 0 24px 50px rgba(0, 0, 0, 0.28);
}

body[data-theme="matrix"] {
  --bg: #071108;
  --panel: rgba(8, 20, 10, 0.82);
  --panel-strong: rgba(10, 26, 12, 0.95);
  --border: rgba(116, 255, 138, 0.2);
  --text: #d8ffdf;
  --muted: #8ec89a;
  --accent: #5eff79;
  --accent-deep: #2dbb45;
  --accent-cool: #0e7f2a;
  --shadow: 0 24px 60px rgba(4, 20, 7, 0.38);
}

body[data-theme="light-blue"] {
  --bg: #eaf6ff;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: rgba(244, 252, 255, 0.98);
  --border: rgba(47, 104, 163, 0.18);
  --text: #173550;
  --muted: #567a9d;
  --accent: #3f9ae5;
  --accent-deep: #2b5f93;
  --accent-cool: #2e7fb2;
  --shadow: 0 20px 45px rgba(31, 89, 140, 0.16);
}

body[data-theme="crimson"] {
  --bg: #000000;
  --panel: rgba(16, 2, 2, 0.90);
  --panel-strong: rgba(22, 2, 2, 0.97);
  --border: rgba(200, 20, 20, 0.28);
  --text: #f5e6e6;
  --muted: #a06060;
  --accent: #e82020;
  --accent-deep: #8b0000;
  --accent-cool: #c0392b;
  --shadow: 0 24px 60px rgba(180, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(239, 181, 71, 0.2), transparent 26%),
    radial-gradient(circle at bottom right, rgba(11, 93, 94, 0.18), transparent 32%),
    linear-gradient(145deg, #04090b 0%, #071013 38%, #10191a 100%);
}

body[data-theme="matrix"] {
  background:
    radial-gradient(circle at top left, rgba(94, 255, 121, 0.2), transparent 28%),
    radial-gradient(circle at bottom right, rgba(14, 127, 42, 0.24), transparent 34%),
    linear-gradient(145deg, #040a04 0%, #071108 40%, #0f1b11 100%);
}

body[data-theme="light-blue"] {
  background:
    radial-gradient(circle at top left, rgba(83, 170, 243, 0.2), transparent 30%),
    radial-gradient(circle at bottom right, rgba(67, 128, 188, 0.16), transparent 34%),
    linear-gradient(145deg, #edf8ff 0%, #eaf6ff 40%, #dceefe 100%);
}

body[data-theme="crimson"] {
  background: #0a0404;
}

a {
  color: inherit;
}

.ambient {
  position: fixed;
  inset: auto;
  width: 22rem;
  height: 22rem;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.3;
  pointer-events: none;
}

.ambient-a {
  top: 4rem;
  right: 8%;
  background: rgba(203, 86, 61, 0.34);
}

.ambient-b {
  bottom: 6rem;
  left: 6%;
  background: rgba(11, 93, 94, 0.24);
}

body[data-theme="matrix"] .ambient-a { background: rgba(94, 255, 121, 0.28); }
body[data-theme="matrix"] .ambient-b { background: rgba(14, 127, 42, 0.22); }
body[data-theme="crimson"] .ambient-a { background: rgba(200, 10, 10, 0.4); }
body[data-theme="crimson"] .ambient-b { background: rgba(100, 0, 0, 0.24); }

/* Crimson theme: header */
body[data-theme="crimson"] .shell-header {
  background: rgba(0, 0, 0, 0.82);
  border-bottom-color: rgba(200, 20, 20, 0.38);
}
.shell-header {
  position: sticky;
  top: 0.75rem;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.35rem 2rem;
  margin: 0.75rem 1rem 0;
  border-radius: 16px;
  backdrop-filter: blur(18px);
  background: rgba(4, 9, 11, 0.68);
  border: 1px solid var(--border);
}

.shell-logo {
  height: 56px;
  width: auto;
  flex-shrink: 0;
}

.shell-header h1,
.panel h2,
.panel h3,
.panel h4 {
  margin: 0;
}

.shell-header nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.theme-button {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.shell-header nav a,
.button,
button {
  padding: 0.72rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-decoration: none;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.shell-header nav a:hover,
.button:hover,
button:hover {
  transform: translateY(-1px);
  border-color: rgba(239, 181, 71, 0.42);
  background: rgba(239, 181, 71, 0.08);
}

.button.ghost {
  background: transparent;
}

.layout {
  width: min(1400px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ── Timeline selector ────────────────────────────────────────────────────── */
.timeline-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.tl-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.tl-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tl-btn {
  padding: 0.38rem 0.82rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 140ms ease;
  white-space: nowrap;
}

.tl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(239, 181, 71, 0.07);
  transform: translateY(-1px);
}

.tl-btn.active {
  border-color: var(--accent);
  background: rgba(239, 181, 71, 0.14);
  color: var(--accent);
  font-weight: 500;
}

.tl-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.table-pager {
  margin-top: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

body[data-theme="matrix"] .tl-btn:hover,
body[data-theme="matrix"] .tl-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(94, 255, 121, 0.1);
}

body[data-theme="light-blue"] .tl-btn:hover,
body[data-theme="light-blue"] .tl-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(63, 154, 229, 0.12);
}

body[data-theme="crimson"] .tl-btn:hover,
body[data-theme="crimson"] .tl-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(232, 32, 32, 0.12);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 1.4rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.4rem;
}

/* ── Intelligence Summary panel ──────────────────────────────────────────── */
.summary-panel {
  margin-bottom: 1.4rem;
}
.summary-headline {
  font-size: 1.15rem;
  font-weight: 600;
  margin: .3rem 0 .4rem;
  line-height: 1.5;
}
.sum-hl {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.summary-timespan strong {
  color: rgba(255,255,255,.8);
  font-weight: 600;
}
.sum-ts-label {
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: .72rem;
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
}
.summary-metrics-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: .55rem;
  margin: .9rem 0 1rem;
}
.summary-metric {
  padding: .65rem .75rem !important;
}
.summary-metric span {
  font-size: .7rem !important;
  margin-bottom: .25rem !important;
}
.summary-metric strong {
  font-size: 1.2rem !important;
}
.summary-charts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  margin-bottom: .9rem;
}
.summary-chart-cell {
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.055);
  border-radius: 8px;
  padding: .3rem .25rem .1rem;
  overflow: hidden;
}
.summary-minichart {
  min-height: 210px;
}
.summary-coverage-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  padding: .6rem 0 .15rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sum-cov-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .15rem .9rem;
  gap: .1rem;
}
.sum-cov-num {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: "IBM Plex Mono", monospace;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.sum-cov-label {
  font-size: .65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.sum-cov-divider {
  width: 1px;
  height: 2rem;
  background: rgba(255,255,255,.08);
  flex-shrink: 0;
}

.hero-copy,
.panel-header p,
.chart-title-row p,
.eyebrow,
label span {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.72rem;
  font-family: "IBM Plex Mono", monospace;
}

.hero-grid,
.grid-two,
.grid-three,
.detail-grid {
  display: grid;
  gap: 1rem;
}

.hero-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 1.4rem;
}

.grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 1.4rem 0;
}

.sankey-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 1.4rem 0;
}

.metric-card,
.detail-card {
  padding: 1rem;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.metric-card span,
.detail-card span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 0.4rem;
}

.metric-card strong,
.detail-card strong {
  display: block;
  word-break: break-word;
  font-size: 1.5rem;
}

.detail-card strong {
  font-size: 1rem;
  font-family: "IBM Plex Mono", monospace;
}

.chart {
  min-height: 290px;
}

/* Hit-count badge for grouped/upserted events */
.hit-badge {
  display: inline-block;
  padding: 0.15rem 0.48rem;
  border-radius: 999px;
  background: rgba(224, 90, 71, 0.22);
  border: 1px solid rgba(224, 90, 71, 0.55);
  color: #e05a47;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* HTTP method + URI in events list */
.http-req-cell { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.http-method {
  display: inline-block;
  padding: 0.08rem 0.38rem;
  border-radius: 4px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 0.35rem;
  white-space: nowrap;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #c8e6ff;
}
.http-method.http-get    { background: rgba(60,174,163,0.2); border-color: rgba(60,174,163,0.5); color: #3caea3; }
.http-method.http-post   { background: rgba(203,86,61,0.2);  border-color: rgba(203,86,61,0.5);  color: #e05a47; }
.http-method.http-put    { background: rgba(246,200,95,0.2); border-color: rgba(246,200,95,0.5); color: #f6c85f; }
.http-method.http-delete { background: rgba(224,90,71,0.25); border-color: rgba(224,90,71,0.6);  color: #ff7a62; }
.http-method.http-head   { background: rgba(141,167,190,0.2);border-color: rgba(141,167,190,0.4);color: #8da7be; }
.http-uri {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.65);
  max-width: 230px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.http-uri-cell { max-width: 320px; overflow: hidden; }
.http-ua-cell  { max-width: 280px; overflow: hidden; font-size: 0.72rem; color: rgba(255,255,255,0.55); }

/* HTTP status code badges */
.http-status {
  display: inline-block;
  padding: 0.06rem 0.36rem;
  border-radius: 4px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
}
.http-status.http-status-2xx { background: rgba(60,174,163,0.18); border-color: rgba(60,174,163,0.4); color: #3caea3; }
.http-status.http-status-3xx { background: rgba(246,200,95,0.18); border-color: rgba(246,200,95,0.4); color: #f6c85f; }
.http-status.http-status-4xx { background: rgba(224,90,71,0.2);   border-color: rgba(224,90,71,0.4);  color: #e05a47; }
.http-status.http-status-5xx { background: rgba(180,60,60,0.25);  border-color: rgba(180,60,60,0.5);  color: #ff7a62; }

/* HTTP events table */
.http-events-table td { vertical-align: top; }

/* ── HTTP Summary card ───────────────────────────────────────────────── */
.http-summary-grid {
  display: grid;
  grid-template-columns: auto 1fr 1.6fr 1.6fr;
  gap: 1.25rem 1.75rem;
  align-items: start;
  padding: 0.25rem 0;
}
@media (max-width: 1100px) {
  .http-summary-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .http-summary-grid { grid-template-columns: 1fr; }
}

.http-summary-block { display: flex; flex-direction: column; gap: 0.45rem; }

.http-method-bar {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  height: 1.5rem;
  min-width: 120px;
  gap: 2px;
}
.http-method-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  overflow: hidden;
  white-space: nowrap;
  min-width: 2px;
  opacity: 0.9;
}
.http-method-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  align-items: center;
  font-size: 0.75rem;
}

.http-stat-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.http-stat-bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
}
.http-stat-bar {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent, #3caea3);
  min-width: 2px;
}

.http-uri-list { display: flex; flex-direction: column; gap: 0.3rem; }
.http-uri-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.http-uri-item .http-uri {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gsb-count {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

/* HTTP status bucket badges (2xx / other) */
.http-status.http-status-other { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.15); color: rgba(255,255,255,0.5); }

/* ── Payload cluster cards ───────────────────────────────────────────── */
.payload-cluster-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.payload-cluster-card {
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.payload-cluster-card.outlier {
  border-color: rgba(245,158,11,0.45);
  background: rgba(245,158,11,0.06);
}
.payload-cluster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.payload-cluster-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.payload-cluster-tags {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.payload-outlier-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(245,158,11,0.25);
  border: 1px solid rgba(245,158,11,0.6);
  color: #f59e0b;
}
.payload-group-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: rgba(60,174,163,0.15);
  border: 1px solid rgba(60,174,163,0.35);
  color: #3caea3;
}
.payload-cluster-id {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
}
.payload-cluster-id:hover { text-decoration: underline; }
.payload-cluster-ips {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.payload-ip {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.06);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
}
.payload-tag {
  font-size: 0.68rem;
  padding: 0.06rem 0.42rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.6);
}
.payload-pre--cluster {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  padding: 0.55rem 0.7rem;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 6px;
  color: #a8e6cf;
  -webkit-user-select: text;
  user-select: text;
}

/* Event detail: section labels + HTTP group */
.detail-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 1.25rem 0 0.4rem 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 0.5rem;
}
.detail-section-label:first-of-type { border-top: none; margin-top: 0; }
.detail-card--wide { grid-column: span 2; }
.detail-grid.http-fields { border: 1px solid rgba(60,174,163,0.2); border-radius: 8px; padding: 0.75rem; background: rgba(60,174,163,0.04); margin-bottom: 0.5rem; }

.chart-large {
  min-height: 420px;
}

.chart-sankey {
  min-height: 560px;
}

.sankey-hint {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.38);
  font-style: italic;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.compact-panel {
  padding-top: 1rem;
}

.panel-header,
.chart-title-row,
.split {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.data-table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.9rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: "IBM Plex Mono", monospace;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table.compact td,
.data-table.compact th {
  padding-left: 0;
  padding-right: 0;
}

/* Payload table */
.payload-table-wrap {
  overflow-x: auto;
}

.payload-table .payload-pre {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 160px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  padding: 0.45rem 0.6rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  color: #a8e6cf;
  min-width: 280px;
  max-width: 520px;
  /* Ensure text is never interpreted as HTML */
  -webkit-user-select: text;
  user-select: text;
}

.payload-table .ts-cell {
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--muted);
}

.payload-table .muted-cell {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.payload-table .asn-label {
  font-size: 0.7rem;
  opacity: 0.65;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

input,
select {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(3, 8, 9, 0.65);
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
}

.filter-actions,
.pager {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.detail-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sankey-card {
  padding: 1rem;
  border-radius: 24px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Attack origin map — layout */
/* ── View mode toggle bar ── */
.globe-mode-bar {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 0.25rem;
  width: fit-content;
}
.globe-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.9rem;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s, transform 0s;
  white-space: nowrap;
}
.globe-mode-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  transform: none;
  border-color: transparent;
}
.globe-mode-btn.active {
  background: rgba(239,181,71,0.15);
  border-color: rgba(239,181,71,0.45);
  color: #efb547;
  transform: none;
}

/* Hide globe-only controls in 2D mode and vice-versa */
.map2d-only-ctrl { display: none; }
.globe-layout.mode-2d .globe-only-ctrl { display: none; }
.globe-layout.mode-2d .map2d-only-ctrl { display: block; }

/* 2D map container */
#attack-map2d {
  display: none;
  width: 100%;
  height: 910px;
  border-radius: 18px;
  overflow: hidden;
  background: #0d1a20;
}
#attack-map2d.active { display: block; }

/* Show 2D, hide 3D in 2D mode */
.globe-layout.mode-2d #attack-globe { display: none; }
.globe-layout.mode-2d #attack-map2d { display: block; }

/* Leaflet dark theme overrides */
#attack-map2d .leaflet-container {
  background: #0d1a20;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
}
#attack-map2d .leaflet-popup-content-wrapper {
  background: rgba(10, 20, 28, 0.95);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #e8eef7;
  box-shadow: 0 4px 18px rgba(0,0,0,0.55);
}
#attack-map2d .leaflet-popup-tip {
  background: rgba(10, 20, 28, 0.95);
}
#attack-map2d .leaflet-popup-close-button { color: rgba(255,255,255,0.5); }
#attack-map2d .leaflet-control-zoom a {
  background: rgba(10,18,26,0.88);
  border-color: rgba(255,255,255,0.13);
  color: rgba(255,255,255,0.7);
}
#attack-map2d .leaflet-control-zoom a:hover {
  background: rgba(239,181,71,0.15);
  color: #efb547;
}
#attack-map2d .leaflet-control-attribution {
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.3);
  font-size: 0.65rem;
}

.globe-section .globe-layout {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
}

.globe-sidebar {
  flex: 0 0 210px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-height: 910px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.globe-sidebar::-webkit-scrollbar { width: 4px; }
.globe-sidebar::-webkit-scrollbar-track { background: transparent; }
.globe-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 2px; }

.globe-main {
  flex: 1;
  min-width: 0;
  position: relative;
}

/* Sidebar groups */
.gsb-group {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}

.gsb-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  display: block;
}

.gsb-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.gsb-hint {
  font-size: 0.62rem;
  opacity: 0.55;
  font-weight: normal;
  letter-spacing: 0;
  text-transform: none;
}

.gsb-hint-line {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.64rem;
  color: var(--muted);
  opacity: 0.6;
  margin-top: 0.3rem;
}

.gsb-val {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--accent);
}

/* Layer toggle buttons */
.globe-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.gtoggle {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  padding: 0.28rem 0.52rem;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: rgba(255,255,255,0.38);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  letter-spacing: 0.04em;
}

.gtoggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #07131a;
  font-weight: 600;
}

.gtoggle:hover:not(.active) {
  border-color: rgba(255,255,255,0.38);
  color: rgba(255,255,255,0.72);
}

/* Texture select */
.gsb-select {
  width: 100%;
  font-size: 0.78rem;
}

/* Size slider */
.gsb-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

/* Category filters */
.cat-filter-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cat-filter-item {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  padding: 0.26rem 0.48rem;
  border-radius: 5px;
  cursor: pointer;
  color: rgba(255,255,255,0.35);
  border: 1px solid transparent;
  transition: all 0.18s;
  user-select: none;
}

.cat-filter-item.active {
  color: rgba(255,255,255,0.88);
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.11);
}

.cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Top-country / top-IP lists */
.gsb-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.gsb-list::-webkit-scrollbar { width: 3px; }
.gsb-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.gsb-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  padding: 0.22rem 0.42rem;
  border-radius: 4px;
  cursor: pointer;
  color: rgba(255,255,255,0.75);
  border: 1px solid transparent;
  transition: all 0.14s;
}

.gsb-list-item:hover { background: rgba(255,255,255,0.07); }

.gsb-list-item.excluded {
  opacity: 0.32;
  text-decoration: line-through;
}

.gsb-count {
  color: var(--muted);
  font-size: 0.68rem;
  margin-left: 0.4rem;
  white-space: nowrap;
}

/* Globe canvas */
.globe-fs-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 20, 30, 0.72);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.globe-fs-btn:hover {
  background: rgba(239,181,71,0.18);
  border-color: rgba(239,181,71,0.5);
  color: #efb547;
}

.globe-main.globe-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #07131a;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 0;
}
.globe-main.globe-fullscreen #attack-globe,
.globe-main.globe-fullscreen #attack-map2d {
  flex: 1;
  height: auto !important;
  border-radius: 0;
}
.globe-main.globe-fullscreen .map-legend {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 1rem;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  border-top: 1px solid rgba(255,255,255,0.06);
  margin: 0;
}
.globe-main.globe-fullscreen .map-status {
  position: absolute;
  top: 10px;
  left: 14px;
  z-index: 5;
}

#attack-globe {
  width: 100%;
  height: 910px;
  border-radius: 18px;
  overflow: hidden;
  background: #03090e;
}

#attack-globe canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.map-popup strong {
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
}

.map-popup {
  font-size: 0.88rem;
  line-height: 1.6;
}

.sensor-dot {
  width: 18px;
  height: 18px;
  background: #0b5d5e;
  border: 2px solid #efb547;
  border-radius: 3px;
  transform: rotate(45deg);
  box-shadow: 0 0 8px rgba(239, 181, 71, 0.6);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 0.85rem;
  padding-left: 0.25rem;
}

.map-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  margin-bottom: 0.8rem;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a8e6cf;
  border: 1px solid rgba(60, 174, 163, 0.45);
  background: rgba(60, 174, 163, 0.12);
  font-family: "IBM Plex Mono", monospace;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
}

.legend-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot-heat {
  width: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e 0%, #f59e0b 54%, #ef4444 100%);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.legend-flag-dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.legend-flag-icon {
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px 2px 2px 0;
  background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
  clip-path: polygon(0 0, 100% 18%, 72% 52%, 100% 100%, 0 84%);
}

.legend-flag-icon::before {
  content: "";
  position: absolute;
  left: -3px;
  top: -1px;
  width: 2px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.legend-sensor-dot {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 0;
}

.legend-sensor-dot svg {
  width: 14px;
  height: 14px;
  display: block;
}

.active-flag-marker {
  pointer-events: none;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--flag-glow, #ef4444) 55%, transparent));
}

.active-flag-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.8rem;
  height: 1.3rem;
  padding: 0.08rem;
  border-radius: 999px;
  background: rgba(7, 16, 19, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 0 14px rgba(0, 0, 0, 0.28);
  transform: translate(-50%, -115%);
  animation: flag-pop 1.4s ease-out forwards;
}

.active-flag-img {
  display: block;
  width: 1.35rem;
  height: 0.95rem;
  object-fit: cover;
  border-radius: 999px;
}

@keyframes flag-pop {
  0% {
    opacity: 0;
    transform: translateY(0.45rem) scale(0.72);
  }
  18% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  72% {
    opacity: 0.92;
    transform: translateY(-0.08rem) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-0.38rem) scale(0.94);
  }
}

@media (max-width: 1080px) {
  .hero,
  .grid-two,
  .grid-three,
  .filter-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .summary-metrics-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .summary-charts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shell-header,
  .panel-header,
  .chart-title-row,
  .split {
    align-items: flex-start;
    flex-direction: column;
  }

  .globe-section .globe-layout {
    flex-direction: column;
  }

  .globe-sidebar {
    flex: none;
    max-height: none;
    overflow-y: visible;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .gsb-group {
    flex: 1 1 180px;
  }
}

@media (max-width: 720px) {
  .layout {
    width: min(100% - 1rem, 1400px);
  }

  .shell-header {
    padding: 1rem;
  }

  .panel {
    border-radius: 22px;
    padding: 1rem;
  }

  .hero-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-charts-grid {
    grid-template-columns: 1fr;
  }

  .data-table {
    display: block;
    overflow-x: auto;
  }
}