:root {
  --bg: #0b0a09;
  --surface: #16130f;
  --surface-2: #1c1814;
  --surface-3: #24201a;
  --border: #2b251e;
  --border-strong: #3a3226;
  --text: #f5ede0;
  --text-2: #c5b9a4;
  --text-muted: #7a6f5e;
  --on-air: #ff4422;
  --ember: #e87a2c;
  --amber: #f59e0b;
  --ok: #84cc16;
  --warn: #eab308;
  --err: #ef4444;
  --steel: #8aa0b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body {
  font-family: "Geist", -apple-system, system-ui, sans-serif;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  src: local("Instrument Serif Italic");
}
a { color: var(--ember); text-decoration: none; }
a:hover { color: var(--amber); }
code, .mono { font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ====== Layout ====== */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand {
  display: flex; align-items: baseline; gap: 6px;
  padding: 0 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.brand-mark {
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-size: 30px;
  line-height: 1;
}
.brand-mark::first-letter { color: var(--on-air); }
.brand-tag {
  font-family: "Geist Mono", monospace;
  font-size: 9px; letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.nav-section {
  font-family: "Geist Mono", monospace;
  font-size: 10px; letter-spacing: 0.18em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 16px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13.5px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.sidebar-footer .user { color: var(--text); padding: 4px 8px; }
.sidebar-footer form button {
  background: none; border: none; color: var(--text-muted);
  font: inherit; padding: 4px 8px; cursor: pointer;
}
.sidebar-footer form button:hover { color: var(--err); }

.main { padding: 28px 32px 40px; max-width: 1400px; width: 100%; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400; font-style: italic;
  font-size: 34px; line-height: 1.1;
  letter-spacing: -0.01em;
}
.page-header p { color: var(--text-muted); font-size: 13px; margin-top: 6px; }

/* ====== Cards ====== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.card h2 {
  font-family: "Geist Mono", monospace;
  font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
  font-weight: 500;
}

/* ====== Stat tiles ====== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.stat .label { font-family: "Geist Mono", monospace; font-size: 10px; letter-spacing: 0.18em; color: var(--text-muted); text-transform: uppercase; }
.stat .value { font-family: "Instrument Serif", Georgia, serif; font-style: italic; font-size: 36px; line-height: 1; margin-top: 8px; letter-spacing: -0.02em; }
.stat .value .unit { font-family: "Geist Mono", monospace; font-style: normal; font-size: 12px; color: var(--text-muted); margin-left: 4px; }
.stat .sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ====== Tables ====== */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  font-family: "Geist Mono", monospace;
  font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
table.data td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(255, 255, 255, 0.015); }
table.data td.mono { font-family: "Geist Mono", monospace; font-size: 12px; }
table.data td .muted { color: var(--text-muted); }

/* ====== Status pills ====== */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: "Geist Mono", monospace;
  font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--border);
}
.pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
}
.pill-running { color: #c8ff9b; border-color: rgba(132,204,22,0.3); background: rgba(132,204,22,0.08); }
.pill-running::before { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.pill-stopped { color: var(--text-muted); }
.pill-failed, .pill-destroyed { color: #ffb4b4; border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.08); }
.pill-failed::before, .pill-destroyed::before { background: var(--err); }
.pill-suspended, .pill-provisioning { color: #ffd99e; border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.08); }
.pill-suspended::before, .pill-provisioning::before { background: var(--amber); }

/* ====== Buttons ====== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  font: inherit; font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--border-strong); color: var(--text); }
.btn-primary { background: var(--ember); border-color: var(--ember); color: #0a0907; font-weight: 500; }
.btn-primary:hover { background: var(--amber); border-color: var(--amber); color: #0a0907; }
.btn-danger { color: #ffb4b4; border-color: rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.1); color: #fff; border-color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.actions-row { display: flex; gap: 8px; align-items: center; }
.actions-row form { display: inline; }

/* ====== Forms ====== */
.form { max-width: 640px; }
.form-group { margin-bottom: 18px; }
.form label {
  display: block;
  font-family: "Geist Mono", monospace;
  font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=number], .form textarea, .form select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit; font-size: 14px;
}
.form input:focus, .form textarea:focus, .form select:focus {
  outline: none; border-color: var(--ember);
  box-shadow: 0 0 0 3px rgba(232,122,44,0.15);
}
.form textarea { min-height: 90px; resize: vertical; }
.form .checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.form .checkbox input { width: auto; }
.form .help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form .actions { display: flex; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ====== Flashes ====== */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.flash-success { background: rgba(132,204,22,0.08); border-color: rgba(132,204,22,0.25); color: #d3f5a4; }
.flash-error   { background: rgba(239,68,68,0.08);  border-color: rgba(239,68,68,0.3);   color: #ffb4b4; }
.flash-info    { background: rgba(138,160,184,0.08);border-color: rgba(138,160,184,0.3); color: var(--steel); }

/* ====== Auth layout ====== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.auth-card .brand { border: none; margin-bottom: 24px; padding-bottom: 0; justify-content: center; }
.auth-card h1 { font-family: "Instrument Serif", Georgia, serif; font-style: italic; font-size: 26px; margin-bottom: 4px; text-align: center; font-weight: 400; }
.auth-card p.sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }

/* ====== Grain overlay for that analog warmth ====== */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.96  0 0 0 0 0.93  0 0 0 0 0.88  0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.4; mix-blend-mode: overlay;
}

/* ====== Two-column page ====== */
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

/* ====== Audit log ====== */
.audit-item {
  display: grid; grid-template-columns: 80px 1fr auto;
  gap: 12px; padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
  align-items: baseline;
}
.audit-item:last-child { border-bottom: none; }
.audit-item .time { color: var(--text-muted); font-family: "Geist Mono", monospace; font-size: 11px; }
.audit-item .actor { color: var(--text-muted); font-size: 11.5px; }
.audit-item .action { font-family: "Geist Mono", monospace; font-size: 11.5px; color: var(--ember); }

/* Empty states */
.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
.empty p { margin-bottom: 16px; }

/* ====== Toolbar above tables ====== */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.toolbar .search { flex: 1; max-width: 320px; }
.toolbar .search input { width: 100%; padding: 7px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font: inherit; font-size: 13px; }

/* ====== Code blocks & key/value pairs ====== */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--text-muted); font-family: "Geist Mono", monospace; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; padding-top: 2px; }
.kv dd { color: var(--text); font-family: "Geist Mono", monospace; font-size: 12.5px; word-break: break-all; }
.kv dd .secret { filter: blur(4px); transition: filter 0.15s; cursor: pointer; }
.kv dd .secret:hover, .kv dd .secret:focus { filter: none; }

/* Tabs strip (used on station sub-pages) */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}
.tab {
  padding: 10px 16px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-family: "Geist Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-2); }
.tab.active {
  color: var(--ember);
  border-bottom-color: var(--ember);
}
