:root {
  --bg:        #071016;
  --surface:   #0d1b26;
  --surface2:  #112030;
  --border:    #1d4054;
  --border2:   #2a5870;
  --text:      #e9f7ff;
  --muted:     #7ab8d4;
  --accent:    #38bdf8;
  --success:   #4ade80;
  --warn:      #fbbf24;
  --danger:    #f87171;
  --code-bg:   #10202d;
  --radius:    10px;
  --shadow:    0 2px 16px rgba(0,0,0,.5);
}

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-logo { font-weight: 700; font-size: 17px; color: var(--accent); letter-spacing: -.3px; }
.topbar-logo span { color: var(--muted); font-weight: 400; }
.topbar-spacer { flex: 1; }
.topbar-user { font-size: 13px; color: var(--muted); }
.topbar-link { font-size: 13px; }

.layout { display: flex; height: calc(100vh - 52px); }

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0;
}
.sidebar-section { padding: 6px 16px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
.sidebar-item:hover { background: var(--surface2); color: var(--text); }
.sidebar-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--surface2); }

/* ── Main content ──────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.page { display: none; flex: 1; flex-direction: column; }
.page.active { display: flex; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

/* ── Form controls ─────────────────────────────────────── */
input[type=text], input[type=search], input[type=password], input[type=date],
textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}
input[type=text]:focus, input[type=search]:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: opacity .15s;
  background: var(--accent);
  color: #071016;
}
.btn:hover { opacity: .85; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 4px 11px; font-size: 13px; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #071016; }
.btn-warn { background: var(--warn); color: #071016; }

/* ── Tabs ──────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color .12s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Table ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 12px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--border); }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-green { background: #14532d; color: var(--success); }
.badge-red   { background: #450a0a; color: var(--danger); }
.badge-yellow{ background: #451a03; color: var(--warn); }
.badge-blue  { background: #0c2340; color: var(--accent); }
.badge-gray  { background: var(--surface2); color: var(--muted); }

/* ── Tags ──────────────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--code-bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ── Spinner ───────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Notice / empty state ──────────────────────────────── */
.notice {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 14px;
}
.notice-title { font-size: 18px; color: var(--text); margin-bottom: 6px; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 480px;
  max-width: 95vw;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ── Code block ────────────────────────────────────────── */
pre, code {
  font-family: 'Fira Mono', 'Cascadia Code', ui-monospace, monospace;
  font-size: 12.5px;
  background: var(--code-bg);
  border-radius: 5px;
}
code { padding: 1px 5px; }
pre { padding: 14px 16px; overflow-x: auto; border: 1px solid var(--border); line-height: 1.6; }
pre mark { background: #0f3a5a; color: inherit; border-radius: 2px; }

/* ── Confidence bar ────────────────────────────────────── */
.conf-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 4px; }
.conf-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--warn), var(--success)); transition: width .4s; }

/* ── Misc ──────────────────────────────────────────────── */
.sep { height: 1px; background: var(--border); margin: 14px 0; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.ml-auto { margin-left: auto; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.p-16 { padding: 16px; }
.p-20 { padding: 20px; }
.text-muted { color: var(--muted); font-size: 13px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-mono { font-family: 'Fira Mono', ui-monospace, monospace; font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
