:root {
  --bg: #0b1020;
  --panel: #131a2e;
  --panel-alt: #18213b;
  --border: #253252;
  --text: #e6edf7;
  --muted: #8fa0c2;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --cyan: #22d3ee;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(19, 26, 46, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo-badge {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #fff;
}
.topbar h1 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.tag {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: rgba(59, 130, 246, 0.18); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.35);
}
.subtitle { font-size: 12px; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 12px; }
.status-pill {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 600;
}
.status-pill.loading { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.status-pill.ready { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; }
.status-pill.error { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }

.layout {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 16px;
  padding: 16px 24px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.controls h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--cyan); margin-bottom: 12px;
}

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field select, .field input[type="number"], .field input[type="text"] {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel-alt);
  color: var(--text); font-size: 13px;
}
.mono-input { font-family: ui-monospace, Consolas, monospace; font-size: 12px !important; }
.ri-row { cursor: pointer; transition: 0.12s; }
.ri-row:hover { background: rgba(59, 130, 246, 0.16); }

.slider-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.slider-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 2px; }
.slider-head span { color: var(--muted); }
.slider-head strong { color: var(--text); font-family: ui-monospace, Consolas, monospace; }
input[type="range"] { width: 100%; accent-color: var(--primary); cursor: pointer; }

.checkbox-row {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); cursor: pointer;
}

.divider { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.inline-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  border: 0; border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: 0.15s ease; color: #fff;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-accent { background: #059669; }
.btn-accent:hover:not(:disabled) { background: #047857; }
.btn-secondary { background: var(--panel-alt); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.full-width { width: 100%; }

.mini-note {
  margin-top: 8px; font-size: 12px; color: #a7f3d0; min-height: 18px;
  font-family: ui-monospace, Consolas, monospace;
}

.workspace { display: flex; flex-direction: column; gap: 16px; }

.kpi-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
}
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 700; font-family: ui-monospace, Consolas, monospace; color: #fff; }
.kpi-sub { font-size: 11px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .charts-row { grid-template-columns: 1fr; } }

.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h3 { font-size: 14px; font-weight: 600; }
.chip {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--cyan);
  font-family: ui-monospace, Consolas, monospace;
}

canvas {
  width: 100%; height: 220px; display: block;
  background: #0d1426; border-radius: 8px; border: 1px solid #1e2a45;
}

.sens-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
}
.sens-table th, .sens-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: right;
}
.sens-table th:first-child, .sens-table td:first-child { text-align: left; }
.sens-table th { color: var(--muted); font-weight: 600; }
.pos { color: #34d399; }
.neg { color: #f87171; }

.spice-panel pre {
  max-height: 200px; overflow: auto; background: #090e1c; padding: 12px;
  border-radius: 8px; border: 1px solid var(--border); font-size: 12px;
  color: #cbd5e1; font-family: ui-monospace, Consolas, monospace;
}

.footer {
  display: flex; justify-content: space-between; padding: 14px 24px;
  border-top: 1px solid var(--border); color: var(--muted); font-size: 12px;
}
