:root {
  --bg: #131318;
  --surface: #1f1f24;
  --surface-low: #1b1b20;
  --surface-high: #2a292f;
  --surface-highest: #35343a;
  --text: #e4e1e9;
  --muted: #b9cacb;
  --primary: #00dbe9;
  --primary-bright: #00f0ff;
  --outline: #3b494b;
  --error: #ffb4ab;
  --ok: #7df4ff;
  --warn: #ffb74d;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-bright); }
code, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

.admin-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--outline);
  background: var(--surface-low);
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand h1 {
  margin: 0; font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em;
}
.badge {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem; border-radius: 999px;
  background: rgba(0, 219, 233, 0.15); color: var(--primary-bright);
  border: 1px solid rgba(0, 219, 233, 0.35);
}
.topbar-meta { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.85rem; }
.btn {
  appearance: none; border: 1px solid var(--outline); background: var(--surface-high);
  color: var(--text); border-radius: 6px; padding: 0.4rem 0.8rem; cursor: pointer;
  font: inherit; font-size: 0.85rem;
}
.btn:hover { border-color: var(--primary); }

.tabnav {
  display: flex; gap: 0.35rem; flex-wrap: wrap;
  padding: 0.55rem 1.25rem;
  border-bottom: 1px solid var(--outline);
  background: #16161b;
}
.tabnav a {
  color: var(--muted); padding: 0.45rem 0.85rem; border-radius: 8px;
  font-size: 0.9rem; font-weight: 500;
}
.tabnav a:hover { color: var(--text); background: var(--surface); }
.tabnav a.active {
  color: var(--primary-bright);
  background: rgba(0, 219, 233, 0.12);
}

.content { flex: 1; padding: 1.25rem; }
.content.bleed { padding: 0; display: flex; flex-direction: column; min-height: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 10px;
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}
.panel h2 {
  margin: 0 0 0.75rem; font-size: 1rem; font-weight: 600; color: var(--primary);
}
.muted { color: var(--muted); }
.error { color: var(--error); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

table.status, table.logs { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.status th, table.status td,
table.logs th, table.logs td {
  text-align: left; padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--outline);
  vertical-align: top;
}
table.status th { width: 36%; color: var(--muted); font-weight: 500; }
table.logs th { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
table.logs tr.bad td { color: var(--error); }
table.logs tr.slow td { color: var(--warn); }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(900px 500px at 15% -10%, #1b2a2c 0%, var(--bg) 55%);
}
.login-card { width: min(420px, 92vw); text-align: center; }
.login-card h1 { margin: 0 0 0.35rem; }
#auth-error { min-height: 1.25rem; margin-top: 1rem; }

/* Arch map */
.arch-layout { display: flex; flex: 1; min-height: calc(100vh - 110px); position: relative; }
.arch-canvas-wrap { flex: 1; position: relative; background: #0e0e13; min-height: 520px; }
.arch-toolbar {
  position: absolute; z-index: 5; top: 0.85rem; left: 0.85rem; right: 0.85rem;
  display: flex; gap: 0.65rem; flex-wrap: wrap; align-items: center; pointer-events: none;
}
.arch-toolbar > * { pointer-events: auto; }
.arch-toolbar input {
  flex: 1; min-width: 180px; max-width: 360px;
  background: var(--surface); border: 1px solid var(--outline); color: var(--text);
  border-radius: 8px; padding: 0.5rem 0.75rem; font: inherit;
}
.arch-meta {
  font-size: 0.75rem; color: var(--muted);
  background: rgba(31,31,36,0.9); border: 1px solid var(--outline);
  border-radius: 999px; padding: 0.3rem 0.65rem;
}
#arch-svg-host { width: 100%; height: 100%; min-height: 520px; }
.arch-legend {
  position: absolute; z-index: 5; left: 0.85rem; bottom: 0.85rem;
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  background: rgba(31,31,36,0.92); border: 1px solid var(--outline);
  border-radius: 10px; padding: 0.55rem 0.7rem; max-width: min(520px, 90%);
}
.legend-item { display: flex; align-items: center; gap: 0.3rem; font-size: 0.7rem; color: var(--muted); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

.drawer {
  width: min(360px, 100%);
  border-left: 1px solid var(--outline);
  background: var(--surface-low);
  padding: 1rem;
  overflow: auto;
  display: none;
}
.drawer.open { display: block; }
.drawer h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.drawer .cat {
  font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.drawer-tabs { display: flex; gap: 0.35rem; margin: 0.85rem 0; }
.drawer-tabs button {
  flex: 1; border: 1px solid var(--outline); background: transparent; color: var(--muted);
  border-radius: 6px; padding: 0.35rem; cursor: pointer; font: inherit; font-size: 0.8rem;
}
.drawer-tabs button.active { color: var(--primary-bright); border-color: var(--primary); background: rgba(0,219,233,0.08); }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
.chip {
  font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 999px;
  border: 1px solid var(--outline); color: var(--primary); cursor: pointer; background: transparent;
}
.files dt { margin-top: 0.5rem; color: var(--text); font-size: 0.8rem; }
.files dd { margin: 0.15rem 0 0 0.6rem; font-size: 0.75rem; color: var(--muted); }
.drawer-close {
  float: right; border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 1.2rem;
}

.empty { color: var(--muted); padding: 1rem 0; }
.refresh-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
@media (max-width: 800px) {
  .arch-layout { flex-direction: column; }
  .drawer { width: 100%; border-left: none; border-top: 1px solid var(--outline); max-height: 40vh; }
}
