/* ── Theme tokens ──────────────────────────────────────────────────────────── */
:root {
  color-scheme: dark;
  /* Elevation ladder — each step is clearly lighter so cards lift off the page */
  --bg:           #070912;
  --surface:      #11141f;
  --surface-raised:#181c2a;
  --surface-soft: #0d0f18;
  --field:        #0a0c15;
  --card-soft:    #0f121c;
  --chip-bg:      rgba(129, 140, 248, 0.14);
  --ink:          #eef1f8;
  --muted:        #8a93a6;
  --line:         rgba(255,255,255,0.08);
  --line-strong:  rgba(255,255,255,0.15);
  --teal:         #818cf8;
  --indigo:       #818cf8;
  --indigo-bright:#a5b0ff;
  --green:        #4ade80;
  --amber:        #fbbf24;
  --red:          #f87171;
  --blue:         #60a5fa;
  --violet:       #c084fc;
  /* Layered shadow for genuine depth */
  --shadow:       0 1px 2px rgba(0,0,0,0.4), 0 12px 32px -8px rgba(0,0,0,0.6);
  --shadow-card:  0 1px 0 rgba(255,255,255,0.04) inset, 0 1px 3px rgba(0,0,0,0.35), 0 8px 24px -12px rgba(0,0,0,0.7);
  --glow-indigo:  0 0 0 1px rgba(129,140,248,0.4), 0 4px 20px -4px rgba(129,140,248,0.45);

  /* text roles: ink = primary, subtext = secondary-readable, muted = tertiary */
  --text:         #eef1f8;
  --subtext:      #c4cbd9;

  /* type scale — one source of truth */
  --fs-display: clamp(30px, 4vw, 46px);
  --fs-h2:      clamp(19px, 2.2vw, 26px);
  --fs-h3:      16px;
  --fs-body:    14px;
  --fs-small:   12.5px;
  --fs-label:   11px;

  --page-px: clamp(18px, 3vw, 42px);
}

[data-theme="light"] {
  color-scheme: light;
  --bg:           #f8fafc;
  --surface:      #ffffff;
  --surface-raised:#f8fafc;
  --surface-soft: #f1f5f9;
  --field:        #ffffff;
  --card-soft:    #f8fafc;
  --chip-bg:      rgba(99,102,241,0.08);
  --ink:          #0f172a;
  --muted:        #475569;
  --line:         rgba(0,0,0,0.08);
  --line-strong:  rgba(0,0,0,0.14);
  --teal:         #4f46e5;
  --indigo:       #4f46e5;
  --indigo-bright:#6366f1;
  --green:        #16a34a;
  --amber:        #d97706;
  --red:          #dc2626;
  --blue:         #2563eb;
  --violet:       #7c3aed;
  --shadow:       0 4px 24px rgba(0,0,0,0.10);
  --shadow-card:  0 1px 2px rgba(0,0,0,0.04), 0 6px 20px -12px rgba(0,0,0,0.18);
  --glow-indigo:  0 0 0 1px rgba(99,102,241,0.35), 0 4px 18px -4px rgba(99,102,241,0.3);
  --text:         #0f172a;
  --subtext:      #334155;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle depth: a faint indigo glow up top + a soft vignette, instead of flat black */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1100px 520px at 78% -8%, rgba(129,140,248,0.10), transparent 60%),
    radial-gradient(900px 600px at 0% 0%, rgba(96,165,250,0.05), transparent 55%);
}

[data-theme="light"] body::before {
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(99,102,241,0.07), transparent 60%);
}

.app-shell, .nav { position: relative; z-index: 1; }

button, input { font: inherit; }
button { cursor: pointer; }
a { text-decoration: none; color: inherit; }

/* ── Sticky nav ────────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 clamp(18px, 3vw, 42px);
  height: 54px;
  background: rgba(10, 13, 20, 0.88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

[data-theme="light"] .nav {
  background: rgba(248, 250, 252, 0.9);
}

.nav-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex-shrink: 0;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}

.nav-brand:hover .nav-brand-name { opacity: 0.8; }

.nav-brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.nav-brand-name span { color: var(--teal); }

.nav-right { display: flex; align-items: center; gap: 1rem; margin-left: auto; }

.nav-back {
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}

.nav-back:hover { color: var(--indigo); }

.theme-btn {
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  border-radius: 7px;
  padding: 0.28rem 0.55rem;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
}

.theme-btn:hover { border-color: var(--teal); color: var(--ink); }

/* ── App shell ─────────────────────────────────────────────────────────────── */
.app-shell { min-height: 100vh; }

/* ── Header / top-bar ──────────────────────────────────────────────────────── */
.top-bar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(300px, 0.75fr) minmax(380px, 1fr);
  gap: 28px;
  align-items: end;
  padding: 32px clamp(18px, 3vw, 42px) 28px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.top-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 120% at 20% -20%, rgba(129,140,248,0.10) 0%, transparent 65%);
  pointer-events: none;
}

.brand-block h1,
.asset-intro h2,
.panel-heading h2,
.feed-heading h2,
.action-panel h2 {
  margin: 0;
  letter-spacing: -0.3px;
}

.brand-block h1 {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1px;
}

.h1-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--indigo);
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 20px;
  padding: 3px 10px;
  vertical-align: middle;
  margin-left: 10px;
  position: relative;
  top: -4px;
}

.brand-block p:last-child {
  max-width: 620px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Lookup form ───────────────────────────────────────────────────────────── */
.lookup-form {
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}

.lookup-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.lookup-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.lookup-row input,
/* ── Prefix view tabs ──────────────────────────────────────────────────────── */
.prefix-views {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.pview-pill {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.pview-pill:hover { color: var(--ink); border-color: var(--teal); }

.pview-pill.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.prefix-load-more {
  width: 100%;
  padding: 9px;
  margin-top: 4px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
  text-align: center;
}

.prefix-load-more:hover { border-color: var(--teal); color: var(--ink); }

.prow-activity {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--teal);
  background: rgba(99,102,241,0.12);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
  cursor: help;
}

/* ── Prefix search ─────────────────────────────────────────────────────────── */
.prefix-search {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 14px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.lookup-row input:focus,
.prefix-search:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

.lookup-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 108px;
  border: 0;
  border-radius: 8px;
  padding: 0 20px;
  background: linear-gradient(180deg, var(--indigo-bright), var(--indigo));
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: var(--glow-indigo);
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
}

.lookup-row button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.lookup-row button:disabled { cursor: wait; opacity: 0.5; transform: none; }

/* ── Asset strip ───────────────────────────────────────────────────────────── */
.asset-strip {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(420px, 1.1fr);
  gap: 24px;
  align-items: stretch;
  padding: 22px clamp(18px, 3vw, 42px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.asset-intro h2 { font-size: clamp(20px, 2.4vw, 32px); line-height: 1.1; font-weight: 800; }

.asset-intro p,
.feed-heading p,
.action-panel p,
.event-card p {
  color: var(--muted);
  line-height: 1.55;
}

/* ── Badges / chips ────────────────────────────────────────────────────────── */
.badge-row,
.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.badge,
.stream-state,
.event-type,
.event-time,
.meta-chip,
.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--chip-bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge.good,  .event-card.good .event-type,  .signal-card.good strong  { color: var(--green); }
.badge.watch, .event-card.watch .event-type, .signal-card.watch strong { color: var(--amber); }
.badge.bad,   .event-card.bad .event-type,   .signal-card.bad strong   { color: var(--red); }
.badge.info,  .event-card.info .event-type,  .signal-card.info strong  { color: var(--blue); }

/* ── Signal grid ───────────────────────────────────────────────────────────── */
.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.signal-card,
.impact-grid article,
.prefix-panel,
.main-panel,
.action-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.signal-card {
  display: grid;
  align-content: center;
  min-height: 110px;
  padding: 16px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.signal-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.signal-label,
.impact-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.signal-card strong {
  display: block;
  min-width: 0;
  margin: 8px 0 5px;
  overflow-wrap: anywhere;
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 800;
  line-height: 1.1;
}

.signal-card small { color: var(--muted); font-size: 12px; line-height: 1.35; }

/* ── Network Intelligence band ─────────────────────────────────────────────── */
.intel-band {
  padding: 20px clamp(18px, 3vw, 42px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.intel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.intel-heading h2 { font-size: 20px; font-weight: 800; margin: 0; }

.intel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.intel-cell {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-soft);
  padding: 12px 14px;
  transition: border-color 0.2s, transform 0.2s;
}

.intel-cell:hover { border-color: var(--line-strong); transform: translateY(-2px); }

.intel-label {
  display: block;
  color: var(--muted);
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.intel-value {
  display: block;
  font-size: var(--fs-body);
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.intel-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.intel-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 0;
  grid-column: 1 / -1;
}

.intel-error {
  color: var(--muted);
  font-size: 13px;
  grid-column: 1 / -1;
}

/* ── Replay band ───────────────────────────────────────────────────────────── */
.replay-band {
  padding: 22px clamp(18px, 3vw, 42px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.replay-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 16px;
}

.replay-heading h2 { font-size: clamp(18px, 2.4vw, 26px); font-weight: 800; }
.replay-heading p  { max-width: 760px; margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Ensure hidden attribute always wins over display declarations */
[hidden] { display: none !important; }

/* ── Tooltips ───────────────────────────────────────────────────────────────── */
[data-tip] { position: relative; }

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a2035;
  border: 1px solid var(--line-strong);
  color: var(--subtext);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.45;
  padding: 7px 11px;
  border-radius: 8px;
  width: max-content;
  max-width: 220px;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}

[data-tip]:hover::after { opacity: 1; }

[data-tip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--line-strong);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 601;
}

[data-tip]:hover::before { opacity: 1; }

.tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 0.62rem;
  font-weight: 700;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  cursor: help;
  vertical-align: middle;
  margin-left: 3px;
  flex-shrink: 0;
  position: relative;
}

/* ── Replay form (redesigned) ───────────────────────────────────────────────── */
.replay-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

/* Row 1: scope pills + locked resource */
.replay-mode-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.replay-scope-pills {
  display: flex;
  gap: 4px;
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 3px;
}

.scope-pill {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.scope-pill.active {
  background: var(--teal);
  color: #fff;
}

.scope-pill:not(.active):hover { color: var(--ink); }

.replay-resource-locked {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: default;
}

.rrl-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}

#replay-resource-display {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

/* Prefix picker row */
.replay-prefix-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
}

.replay-prefix-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.replay-prefix-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.mini-btn:hover { border-color: var(--indigo); color: var(--ink); }

.replay-prefix-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--indigo);
  white-space: nowrap;
}

.replay-prefix-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 132px;
  overflow-y: auto;
}

.rpc-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--subtext);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 5px 9px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.rpc-item:hover { border-color: var(--indigo); }
.rpc-item.on { border-color: var(--indigo); color: var(--ink); background: rgba(129,140,248,0.1); }
.rpc-item input { accent-color: var(--indigo); cursor: pointer; }

.replay-prefix-empty { font-size: 0.78rem; color: var(--muted); }

/* Multi-prefix stats chips */
.mp-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 0.9rem;
}

.mp-chip {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--subtext);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
}

.mp-chip.mp-more { color: var(--muted); }

.replay-label-inline {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}

.replay-label-top {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Row 2: time inputs + related + run button */
.replay-inputs-row {
  display: grid;
  grid-template-columns: minmax(160px, 200px) minmax(160px, 200px) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.replay-label-inline input {
  display: block;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--field);
  color: var(--ink);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-top: 5px;
}

.replay-label-inline input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(129,140,248,0.15);
}

.replay-form input[type="datetime-local"] { color-scheme: dark; }
[data-theme="light"] .replay-form input[type="datetime-local"] { color-scheme: light; }

.replay-related-label { flex-direction: column; align-items: flex-start; }

.optional-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
}

.replay-run-btn {
  min-height: 40px;
  padding: 0 22px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--indigo-bright), var(--indigo));
  color: #fff;
  font-weight: 800;
  font-size: 0.88rem;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--glow-indigo);
  transition: filter 0.15s, transform 0.1s;
  align-self: end;
}

.replay-run-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.replay-run-btn:disabled { cursor: wait; opacity: 0.75; transform: none; display: flex; align-items: center; }
.replay-run-btn:disabled:hover { opacity: 0.75; transform: none; }

.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 7px;
  flex-shrink: 0;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.replay-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.85fr) minmax(500px, 1.15fr);
  gap: 12px;
  align-items: start;
}

.replay-summary,
.replay-cards article {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.replay-summary {
  grid-column: 1 / -1;
  padding: 16px;
}

.replay-summary strong { display: block; font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.replay-summary span   { display: block; color: var(--muted); font-size: 14px; line-height: 1.5; }

.answer-kicker {
  margin-bottom: 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.answer-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-soft);
  padding: 11px 12px;
}

.answer-row > span  { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.answer-row > strong { display: block; margin-top: 6px; overflow-wrap: anywhere; font-size: 16px; font-weight: 800; line-height: 1.2; }
.answer-row > small  { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.learning-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.learning-note {
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 12px;
}

.learning-note > span { display: block; color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.learning-note > p    { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

.replay-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-content: start;
  align-self: start;
  gap: 8px;
}

.replay-cards article { padding: 12px 14px; }
.replay-cards span    { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.replay-cards strong  { display: block; margin-top: 6px; overflow-wrap: anywhere; font-size: 17px; font-weight: 800; line-height: 1.15; }
.replay-cards small   { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.replay-feed { display: grid; align-content: start; gap: 10px; }

.sparkline {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 3px;
  height: 32px;
  margin-top: 10px;
}

.sparkline i {
  display: block;
  min-height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--teal);
  opacity: 0.7;
}

.sparkline i.peak { opacity: 1; background: var(--amber); }

/* ── Workspace ─────────────────────────────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 310px) minmax(420px, 1fr) minmax(240px, 300px);
  gap: 18px;
  padding: 18px clamp(18px, 3vw, 42px) 48px;
}

.prefix-panel,
.main-panel,
.action-panel {
  min-width: 0;
  padding: 16px;
}

.main-panel { box-shadow: var(--shadow); }

.panel-heading,
.feed-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.panel-heading { margin-bottom: 12px; }

.panel-heading h2,
.feed-heading h2,
.action-panel h2 { font-size: 20px; font-weight: 800; }

.prefix-search { margin-bottom: 10px; }

/* ── Prefix tools ──────────────────────────────────────────────────────────── */
.prefix-tools {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 7px;
  align-items: center;
  margin-bottom: 10px;
}

.prefix-tools button {
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 0 10px;
  transition: border-color 0.15s;
}

.prefix-tools button:hover { border-color: var(--teal); }

.prefix-tools span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

/* ── Prefix list ───────────────────────────────────────────────────────────── */
.prefix-list {
  display: grid;
  gap: 7px;
  max-height: calc(100vh - 360px);
  min-height: 240px;
  overflow: auto;
  padding-right: 2px;
}

.prefix-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 6px;
  align-items: stretch;
}

.prefix-check {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  transition: border-color 0.15s;
}

.prefix-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--teal);
}

.prefix-row.selected .prefix-check,
.prefix-row.selected .prefix-button {
  border-color: var(--teal);
}

.prefix-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.prefix-button:hover { border-color: var(--line-strong); background: var(--surface-soft); }

.prefix-button.active {
  border-color: var(--teal);
  background: rgba(129,140,248,0.06);
  box-shadow: inset 3px 0 0 var(--teal);
}

.prefix-button strong { display: block; overflow-wrap: anywhere; font-size: 13px; font-weight: 700; }
.prefix-button small  { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }

/* ── Stream state pill ─────────────────────────────────────────────────────── */
.stream-state { white-space: nowrap; }
.stream-state.live  { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.stream-state.info  { background: color-mix(in srgb, var(--blue)  14%, transparent); color: var(--blue); }
.stream-state.watch { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); }
.stream-state.error { background: color-mix(in srgb, var(--red)   14%, transparent); color: var(--red); }

/* ── Impact grid ───────────────────────────────────────────────────────────── */
.impact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.impact-grid article {
  min-height: 80px;
  padding: 12px 14px;
  background: var(--card-soft);
  transition: border-color 0.2s;
}

.impact-grid strong { display: block; margin-top: 7px; overflow-wrap: anywhere; font-size: 17px; font-weight: 800; }

.bad-text  { color: var(--red); }
.good-text { color: var(--green); }
.muted-text{ color: var(--muted); }

/* ── Event feed ────────────────────────────────────────────────────────────── */
.event-feed,
.action-list { display: grid; gap: 10px; }

.event-card {
  border: 1px solid var(--line);
  border-left: 4px solid rgba(129,140,248,0.3);
  border-radius: 10px;
  background: var(--surface);
  padding: 15px;
  transition: border-color 0.2s;
}

.event-card.good  { border-left-color: var(--green); }
.event-card.watch { border-left-color: var(--amber); }
.event-card.bad   { border-left-color: var(--red); }
.event-card.info  { border-left-color: var(--blue); }

.empty-card { border-left-color: rgba(129,140,248,0.2); }

.event-card h3 { margin: 10px 0 6px; font-size: 17px; font-weight: 800; line-height: 1.25; }
.event-card p  { margin: 0 0 10px; font-size: 14px; }

.event-topline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.event-next {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

/* ── Action items ──────────────────────────────────────────────────────────── */
.action-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px 14px;
  transition: border-color 0.15s;
}

.action-item:hover { border-color: var(--line-strong); }
.action-item strong { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 700; }
.action-item span   { color: var(--muted); font-size: 13px; line-height: 1.45; }

.empty-note { color: var(--muted); font-size: 13px; line-height: 1.4; }

/* ── Route report ──────────────────────────────────────────────────────────── */
.route-report { margin-bottom: 16px; }
.route-report:empty { display: none; }

.rr-loading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.rr-spinner {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: rr-spin 0.75s linear infinite;
}

@keyframes rr-spin { to { transform: rotate(360deg); } }

.rr-loading-text { display: flex; flex-direction: column; gap: 3px; }
.rr-loading-text strong { font-size: 14px; font-weight: 700; }
.rr-loading-text span   { font-size: 13px; color: var(--muted); }

.route-report.loaded {
  border: 1px solid var(--line);
  border-left: 4px solid rgba(129,140,248,0.3);
  border-radius: 10px;
  background: var(--surface);
  padding: 16px;
}

.route-report.loaded.good  { border-left-color: var(--green); }
.route-report.loaded.watch { border-left-color: var(--amber); }
.route-report.loaded.bad   { border-left-color: var(--red); }

.rr-header { margin-bottom: 12px; }

.rr-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.rr-label { color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }

.rr-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--chip-bg);
  color: var(--muted);
}

.rr-status.good  { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.rr-status.watch { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); }
.rr-status.bad   { background: color-mix(in srgb, var(--red)   14%, transparent); color: var(--red); }

.rr-meta { font-size: 12px; color: var(--muted); }

.rr-narrative { display: grid; gap: 8px; margin-bottom: 14px; }

.rr-part {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 14px;
  line-height: 1.55;
}

.rr-icon { flex-shrink: 0; font-size: 12px; margin-top: 2px; color: var(--muted); }

.rr-part.good  .rr-icon { color: var(--green); }
.rr-part.watch .rr-icon { color: var(--amber); }
.rr-part.bad   .rr-icon { color: var(--red); }
.rr-part.info  .rr-icon { color: var(--teal); }
.rr-part.bad   { font-weight: 500; }

.rr-upstreams { padding-top: 12px; border-top: 1px solid var(--line); }

.rr-sub-label { margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }

.upstream-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(70px, 180px) 44px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}

.upstream-id { display: flex; align-items: center; gap: 8px; min-width: 0; }

.upstream-id code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 11px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  flex-shrink: 0;
}

.upstream-id span {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upstream-bar-track {
  height: 5px;
  background: var(--surface-soft);
  border-radius: 3px;
  overflow: hidden;
}

.upstream-bar-fill {
  height: 100%;
  background: var(--line-strong);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.upstream-bar-fill.primary { background: var(--teal); opacity: 0.8; }
.upstream-count { font-size: 12px; color: var(--muted); text-align: right; }

.rr-error {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ── AS path display ───────────────────────────────────────────────────────── */
.event-path {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 4px;
  padding: 8px 10px;
  background: var(--surface-soft);
  border-radius: 7px;
  font-size: 13px;
}

.path-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; flex-shrink: 0; }

.path-hops { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; min-width: 0; }

.path-hop {
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  font-size: 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 6px;
}

.path-arrow   { color: var(--muted); font-size: 10px; user-select: none; }
.path-ellipsis{ color: var(--muted); font-size: 13px; padding: 0 2px; }

/* ── Quiet card ────────────────────────────────────────────────────────────── */
.quiet-card { border-left-color: var(--teal); }

.quiet-baseline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.quiet-row { display: flex; flex-direction: column; gap: 4px; }
.quiet-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.quiet-row strong { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }

/* ── Asset actions (Watch button) ──────────────────────────────────────────── */
.asset-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Scope toggle row (ASN Overview / Single Prefix) */
.scope-toggle-row {
  display: flex;
  gap: 3px;
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 3px;
}

.scope-mode-pill {
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.scope-mode-pill.active {
  background: var(--teal);
  color: #fff;
}

.scope-mode-pill:not(.active):hover { color: var(--ink); }

.btn-watch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(129,140,248,0.08);
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s, opacity 0.15s;
}

.btn-watch:hover { background: rgba(129,140,248,0.16); }

.btn-watch.in-watchlist {
  background: rgba(74,222,128,0.08);
  border-color: var(--green);
  color: var(--green);
}

.btn-ghost {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 14px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover { border-color: var(--red); color: var(--red); }

/* ── Prefix exports ─────────────────────────────────────────────────────────── */
.prefix-exports {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.prefix-exports button,
.report-exports button {
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 11px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: border-color 0.15s, color 0.15s;
}

.prefix-exports button:hover,
.report-exports button:hover { border-color: var(--teal); color: var(--ink); }

/* ── Report exports ─────────────────────────────────────────────────────────── */
.report-exports {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.report-exports button[id="export-report-pdf"] {
  border-color: rgba(129,140,248,0.35);
  color: var(--teal);
}

.report-exports button[id="export-report-pdf"]:hover {
  background: rgba(129,140,248,0.08);
  color: var(--teal);
}

/* ── Watchboard ─────────────────────────────────────────────────────────────── */
.watchboard {
  padding: 20px clamp(18px, 3vw, 42px);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
}

.watchboard-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

.watchboard-heading h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 800;
  margin: 0;
}

.watchboard-heading p { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

.watch-table {
  display: grid;
  gap: 8px;
}

.watch-row {
  display: grid;
  grid-template-columns: 12px minmax(220px, 1fr) minmax(130px, 200px) 110px minmax(180px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.2s;
}

.watch-row:hover { border-color: var(--line-strong); }

.watch-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
  transition: background 0.3s;
}

.watch-dot.quiet   { background: var(--green); box-shadow: 0 0 6px rgba(74,222,128,0.4); }
.watch-dot.watch   { background: var(--amber); box-shadow: 0 0 6px rgba(251,191,36,0.4); }
.watch-dot.bad     { background: var(--red);   box-shadow: 0 0 8px rgba(248,113,113,0.6); animation: watch-pulse 1.5s ease-in-out infinite; }
.watch-dot.connecting { background: var(--teal); opacity: 0.6; animation: watch-pulse 1s ease-in-out infinite; }

@keyframes watch-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.watch-info strong { display: block; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-info small  { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.watch-prefix {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watch-stream-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  background: var(--chip-bg);
  color: var(--muted);
}

.watch-stream-pill.live  { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.watch-stream-pill.error { background: color-mix(in srgb, var(--red)   14%, transparent); color: var(--red); }

.watch-event { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-event.bad   { color: var(--red); font-weight: 600; }
.watch-event.watch { color: var(--amber); font-weight: 600; }

.watch-actions { display: flex; gap: 6px; flex-shrink: 0; }

.watch-goto,
.watch-remove {
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  transition: border-color 0.15s, color 0.15s;
}

.watch-goto:hover  { border-color: var(--teal); color: var(--teal); }
.watch-remove:hover{ border-color: var(--red); color: var(--red); }

.watch-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}

/* ── Print / PDF styles ─────────────────────────────────────────────────────── */
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  body { background: #fff; color: #0f172a; font-size: 11pt; }

  .print-report-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    border-bottom: 2px solid #6366f1; padding-bottom: 12px; margin-bottom: 20px;
  }

  .print-report-header h1 { font-size: 22pt; font-weight: 900; color: #0f172a; margin: 0 0 4px; }
  .print-report-header p  { font-size: 9pt; color: #64748b; margin: 0; }
  .print-logo { font-size: 11pt; font-weight: 900; color: #6366f1; }

  .print-section { margin: 20px 0; page-break-inside: avoid; }
  .print-section h2 { font-size: 12pt; font-weight: 800; color: #6366f1; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #e2e8f0; padding-bottom: 6px; margin-bottom: 12px; }

  .print-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .print-cell { border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px; }
  .print-cell-label { font-size: 8pt; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
  .print-cell-value { font-size: 13pt; font-weight: 700; margin-top: 4px; }
  .print-cell-sub   { font-size: 9pt; color: #64748b; margin-top: 3px; }

  .print-row { display: flex; gap: 10px; align-items: baseline; margin: 6px 0; font-size: 10pt; line-height: 1.5; }
  .print-row-icon { width: 16px; flex-shrink: 0; font-weight: 700; }
  .print-row-icon.good  { color: #16a34a; }
  .print-row-icon.bad   { color: #dc2626; }
  .print-row-icon.watch { color: #d97706; }
  .print-row-icon.info  { color: #2563eb; }

  .print-event { border-left: 3px solid #94a3b8; border-radius: 4px; padding: 8px 10px; margin: 6px 0; page-break-inside: avoid; }
  .print-event.bad   { border-left-color: #dc2626; }
  .print-event.watch { border-left-color: #d97706; }
  .print-event.good  { border-left-color: #16a34a; }
  .print-event-title { font-size: 10pt; font-weight: 700; }
  .print-event-body  { font-size: 9pt; color: #475569; margin-top: 3px; }
  .print-event-next  { font-size: 9pt; color: #0f172a; font-weight: 600; margin-top: 5px; border-top: 1px solid #f1f5f9; padding-top: 5px; }

  .print-footer { margin-top: 32px; padding-top: 10px; border-top: 1px solid #e2e8f0; font-size: 8pt; color: #94a3b8; display: flex; justify-content: space-between; }

  .print-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .print-action-item { border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 10px; }
  .print-action-title { font-size: 9pt; font-weight: 700; }
  .print-action-body  { font-size: 8pt; color: #475569; margin-top: 2px; }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .workspace { grid-template-columns: minmax(240px, 300px) minmax(420px, 1fr); }
  .action-panel { grid-column: 1 / -1; }
  .action-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .replay-form { grid-template-columns: 1fr 1fr; }
  .scope-toggle { grid-template-columns: 1fr; }
  .replay-actions { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1100px) {
  .watch-row {
    grid-template-columns: 12px 1fr auto auto;
    grid-template-rows: auto auto;
  }
  .watch-prefix    { grid-column: 2; grid-row: 2; }
  .watch-stream-pill { grid-column: 3; grid-row: 1; }
  .watch-event     { display: none; }
}

@media (max-width: 860px) {
  .top-bar,
  .asset-strip,
  .replay-layout,
  .workspace { grid-template-columns: 1fr; }

  .nav-back    { display: none; }

  .replay-form    { grid-template-columns: 1fr; }
  .replay-heading { flex-direction: column; }

  .signal-grid,
  .impact-grid,
  .replay-cards { grid-template-columns: 1fr; }

  .prefix-list { max-height: 320px; }

  .lookup-row { grid-template-columns: 1fr; }
  .lookup-row button { min-height: 46px; }

  .action-list { grid-template-columns: 1fr; }

  .quiet-baseline { grid-template-columns: 1fr; }
}

/* ── Network Trends ─────────────────────────────────────────────────────────── */
.trends-section {
  padding: 2.5rem var(--page-px);
  border-top: 1px solid var(--line);
}

.trends-heading {
  margin-bottom: 1.5rem;
}

.trends-heading h2 {
  margin: 0.25rem 0 0.4rem;
  font-size: var(--fs-h2);
  font-weight: 800;
  letter-spacing: -0.4px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.trends-heading p {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--muted);
}

.scope-pill-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.scope-pill-badge.is-asn {
  color: var(--indigo);
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.25);
}

.scope-pill-badge.is-prefix {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 30%, transparent);
}

.trends-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1rem;
  align-items: start;
}

.trend-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-card);
}

.trend-card-title {
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* 24h / 7d toggle */
.trend-period-toggle {
  display: inline-flex;
  gap: 2px;
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 2px;
}

.trend-period-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  padding: 3px 9px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.trend-period-btn.active { background: var(--indigo); color: #fff; }
.trend-period-btn:not(.active):hover { color: var(--ink); }

/* Routing stats */
.routing-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.rstat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
}

.rstat-value {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 0.35rem;
  color: var(--ink);
}

.rstat-value.rpki-valid   { color: var(--green); }
.rstat-value.rpki-invalid { color: var(--red); }
.rstat-value.rpki-unknown { color: var(--amber); }

/* Canonical card field label — matches .signal-label / .intel-label */
.rstat-label {
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.rstat-sub {
  font-size: var(--fs-small);
  color: var(--muted);
  line-height: 1.4;
}

/* RPKI bar */
.rpki-bar-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 0.4rem;
}

.rpki-bar {
  display: flex;
  height: 8px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  gap: 2px;
  margin-bottom: 0.6rem;
}

.rpki-seg {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.rpki-seg.valid   { background: var(--green); }
.rpki-seg.invalid { background: var(--red); }
.rpki-seg.unknown { background: var(--amber); opacity: 0.6; }

.rpki-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.rpki-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.rpki-legend .dot.valid   { background: var(--green); }
.rpki-legend .dot.invalid { background: var(--red); }
.rpki-legend .dot.unknown { background: var(--amber); opacity: 0.7; }

.rstat-neighbours {
  font-size: 0.75rem;
  color: var(--muted);
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.rstat-neighbours strong { color: var(--subtext); }

/* BGP chart card */
.trend-chart-wrap {
  width: 100%;
  position: relative;
  overflow: hidden;
}

.trend-svg {
  width: 100%;
  height: 200px;
  display: block;
}

/* Hover tooltip */
.chart-tip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  min-width: 150px;
  background: #1a2032;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.45);
  font-size: var(--fs-small);
  color: var(--ink);
}

[data-theme="light"] .chart-tip { background: #ffffff; }

.chart-tip-time {
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 5px;
}

.chart-tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.6;
}

.ct-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.ct-dot.ct-ann { background: var(--indigo); }
.ct-dot.ct-wit { background: var(--red); }

.trend-legend {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--fs-small);
  color: var(--subtext);
  margin-top: 0.85rem;
}

.leg-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  margin-right: 2px;
  vertical-align: middle;
}

.leg-swatch.leg-ann { background: var(--indigo); }
.leg-swatch.leg-wit { background: var(--red); margin-left: 0.6rem; }

.trend-total {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--fs-small);
}

.trend-loading {
  font-size: var(--fs-body);
  color: var(--muted);
  padding: 2rem 0;
  text-align: center;
}

.trend-no-data {
  font-size: var(--fs-small);
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
  line-height: 1.6;
}

.trend-no-data a { color: var(--indigo); font-weight: 600; }

/* Inline spinner for loading states */
.trend-spin {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* Responsive */
@media (max-width: 860px) {
  .trends-grid { grid-template-columns: 1fr; }
}
