/* Admin dashboard — "Liquid Glass" theme. Solid white/black backgrounds, frosted translucent
   panels (sidebar, topbar, panels, tables, modals, toasts), indigo-violet accent. Token-driven;
   data-theme dark/light. Desktop sidebar collapses to a drawer ≤820px. */
:root[data-theme='dark'] {
  --bg: #000000;
  --bg-2: rgba(22, 22, 28, 0.62);     /* sidebar/topbar glass bars */
  --panel: rgba(255, 255, 255, 0.055);
  --panel-2: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f3f4f8;
  --fg: #f3f4f8;
  --muted: #9aa3b8;
  --accent: #8a7dff;
  --accent-2: #7466ff;
  --accent-soft: rgba(138, 125, 255, 0.16);
  --info: #8a7dff;
  --warning: #f0a020;
  --critical: #ff6b6b;
  --good: #34c759;
  --glass-border: rgba(255, 255, 255, 0.12);
  --hi: rgba(255, 255, 255, 0.10);
  --blur: saturate(1.6) blur(16px);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  --elev: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 28px rgba(0, 0, 0, 0.5);
}
:root[data-theme='light'] {
  --bg: #ffffff;
  --bg-2: rgba(255, 255, 255, 0.72);
  --panel: rgba(255, 255, 255, 0.66);
  --panel-2: rgba(20, 18, 45, 0.045);
  --border: rgba(20, 18, 45, 0.10);
  --text: #15172b;
  --fg: #15172b;
  --muted: #5b6275;
  --accent: #5b50f0;
  --accent-2: #4a3fe0;
  --accent-soft: rgba(91, 80, 240, 0.10);
  --info: #5b50f0;
  --warning: #b45309;
  --critical: #dc2626;
  --good: #16a34a;
  --glass-border: rgba(20, 18, 45, 0.08);
  --hi: rgba(255, 255, 255, 0.65);
  --blur: saturate(1.6) blur(16px);
  --shadow: 0 10px 40px rgba(20, 30, 60, 0.16);
  --elev: 0 1px 2px rgba(16, 18, 40, 0.06), 0 6px 20px rgba(16, 18, 40, 0.07);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  letter-spacing: -0.005em;
}

#app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }

/* ---- bold SVG icons ---- */
.ic { display: inline-flex; align-items: center; justify-content: center; width: 1.15em; height: 1.15em;
  vertical-align: -0.2em; flex: 0 0 auto; color: inherit; }
.ic svg { width: 100%; height: 100%; display: block; stroke-width: 2.1; }

/* ---- Sidebar (glass) ---- */
.sidebar {
  background: var(--bg-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-right: 1px solid var(--glass-border);
  display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 6px 8px 16px; }
.brand-logo { font-size: 26px; color: var(--accent); display: inline-flex; }
.brand-logo .ic { width: 28px; height: 28px; }
.brand-title { font-weight: 800; letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); font-size: 12px; }
#nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-size: 13.5px; font-weight: 550;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 6px 18px -6px var(--accent); }
.nav-icon { width: 20px; display: inline-flex; align-items: center; justify-content: center; }
.nav-icon .ic { width: 18px; height: 18px; }
.nav-divider { height: 1px; background: var(--glass-border); margin: 8px 6px; }
.sidebar-footer { border-top: 1px solid var(--glass-border); padding-top: 12px; margin-top: 8px; }
.ghost-btn {
  background: var(--panel); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  color: var(--text); border: 1px solid var(--glass-border);
  border-radius: 10px; padding: 8px 10px; cursor: pointer; width: 100%;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.ghost-btn .ic { width: 16px; height: 16px; }
.who { color: var(--muted); font-size: 12px; margin-top: 8px; padding: 0 4px; }

/* ---- Content ---- */
.content { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 24px; border-bottom: 1px solid var(--glass-border);
  background: var(--bg-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: -0.02em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.api-input {
  width: 280px; max-width: 40vw; padding: 8px 11px; border: 1px solid var(--glass-border);
  border-radius: 10px; background: var(--panel); color: var(--text); font-size: 12.5px;
}
.api-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.conn { font-size: 12px; }
.conn.on { color: var(--good); }
.conn.off { color: var(--critical); }
main#view { padding: 24px; overflow-y: auto; flex: 1; }

.loading, .notice { color: var(--muted); padding: 32px; text-align: center; }
.notice.error { color: var(--critical); }
.notice code { color: var(--text); background: var(--panel-2); padding: 2px 6px; border-radius: 4px; }

/* ---- Mobile drawer (≤820px) ---- */
#nav-toggle { display: none; }
.nav-scrim { display: none; }
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 264px; z-index: 60;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .nav-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); z-index: 55; }
  .nav-scrim.show { display: block; }
  #nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
    background: var(--panel); border: 1px solid var(--glass-border); color: var(--text);
  }
  #nav-toggle .ic { width: 20px; height: 20px; }
  .topbar { padding: 12px 16px; }
  .api-input { width: 150px; }
  main#view { padding: 16px; }
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---- accessibility fallbacks ---- */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .sidebar, .topbar, .ghost-btn { background: var(--bg); }
}
@media (prefers-reduced-transparency: reduce) {
  .sidebar, .topbar, .ghost-btn { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg); }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
