:root {
  --bg: #0d1723;
  --bg-soft: #111b2d;
  --panel: rgba(18, 28, 44, 0.94);
  --panel-strong: rgba(20, 30, 50, 0.98);
  --panel-soft: rgba(24, 36, 58, 0.94);
  --text: #e5ebf7;
  --muted: #9db1cc;
  --line: rgba(156, 179, 215, 0.16);
  --green: #7dd3a0;
  --gold: #c5a56d;
  --red: #f16e6e;
  --yellow: #d9bc6c;
  --cyan: #7dd3fc;
  --blue: #8ba9ff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
  --glow: 0 0 0 1px rgba(125, 211, 240, 0.1), 0 18px 48px rgba(0, 0, 0, 0.24);
}

body[data-theme="light"] {
  --bg: #edf2f8;
  --bg-soft: #f8fbff;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.97);
  --panel-soft: rgba(246, 249, 252, 0.96);
  --text: #132538;
  --muted: #5f7287;
  --line: rgba(20, 37, 56, 0.11);
  --shadow: 0 20px 50px rgba(35, 57, 81, 0.12);
  --glow: 0 0 0 1px rgba(134, 168, 255, 0.08), 0 18px 40px rgba(35, 57, 81, 0.1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  font-family: "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(122, 216, 246, 0.08), transparent 26%),
    radial-gradient(circle at top left, rgba(121, 240, 167, 0.08), transparent 22%),
    linear-gradient(180deg, var(--bg-soft), var(--bg));
  color: var(--text);
}

body.compact { font-size: 14px; }
body.high-contrast { --line: rgba(255, 255, 255, 0.34); --muted: #c9d5e1; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

button, input, select, textarea { font: inherit; }

.splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 20px;
  z-index: 999;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(121, 240, 167, 0.12), transparent 26%),
    radial-gradient(circle at center, rgba(122, 216, 246, 0.08), transparent 34%),
    linear-gradient(180deg, #050b11, #04070d);
}

.splash-orbit {
  position: absolute;
  inset: 50%;
  width: min(54vw, 520px);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  border: 1px solid rgba(122, 216, 246, 0.16);
  box-shadow:
    0 0 0 24px rgba(122, 216, 246, 0.02),
    0 0 0 56px rgba(121, 240, 167, 0.02);
}

.splash-rune {
  font-size: 78px;
  color: var(--green);
  text-shadow: 0 0 24px rgba(121, 240, 167, 0.36);
  animation: pulse 1.35s ease-in-out infinite;
}

.splash-logo {
  width: min(112px, 24vw);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 10px 30px rgba(122, 216, 246, 0.24));
  animation: pulse 1.35s ease-in-out infinite;
}

.splash-copy {
  text-align: left;
  max-width: 440px;
  position: relative;
}

.splash-copy h1 { margin: 0 0 10px; font-size: 28px; letter-spacing: 0.12em; }
.splash-copy p, .splash-copy strong { display: block; margin: 6px 0; color: #b7c6d7; }

.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1200;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.toast.error { border-color: rgba(255, 133, 133, 0.35); }
.toast.success { border-color: rgba(121, 240, 167, 0.28); }

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(5, 10, 16, 0.82);
  backdrop-filter: blur(16px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
}

.sidebar-top, .sidebar-middle, .sidebar-controls {
  display: grid;
  gap: 14px;
  align-content: start;
}

.sidebar-top {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(5, 10, 16, 0.92), rgba(5, 10, 16, 0.82));
  padding-top: 4px;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(122, 216, 246, 0.05), rgba(121, 240, 167, 0.05));
  box-shadow: var(--glow);
}

.brand-rune {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(121, 240, 167, 0.14), rgba(215, 183, 119, 0.12));
  border: 1px solid var(--line);
  font-size: 24px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(121, 240, 167, 0.12), rgba(215, 183, 119, 0.1));
  padding: 8px;
  box-shadow: var(--glow);
}

.console-block, .sidebar-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--glow);
}

.console-head, .signal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.console-note {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.9rem;
}

.mini-pill {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-nav, .sidebar-controls { display: grid; gap: 10px; }

.nav-item, .toggle-btn, .primary-btn, select, input, textarea, button {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.nav-item, .toggle-btn, .primary-btn, button {
  cursor: pointer;
  padding: 12px 14px;
}

.nav-item {
  text-align: left;
}

.nav-item.active, .primary-btn {
  background: linear-gradient(145deg, rgba(121, 240, 167, 0.13), rgba(122, 216, 246, 0.13));
}

.toggle-btn:hover, .nav-item:hover, .primary-btn:hover, .table-action:hover {
  border-color: rgba(122, 216, 246, 0.34);
}

.sidebar-controls label {
  display: grid;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.signal-list, .mini-stack {
  display: grid;
  gap: 10px;
}

.signal-row strong, .mini-stack strong {
  font-size: 1rem;
}

.mini-stack-item {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 4px;
}

.mini-stack-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.content {
  padding: 22px;
  display: grid;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.topbar, .panel, .metric, .inline-note, .table-wrap {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 22px;
  position: sticky;
  top: 0;
  z-index: 3;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(14, 22, 36, 0.95);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,0.05), 0 24px 48px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(20px);
}

.topbar-note {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-top: 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 0.92rem;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.72rem;
}

.topbar h2, .panel h3 { margin: 0; }

.topbar-copy {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 720px;
  line-height: 1.55;
}

.topbar-actions {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.topbar-status, .topbar-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill, .clock-pill {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
}

.status-pill.healthy { color: var(--green); }
.status-pill.degraded { color: var(--yellow); }
.status-pill.critical { color: var(--red); }

.view { display: none; gap: 18px; }
.view.active { display: grid; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 18px;
}

.metric {
  padding: 22px;
  display: grid;
  gap: 12px;
  min-height: 170px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 18px 40px rgba(0, 0, 0, 0.14);
}

.metric span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

.metric strong {
  font-size: clamp(2rem, 2.7vw, 2.6rem);
  line-height: 1;
}

.metric small {
  color: var(--muted);
  line-height: 1.6;
}

.grid { display: grid; gap: 16px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-col { grid-template-columns: 1.05fr 1fr 1fr; }

.section-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.summary-card {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02), 0 12px 24px rgba(0, 0, 0, 0.08);
}

.summary-card .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.summary-card strong {
  font-size: 1.55rem;
}

.summary-card small {
  color: var(--muted);
  line-height: 1.5;
}

.panel {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.panel-head {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.panel-head.compact h3 { font-size: 1rem; }

.stack, .status-summary {
  display: grid;
  gap: 12px;
}

.stack-item, .summary-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  display: grid;
  gap: 7px;
}

.stack-item .row, .summary-card .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.stack-item small, .summary-card small {
  color: var(--muted);
  line-height: 1.5;
}

.event-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.timeline-bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  min-height: 260px;
}

.timeline-bar {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.timeline-bar-fill {
  width: 100%;
  min-height: 12px;
  border-radius: 14px 14px 5px 5px;
  background: linear-gradient(180deg, rgba(134, 168, 255, 0.98), rgba(122, 216, 246, 0.8), rgba(121, 240, 167, 0.6));
  border: 1px solid rgba(122, 216, 246, 0.26);
  box-shadow: 0 10px 22px rgba(122, 216, 246, 0.13);
}

.timeline-bar strong { font-size: 0.85rem; }
.timeline-bar span { color: var(--muted); font-size: 0.72rem; }

.table-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

.table-wrap {
  overflow: auto;
  padding: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 18px 36px rgba(0,0,0,0.08);
}

.sidebar, .content {
  scrollbar-width: thin;
  scrollbar-color: rgba(121, 240, 167, 0.24) transparent;
}

.sidebar::-webkit-scrollbar, .content::-webkit-scrollbar, .table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.sidebar::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(121, 240, 167, 0.22);
  border-radius: 999px;
}

.sidebar::-webkit-scrollbar-track,
.content::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  padding: 16px 18px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  background: rgba(255,255,255,0.02);
}

tbody tr {
  transition: background 0.18s ease, transform 0.18s ease;
}

tbody tr:hover {
  background: rgba(255,255,255,0.04);
  transform: translateX(2px);
}

.table-action {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-weight: 600;
}

.table-action:hover {
  background: rgba(255,255,255,0.08);
}

input, textarea, select {
  width: 100%;
  padding: 12px 14px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.ingest-form {
  display: grid;
  gap: 12px;
}

.preset-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preset-btn, .table-action {
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
}

.inline-note {
  padding: 14px 16px;
  color: var(--muted);
  min-height: 52px;
}

.json-card {
  margin: 0;
  padding: 0;
  white-space: pre-wrap;
  color: var(--muted);
  line-height: 1.6;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge.critical { background: rgba(241, 110, 110, 0.16); color: var(--red); }
.badge.high { background: rgba(217, 188, 108, 0.16); color: var(--yellow); }
.badge.medium { background: rgba(122, 211, 246, 0.18); color: var(--cyan); }
.badge.low { background: rgba(121, 243, 167, 0.14); color: var(--green); }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.05); opacity: 1; }
}

@media (max-width: 1240px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-rows: auto;
  }
  .three-col, .two-col, .metric-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .content, .sidebar { padding: 16px; }
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar-actions { justify-items: stretch; }
  .topbar-tools, .topbar-status { justify-content: flex-start; }
  .timeline-bars { grid-template-columns: repeat(6, minmax(0, 1fr)); min-height: 220px; }
  .toast-stack { left: 16px; right: 16px; width: auto; }
}
