/* SB Admin–inspired shell: light content, primary sidebar, theme toggle (no global search). */
@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap");

:root {
  /* Light: airy page + white cards (SB Admin–style) */
  --bg: #f8f9fc;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-glass: rgba(255, 255, 255, 0.92);
  --border: #e3e6f0;
  --text: #5a5c69;
  --text-strong: #3a3b45;
  --text-muted: #858796;
  --accent: #4e73df;
  --accent-hover: #2e59d9;
  --accent-dark: #224abe;
  --accent-soft: rgba(78, 115, 223, 0.12);
  --radius: 0.35rem;
  --shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
  --shadow-sm: 0 0.125rem 0.25rem rgba(58, 59, 69, 0.09);
  --shadow-lg: 0 1rem 3rem rgba(58, 59, 69, 0.18);

  --topbar-bg: #ffffff;
  --topbar-border: #e3e6f0;
  --sidebar-text: rgba(255, 255, 255, 0.88);
  --sidebar-text-dim: rgba(255, 255, 255, 0.55);
  --sidebar-bg: linear-gradient(180deg, #4e73df 0%, #224abe 100%);
  --sidebar-border: rgba(0, 0, 0, 0.08);
  --sidebar-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.2);
  --table-head-bg: #f8f9fc;
  --pill-bg: #ffffff;
}

html[data-theme="dark"] {
  --bg: #121318;
  --surface: #1a1d24;
  --surface-2: #15171d;
  --surface-glass: rgba(26, 29, 36, 0.92);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e6e8ef;
  --text-strong: #f3f4f8;
  --text-muted: rgba(230, 232, 239, 0.62);
  --accent: #6f8ff7;
  --accent-hover: #5a7eef;
  --accent-dark: #4e73df;
  --accent-soft: rgba(111, 143, 247, 0.16);
  --shadow: 0 0.15rem 1.75rem 0 rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.45);

  --topbar-bg: #1a1d24;
  --topbar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: rgba(255, 255, 255, 0.9);
  --sidebar-text-dim: rgba(255, 255, 255, 0.5);
  --sidebar-bg: linear-gradient(180deg, #1e2a4a 0%, #12151f 100%);
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.45);
  --table-head-bg: #22262f;
  --pill-bg: #22262f;
}

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

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

.appTopbar {
  position: sticky;
  top: 0;
  /* Above sidebar overlay (60) so Menu / theme stay clickable when the drawer is open on small screens */
  z-index: 65;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  box-shadow: var(--shadow-sm);
}

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

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.brandTitle {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--text-strong);
}
.brandSub {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.menuBtn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  color: var(--text-strong);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8125rem;
  box-shadow: var(--shadow-sm);
}
.menuBtn:hover { border-color: #d1d3e2; background: var(--surface-2); }
.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;
  font-weight: 700;
}
.linkMuted:hover { color: var(--accent); }

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

.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: 14rem;
  color: var(--sidebar-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.75rem 0.65rem 1rem;
  overflow: auto;
}

.sidebarHeader {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding: 0.35rem 0.25rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebarHeader .brandTitle {
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sidebarHeader .closeBtn {
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 0.35rem 0.45rem;
  cursor: pointer;
  color: #fff;
}
.sidebarHeader .closeBtn:hover { background: rgba(255, 255, 255, 0.15); }
.sidebarHeader .closeBtn svg { width: 18px; height: 18px; }

.navGroupLabel {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-text-dim);
  margin: 0.85rem 0.35rem 0.35rem;
}

.navLink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.15rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  border: 1px solid transparent;
  border-left: 4px solid transparent;
  font-weight: 700;
  font-size: 0.8125rem;
}
.navLink:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.06);
}
.navLink.active {
  background: rgba(255, 255, 255, 0.14);
  border-left-color: rgba(255, 255, 255, 0.95);
  color: #fff;
}
.navLink .hint {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-text-dim);
}

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

/* Desktop: persistent sidebar; optional collapse via body.navDesktopCollapsed */
@media (min-width: 980px) {
  .appShell { grid-template-columns: 14rem 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);
    transition: transform 0.2s ease, visibility 0.2s ease;
  }
  body.navDesktopCollapsed .appShell {
    grid-template-columns: 1fr;
  }
  body.navDesktopCollapsed .sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    width: 14rem;
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
    z-index: 70;
  }
  body.navDesktopCollapsed .appBody {
    grid-column: 1 / -1;
  }
  .appBody {
    grid-column: 2;
    padding: 1.5rem 1.5rem 2.5rem;
    max-width: 120rem;
  }
}

/* --- Common UI primitives --- */
.pageTitle {
  font-size: 1.65rem;
  font-weight: 800;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}
.pageSubtitle { margin: 0 0 1rem; color: var(--text-muted); font-size: 1rem; font-weight: 600; }

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

.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.4rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-strong);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.8125rem;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: #d1d3e2; background: var(--surface-2); }
.btnPrimary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btnPrimary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btnDanger { background: #e74a3b; border-color: #e74a3b; color: #fff; }
.btnDanger:hover { filter: brightness(0.95); }

label { display: block; font-weight: 800; font-size: 0.875rem; margin: 0 0 0.4rem; color: var(--text-strong); }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid #d1d3e2;
  background: var(--surface);
  color: var(--text-strong);
  font-size: 0.9375rem;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #bac8f3;
  box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.22);
}
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;
}

.themeBtn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  color: var(--text-strong);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: var(--shadow-sm);
  font-weight: 800;
  font-size: 0.8125rem;
  font-family: inherit;
}
.themeBtn:hover { border-color: #bac8f3; color: var(--accent); }
.themeBtn svg { width: 18px; height: 18px; }
.btnLink {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
  text-decoration: underline;
  font-size: 0.875rem;
  font-family: inherit;
}
.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.6rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  color: var(--text-strong);
  font-weight: 800;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  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.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--pill-bg);
  white-space: nowrap;
}
.pillOk { border-color: rgba(28, 200, 138, 0.35); color: #13855c; background: rgba(28, 200, 138, 0.1); }
.pillBad { border-color: rgba(231, 74, 59, 0.35); color: #c0392b; background: rgba(231, 74, 59, 0.1); }

.err { color: #e74a3b; font-size: 0.9rem; font-weight: 700; }
.err.show { margin-top: 0.5rem; }
.ok { color: #1cc88a; font-size: 0.9rem; margin-top: 0.5rem; font-weight: 700; }
.empty { color: var(--text-muted); padding: 1.5rem; text-align: center; font-weight: 600; }

html[data-theme="dark"] .pillOk { color: #5ce0b8; }
html[data-theme="dark"] .pillBad { color: #ff8a80; }
