:root {
  /* NextAdmin-like palette (light) */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #fbfcff;
  --surface-glass: rgba(255, 255, 255, 0.78);
  --border: rgba(15, 23, 42, 0.10);
  --text: #0f172a;
  --text-muted: rgba(15, 23, 42, 0.60);
  --accent: #3c50e0;
  --accent-hover: #2d3fd6;
  --accent-soft: rgba(60, 80, 224, 0.12);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 18px 55px rgba(15, 23, 42, 0.12);

  --topbar-bg: rgba(245, 247, 251, 0.9);
  --sidebar-bg: rgba(255,255,255,0.95);
  --sidebar-border: rgba(15, 23, 42, 0.08);
  --sidebar-shadow: 0 18px 60px rgba(15, 23, 42, 0.18);
  --table-head-bg: #fafbfc;
  --pill-bg: #ffffff;
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #0f172a;
  --surface-2: #111c33;
  --surface-glass: rgba(15, 23, 42, 0.78);
  --border: rgba(226, 232, 240, 0.12);
  --text: #e2e8f0;
  --text-muted: rgba(226, 232, 240, 0.62);
  --accent: #5a6bff;
  --accent-hover: #4a5cf3;
  --accent-soft: rgba(90, 107, 255, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 22px 70px rgba(0, 0, 0, 0.45);

  --topbar-bg: rgba(11, 18, 32, 0.82);
  --sidebar-bg: rgba(15, 23, 42, 0.92);
  --sidebar-border: rgba(226, 232, 240, 0.10);
  --sidebar-shadow: 0 22px 70px rgba(0, 0, 0, 0.55);
  --table-head-bg: color-mix(in srgb, var(--surface-2) 72%, transparent);
  --pill-bg: color-mix(in srgb, var(--surface) 86%, transparent);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* --- App shell --- */
.appShell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

.appTopbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sidebar-border);
}

.appTopbarInner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.brandTitle {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.brandSub {
  font-size: 0.75rem;
  color: var(--text-muted);
}


.menuBtn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: var(--shadow);
}
.menuBtn:hover { border-color: #cbd5e1; }
.menuBtn svg { width: 18px; height: 18px; }

.topActions {
  margin-left: auto;
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}
.linkMuted {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
}
.linkMuted:hover { color: var(--accent); }

.appBody {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* Utility: allow pages to opt out of container constraints */
.uFullBleed {
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 60;
}
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 290px;
  color: var(--text);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: var(--sidebar-shadow);
  z-index: 70;
  transform: translateX(-105%);
  transition: transform 0.2s ease;
  padding: 0.9rem 0.9rem 1rem;
  overflow: auto;
}

.sidebarHeader {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.sidebarHeader .closeBtn {
  margin-left: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
}
.sidebarHeader .closeBtn:hover { border-color: #cbd5e1; }
.sidebarHeader .closeBtn svg { width: 18px; height: 18px; }

.navGroupLabel {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--text) 45%, transparent);
  margin: 0.85rem 0 0.35rem;
}

.navLink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  color: color-mix(in srgb, var(--text) 88%, transparent);
  text-decoration: none;
  border: 1px solid transparent;
}
.navLink:hover { background: rgba(60, 80, 224, 0.06); border-color: rgba(60, 80, 224, 0.14); }
.navLink.active {
  background: rgba(60, 80, 224, 0.10);
  border-color: rgba(60, 80, 224, 0.22);
  color: color-mix(in srgb, var(--text) 94%, transparent);
}
.navLink .hint { font-size: 0.75rem; color: color-mix(in srgb, var(--text) 55%, transparent); }

.sidebarOpen .sidebarOverlay { display: block; }
.sidebarOpen .sidebar { transform: translateX(0); }

/* Desktop: persistent sidebar */
@media (min-width: 980px) {
  .appShell { grid-template-columns: 290px 1fr; }
  .appTopbar { grid-column: 1 / -1; }
  .sidebarOverlay { display: none !important; }
  .sidebar {
    position: sticky;
    top: 56px;
    transform: none;
    height: calc(100vh - 56px);
    box-shadow: none;
    border-right: 1px solid var(--sidebar-border);
  }
  .appBody {
    grid-column: 2;
    padding: 1.25rem 1.25rem 2.5rem;
  }
}

/* --- Common UI primitives --- */
.pageTitle { font-size: 1.45rem; margin: 0 0 0.25rem; letter-spacing: -0.01em; }
.pageSubtitle { margin: 0 0 1rem; color: var(--text-muted); font-size: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.cardElevated { box-shadow: var(--shadow-lg); }

.cardHeaderRow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
}
.btn:hover { border-color: #cbd5e1; }
.btnPrimary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btnPrimary:hover { filter: brightness(0.96); }
.btnDanger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btnDanger:hover { filter: brightness(0.92); }

/* Form controls (bigger, spaced) */
label { display: block; font-weight: 700; font-size: 0.95rem; margin: 0 0 0.4rem; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text);
  font-size: 1rem;
  box-shadow: var(--shadow);
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px); background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 2.1rem; }

/* Theme toggle button */
.themeBtn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: var(--shadow);
  font-weight: 700;
  font-size: 0.85rem;
}
.themeBtn:hover { border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.themeBtn svg { width: 18px; height: 18px; }
.btnLink {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
  font-size: 0.875rem;
}
.btnLink:hover { color: var(--accent-hover); }

.tableWrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { text-align: left; padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; background: var(--table-head-bg); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--pill-bg);
  white-space: nowrap;
}
.pillOk { border-color: rgba(22,163,74,0.25); color: #166534; background: rgba(22,163,74,0.08); }
.pillBad { border-color: rgba(185,28,28,0.25); color: #991b1b; background: rgba(185,28,28,0.08); }

.err { color: #b91c1c; font-size: 0.9rem; }
.err.show { margin-top: 0.5rem; }
.ok { color: #166534; font-size: 0.9rem; margin-top: 0.5rem; }
.empty { color: var(--text-muted); padding: 1.5rem; text-align: center; }

