:root {
  --bg: #0f172a;
  --panel: #111c33;
  --panel-2: #18243f;
  --line: #243454;
  --text: #e5eefc;
  --muted: #95a4bf;
  --accent: #4f8cff;
  --danger: #ff6b6b;
  --ok: #4ade80;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea {
  font: inherit;
}
button {
  border: 1px solid var(--line);
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}
button.ghost {
  background: transparent;
}
input, textarea {
  width: 100%;
  margin-top: 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
}
.topbar, .tabs, .grid {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar h1 { margin: 0; font-size: 22px; }
.active-page {
  margin-top: 6px;
  color: #dbeafe;
  font-size: 14px;
  font-weight: 600;
}
.muted { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 8px; padding-top: 0; }
.tab {
  background: var(--panel);
}
.tab.active { background: var(--accent); }
.grid { display: grid; gap: 16px; }
.panel {
  background: rgba(17, 28, 51, 0.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.hidden { display: none; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.cards.small { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.value { font-size: 22px; margin-top: 6px; font-weight: 700; }
.control-row, .toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.form-grid {
  display: grid;
  gap: 12px;
}
.section-title {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: #bfdbfe;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.table-wrap, .list {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}
th { color: var(--muted); font-size: 12px; }
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.row-actions button {
  padding: 6px 10px;
  font-size: 12px;
}
.row-actions .danger {
  background: transparent;
  border-color: var(--danger);
  color: #ffd3d3;
}
.result {
  padding: 10px 12px;
  min-height: 24px;
  color: var(--muted);
}
.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  min-width: 260px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(17, 28, 51, 0.96);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.toast.ok { border-color: rgba(74, 222, 128, .35); }
.toast.err { border-color: rgba(255, 107, 107, .35); }
.toast.info { border-color: rgba(79, 140, 255, .35); }
.toast .title { font-weight: 700; margin-bottom: 4px; }
.toast .body { color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.item {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.item:last-child { border-bottom: 0; }
.mono, code, pre { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace; }
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 18, .88);
  z-index: 50;
}
.login-box {
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}
.login-box h1 { margin: 0 0 8px; }
.login-box form { display: grid; gap: 12px; }
.login-box button { width: 100%; }
