:root {
  --bg-canvas: #070b14;
  --bg-surface: #0d1424;
  --bg-elevated: #131c31;
  --bg-input: #09101d;
  --border-subtle: #1e293b;
  --border-strong: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent-teal: #14b8a6;
  --accent-cyan: #38bdf8;
  --accent-amber: #f59e0b;
  --status-allow: #10b981;
  --status-warn: #f59e0b;
  --status-block: #f43f5e;
  --ns-primary: #0f766e;
  --ns-accent: #1d4ed8;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 15% 0%, #0f1d35 0%, var(--bg-canvas) 52%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.num, code, pre {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.app-shell {
  max-width: 1260px;
  margin: 0 auto;
  padding: 20px 24px 56px;
}

/* Header */
.top-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background: rgba(13, 20, 36, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.badge-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  text-decoration: none;
}

.pill-teal {
  border-color: rgba(20, 184, 166, 0.45);
  background: rgba(15, 118, 110, 0.22);
  color: #5eead4;
}

.pill-cyan {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(3, 105, 161, 0.22);
  color: #7dd3fc;
}

.pill-amber {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(180, 83, 9, 0.22);
  color: #fcd34d;
}

/* BYOK Drawer */
.byok-drawer {
  margin-top: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 16px;
}

.byok-drawer summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-secondary);
  user-select: none;
}

.byok-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
  align-items: end;
}

.byok-note {
  margin: 8px 0 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Tabs */
.tab-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
  background: var(--bg-surface);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.14s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  background: var(--bg-elevated);
  color: #ffffff;
  border-color: rgba(45, 212, 191, 0.45);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.tab-btn .tab-kicker {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5eead4;
  margin-bottom: 2px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Cards & Grids */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: #f8fafc;
}

.card-desc {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px 16px;
}

.kpi-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  color: #ffffff;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* Forms & Buttons */
label.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 11px;
  font-family: var(--font-sans);
  font-size: 13px;
}

textarea {
  font-family: var(--font-mono);
  font-size: 12.5px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-teal);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.chip-btn:hover {
  border-color: var(--accent-teal);
  color: #ffffff;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn:hover {
  border-color: #64748b;
}

.btn-primary {
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
  border-color: #14b8a6;
  color: #ffffff;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

/* Verdict Banners */
.verdict-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--border-strong);
}

.verdict-ALLOW {
  background: rgba(16, 185, 129, 0.13);
  border-color: rgba(16, 185, 129, 0.5);
}

.verdict-WARN {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.55);
}

.verdict-BLOCK {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.55);
}

.verdict-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
}

.badge-ALLOW {
  background: #065f46;
  color: #6ee7b7;
}

.badge-WARN {
  background: #78350f;
  color: #fcd34d;
}

.badge-BLOCK {
  background: #881337;
  color: #fda4af;
}

/* Trace Timeline */
.trace-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trace-step {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-teal);
  border-radius: 8px;
  padding: 12px 14px;
}

.trace-step-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.trace-summary {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 4px 0 8px;
}

.code-details summary {
  cursor: pointer;
  font-size: 11.5px;
  color: #7dd3fc;
  font-family: var(--font-mono);
}

.json-box {
  background: #060a12;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 11.5px;
  line-height: 1.45;
  color: #cbd5e1;
  max-height: 260px;
  margin: 8px 0 0;
}

/* SVG Container */
.svg-stage {
  width: 100%;
  overflow-x: auto;
  background: #0b1120;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  padding: 6px;
}

.svg-stage svg {
  display: block;
  width: 100%;
  height: auto;
}

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

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

table.data-table th,
table.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

table.data-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.65);
}

table.data-table td.nowrap {
  white-space: nowrap;
}

table.data-table td.right,
table.data-table th.right {
  text-align: right;
}

.two-col {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
}

@media (max-width: 980px) {
  .tab-bar,
  .kpi-strip,
  .controls-grid,
  .two-col {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .tab-bar,
  .kpi-strip,
  .controls-grid,
  .two-col {
    grid-template-columns: 1fr;
  }
}
