:root {
  --bg: #0b0f17;
  --bg-card: #121824;
  --bg-elev: #192233;
  --border: #253147;
  --text: #e6edf7;
  --muted: #8ea0b8;
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}
code { font-family: var(--mono); background: rgba(56, 189, 248, 0.12); padding: 1px 5px; border-radius: 4px; color: #7dd3fc; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.7);
}
.brand h1 { font-size: 17px; font-weight: 700; }
.subtitle { font-size: 12px; color: var(--muted); }

.status-badges, .header-actions, .inline-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg-elev);
}
.badge-ok { color: #86efac; border-color: rgba(34, 197, 94, 0.45); background: rgba(34, 197, 94, 0.12); }
.badge-warn { color: #fde68a; border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.12); }
.badge-err { color: #fca5a5; border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.12); }
.badge-info { color: #93c5fd; border-color: rgba(56, 189, 248, 0.45); background: rgba(56, 189, 248, 0.12); }
.badge-muted { color: var(--muted); }

.btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 13px; transition: 0.15s ease;
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #05131f; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-elev); }
.btn-outline.active { border-color: var(--green); color: #86efac; background: rgba(34, 197, 94, 0.12); }
.btn-danger { background: rgba(239, 68, 68, 0.18); color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tabs {
  display: flex; gap: 4px; padding: 10px 24px 0; background: var(--bg-card);
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  padding: 10px 16px; font-weight: 600; font-size: 13px; border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.container { max-width: 1440px; margin: 0 auto; padding: 20px 24px 48px; }
.tab-panel { display: none; flex-direction: column; gap: 18px; }
.tab-panel.active { display: flex; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
}
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 24px; font-weight: 700; margin: 6px 0 4px; }
.kpi-sub { font-size: 12px; color: var(--muted); }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.card-header h2 { font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); font-size: 12px; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.chart-box { width: 100%; min-height: 220px; display: flex; align-items: center; justify-content: center; }
.chart-box svg { width: 100%; height: auto; display: block; }

.terminal {
  background: #070a10; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; height: 240px; overflow-y: auto; font-family: var(--mono);
  font-size: 12px; line-height: 1.5; white-space: pre-wrap; color: #cbd5e1;
}
.term-think { color: #a78bfa; }
.term-tool { color: #38bdf8; }
.term-ok { color: #4ade80; }
.term-err { color: #f87171; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.decision-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
}
.decision-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.decision-title { font-size: 15px; font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details { margin-top: 8px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 12px; }
.pre-box {
  margin-top: 8px; white-space: pre-wrap; font-family: var(--mono); font-size: 12px;
  color: #cbd5e1; max-height: 280px; overflow-y: auto;
}

.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.note-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.note-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }

.input, .input-sm, textarea, select {
  background: #0a0f18; color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-family: var(--font); font-size: 13px; width: 100%;
}
.input-sm { width: auto; padding: 5px 9px; font-size: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.form-row { display: flex; gap: 10px; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }

.banner {
  background: rgba(56, 189, 248, 0.08); border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px;
}
.hidden { display: none; }
.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.reset-zone { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.ref-item { padding: 10px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; }
.corr-cell { text-align: center; font-family: var(--mono); font-size: 11px; min-width: 48px; }
