/* PTS Custom Reports - design system
   Mirrors PTS Central Audio (audiototext/webapp site.css): navy sidebar,
   diagonal blue/hex topbar, rounded cards, light/dark via data-theme on <html>.
   Plain CSS - no Bootstrap - so the component rules below cover what we use. */

:root {
  --navy-950: #071427;
  --navy-900: #0a1c33;
  --navy-800: #12294a;
  --navy-700: #1b3a63;
  --blue-700: #144f9e;
  --blue-600: #1a68d1;
  --blue-500: #2f8cf0;
  --blue-400: #5aa8f5;
  --blue-100: #e8f2fe;
  --ink: #16233a;
  --muted: #64748b;
  --bg: #eef2f8;
  --card-bg: #ffffff;
  --border: #e3e8f0;
  --success: #17a673;
  --danger: #e5484d;
  --surface: #ffffff;
  --surface-alt: #f7f9fc;
  --row-hover: #f1f6fd;
  --chip-bg: rgba(255, 255, 255, 0.9);
  --shadow-color: rgba(15, 35, 65, 0.06);
  --danger-soft: #fdecec;
  --danger-ink: #9c2b2f;
  --danger-border: #f3c6c8;
  --success-soft: #e3f6ee;
  --success-ink: #0f6e4c;
  --link: var(--blue-600);
  --link-hover: var(--blue-700);
  color-scheme: light;
  --radius: 14px;
  --radius-sm: 8px;
  --sidebar-w: 250px;
}

/* Dark theme: only the neutral surfaces/text change - the navy sidebar and
   blue accents stay the same so it still reads as the PTS Central scheme. */
:root[data-theme="dark"] {
  --blue-100: rgba(47, 140, 240, 0.16);
  --ink: #e4ebf5;
  --muted: #8ea2bf;
  --bg: #0b1628;
  --card-bg: #11223b;
  --border: #22385a;
  --surface: #11223b;
  --surface-alt: #0f1e34;
  --row-hover: #16294a;
  --chip-bg: rgba(17, 34, 59, 0.9);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --danger-soft: rgba(229, 72, 77, 0.15);
  --danger-ink: #f4a3a6;
  --danger-border: rgba(229, 72, 77, 0.5);
  --success-soft: rgba(23, 166, 115, 0.15);
  --success-ink: #7fdcb6;
  --link: var(--blue-400);
  --link-hover: #8cc3fa;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }

/* ---------- Shell layout ---------- */

.app-shell { display: flex; min-height: 100vh; }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 55%, var(--navy-800) 100%);
  color: #cfe0f7;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 2px 0 18px rgba(4, 12, 26, 0.25);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.4rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-brand:hover { color: #fff; }

.brand-mark {
  display: inline-flex;
  color: var(--blue-400);
  filter: drop-shadow(0 0 6px rgba(90, 168, 245, 0.45));
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }

.brand-name {
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #eaf3ff;
}

.brand-name b {
  font-weight: 800;
  background: linear-gradient(90deg, #7fc0ff, #3a86f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: #7f97b8;
  margin-top: 0.15rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.9rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow-y: auto;
}

.nav-section {
  padding: 1rem 0.85rem 0.35rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6d84a3;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: #a9c0dd;
  font-weight: 500;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-icon { display: inline-flex; flex: none; width: 20px; height: 20px; }
.nav-icon svg { width: 100%; height: 100%; }

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.nav-item.active {
  background: linear-gradient(90deg, rgba(47, 140, 240, 0.22), rgba(47, 140, 240, 0.06));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--blue-400);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  color: #6d84a3;
}

.db-status { display: flex; align-items: center; gap: 0.5rem; overflow: hidden; }
.db-status span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-status i {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6d84a3;
}
.db-status.ok i { background: var(--success); box-shadow: 0 0 6px rgba(23, 166, 115, 0.8); }
.db-status.bad i { background: var(--danger); box-shadow: 0 0 6px rgba(229, 72, 77, 0.8); }
.db-status.bad { color: #f4a3a6; }

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.9rem;
  left: 0.9rem;
  z-index: 1100;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--navy-900);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}

.sidebar-toggle span { width: 18px; height: 2px; background: #cfe0f7; border-radius: 2px; }

.sidebar-backdrop { display: none; }

/* ---------- Topbar ---------- */

.topbar {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 96px;
}

.topbar-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 62%, var(--blue-600) 62.5%, var(--blue-500) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-opacity='0.16' d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15z'/%3E%3C/svg%3E");
  background-size: cover, 28px 49px;
}

.topbar-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  min-height: 96px;
}

.topbar-title h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.topbar-user { display: flex; align-items: center; gap: 0.9rem; flex: none; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle:hover { color: var(--blue-600); border-color: var(--blue-400); background: var(--blue-100); }

/* Show the icon for the theme you'd switch TO. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Content ---------- */

.content { flex: 1; min-width: 0; padding: 1.75rem 2rem 2.5rem; }

.app-footer {
  padding: 1rem 2rem;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

.page-lead { color: var(--muted); margin: 0 0 1.25rem; }

.page-subtitle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  margin: 1.75rem 0 1rem;
}

.section-icon { display: inline-flex; width: 22px; height: 22px; color: var(--blue-500); }
.section-icon svg { width: 100%; height: 100%; }

.breadcrumb {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Cards ---------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 14px var(--shadow-color);
}

.card-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.stat { padding: 1.1rem 1.25rem; }
.stat-value { margin-top: 0.35rem; font-size: 2rem; font-weight: 700; color: var(--ink); line-height: 1.2; }

.report-group { scroll-margin-top: 1rem; }

.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.report-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.1rem 1.25rem;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.report-card strong { font-weight: 700; }
.report-card span { color: var(--muted); font-size: 0.86rem; }

.report-card:hover {
  color: var(--ink);
  border-color: var(--blue-400);
  box-shadow: 0 6px 22px rgba(47, 140, 240, 0.15);
  transform: translateY(-1px);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  line-height: 1.4;
  cursor: pointer;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  border-color: var(--blue-700);
}

.btn-primary:hover, .btn-primary:focus {
  color: #fff;
  background: linear-gradient(135deg, var(--blue-600), var(--navy-800));
  border-color: var(--navy-800);
}

.btn-outline-primary { color: var(--link); background: transparent; border-color: var(--blue-500); }
.btn-outline-primary:hover { color: #fff; background: var(--blue-600); border-color: var(--blue-600); }

.btn:focus-visible, input:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(47, 140, 240, 0.25);
}

/* ---------- Forms ---------- */

input, select, textarea {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.75rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: var(--surface-alt); }
input:focus, select:focus, textarea:focus { border-color: var(--blue-500); }
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; min-height: 5.5rem; }

.params {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  padding: 1.1rem 1.25rem;
}

.params label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.filter { width: 320px; max-width: 100%; margin-bottom: 1rem; }

/* ---------- Alerts ---------- */

.alert {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border-left: 4px solid transparent;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  font: inherit;
}

.alert-danger { background: var(--danger-soft); border-left-color: var(--danger); color: var(--danger-ink); }
.alert-info { background: var(--blue-100); border-left-color: var(--blue-500); color: var(--link-hover); }
.alert-success { background: var(--success-soft); border-left-color: var(--success); color: var(--success-ink); }

code {
  color: var(--link-hover);
  background: var(--blue-100);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ---------- Tables ---------- */

.toolbar { display: flex; gap: 0.6rem; align-items: center; margin: 1.5rem 0 0.75rem; }
.toolbar span { margin-right: auto; color: var(--muted); font-size: 0.86rem; }

.table-wrap {
  overflow: auto;
  max-height: 70vh;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 14px var(--shadow-color);
}

table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }

th, td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-alt);
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Topbar user chip ---------- */

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem 0.35rem 0.35rem;
  box-shadow: 0 2px 10px var(--shadow-color);
  color: var(--ink);
}

.user-chip:hover { color: var(--ink); border-color: var(--blue-400); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  flex: none;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 0.86rem; }
.user-role { font-size: 0.72rem; color: var(--muted); }

.logout-form { display: inline-flex; margin: 0; }

.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.logout-btn svg { width: 18px; height: 18px; }
.logout-btn:hover { color: var(--danger); border-color: var(--danger-border); background: var(--danger-soft); }

/* ---------- Sign-in pages ---------- */

.auth-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(160deg, var(--navy-950), var(--navy-800));
  overflow: hidden;
}

.auth-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 58%, rgba(26, 104, 209, 0.55) 58.5%, rgba(47, 140, 240, 0.35) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-opacity='0.07' d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15z'/%3E%3C/svg%3E");
  background-size: cover, 28px 49px;
}

.auth-panel { position: relative; width: 100%; max-width: 420px; }

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.auth-brand .brand-name { font-size: 1.3rem; }

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  padding: 2rem;
}

.auth-card h2 { margin: 0 0 0.35rem; font-size: 1.3rem; font-weight: 700; }
.auth-card .page-lead { font-size: 0.88rem; }

/* ---------- Panels, forms, details ---------- */

.panel { padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
.panel.narrow { max-width: 560px; }

.panel-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.stack-form { display: flex; flex-direction: column; gap: 1rem; }

.stack-form label, .role-name {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.optional { font-weight: 400; color: var(--muted); font-size: 0.76rem; }
.form-hint { margin: 0; font-size: 0.8rem; font-weight: 400; color: var(--muted); }
.form-actions { display: flex; gap: 0.6rem; align-items: center; }
.btn-block { width: 100%; padding: 0.65rem 1rem; font-size: 0.95rem; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.6rem 1.5rem;
  margin: 0;
  font-size: 0.9rem;
}

.details dt { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.details dd { margin: 0; }

.page-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-actions .page-lead { margin: 0; }

.muted { color: var(--muted); }

.empty-state { max-width: 520px; padding: 2rem; text-align: center; margin: 1rem auto; }
.empty-code { font-size: 3rem; font-weight: 800; color: var(--blue-500); line-height: 1; margin-bottom: 0.5rem; }

/* ---------- Buttons (small / secondary / status) ---------- */

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-outline-secondary { color: var(--muted); background: transparent; border-color: var(--border); }
.btn-outline-secondary:hover { color: var(--ink); background: var(--surface-alt); border-color: var(--muted); }
.btn-outline-danger { color: var(--danger); background: transparent; border-color: var(--danger-border); }
.btn-outline-danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-outline-success { color: var(--success); background: transparent; border-color: var(--success); }
.btn-outline-success:hover { color: #fff; background: var(--success); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--link);
  cursor: pointer;
}

.link-btn:hover { color: var(--link-hover); }

.actions-cell { width: 1%; }
.row-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.row-actions form { margin: 0; }
td.wrap { white-space: normal; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 0.2em 0.65em;
  margin: 0.1rem 0;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--ink);
  white-space: nowrap;
}

.badge-blue { background: var(--blue-100); border-color: transparent; color: var(--link-hover); }
.badge-success { background: var(--success-soft); border-color: transparent; color: var(--success-ink); }
.badge-muted { color: var(--muted); }
.badge-warn { background: #fef6e0; border-color: transparent; color: #8a600f; font-size: 0.68rem; }
:root[data-theme="dark"] .badge-warn { background: rgba(224, 165, 33, 0.15); color: #f2cf7c; }

/* ---------- Role permissions ---------- */

.perm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.perm-head .panel-title { margin-bottom: 0.5rem; }
.perm-bulk { font-size: 0.8rem; color: var(--muted); }
.perm-section .form-hint { margin-bottom: 0.9rem; }

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.5rem 1.25rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--blue-600); flex: none; cursor: pointer; }

.check-card {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-weight: 600;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.check-card:hover { border-color: var(--blue-400); }
.check-card:has(input:checked) { border-color: var(--blue-500); background: var(--blue-100); }
.check-icon { display: inline-flex; width: 20px; height: 20px; color: var(--blue-500); flex: none; }
.check-icon svg { width: 100%; height: 100%; }
fieldset:disabled .check, fieldset:disabled .check input { cursor: default; }

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 0.9rem 0;
  margin-bottom: 1.25rem;
  background: linear-gradient(transparent, var(--bg) 35%);
}

.role-summary { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.4rem; font-size: 0.88rem; }
.role-summary li { display: flex; justify-content: space-between; gap: 1rem; }
.role-summary span { color: var(--muted); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }

  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }

  /* Keep the toggle clear of the brand logo while the sidebar is open. */
  .sidebar.open .sidebar-brand { padding-left: 4.25rem; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(4, 12, 26, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

  .app-main { margin-left: 0; }
  .topbar-content { padding: 1.25rem 1.25rem 1.25rem 4.25rem; }
  .content { padding: 1.25rem; }
  .toolbar { flex-wrap: wrap; }
  .user-meta { display: none; }
  .user-chip { padding-right: 0.35rem; }
  .page-actions { flex-direction: column; }
}

/* ---------- Sites ---------- */

.site-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.3rem 0.4rem 0.3rem 0.75rem;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 2px 10px var(--shadow-color);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
}

.site-switcher.single { padding-right: 0.9rem; }
.site-switcher.none { padding: 0.45rem 0.9rem; color: var(--danger-ink); background: var(--danger-soft); border-color: var(--danger-border); }
.site-icon { display: inline-flex; width: 17px; height: 17px; color: var(--blue-500); flex: none; }
.site-icon svg { width: 100%; height: 100%; }

.site-switcher select {
  max-width: 220px;
  padding: 0.25rem 0.5rem;
  border: 0;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

:root[data-theme="dark"] .site-switcher select { background: transparent; }
.site-switcher select option { color: var(--ink); background: var(--surface); }

.site-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
  color: var(--muted);
}

.site-tag.first { margin-left: 0; padding-left: 0; border-left: 0; }
.site-tag svg { width: 13px; height: 13px; color: var(--blue-500); }

.panel-title.spaced { margin-top: 1.75rem; margin-bottom: 0.35rem; }
.role-checks { margin-top: 0.75rem; }

.field-row { display: flex; gap: 0.75rem; }
.field-row .grow { flex: 1; }
.field-row .port { width: 150px; }

.auth-choice { display: flex; gap: 1.5rem; padding: 0.25rem 0; }
.auth-choice .check { font-weight: 600; font-size: 0.86rem; }
.check input[type=radio] { accent-color: var(--blue-600); }

.advanced summary { cursor: pointer; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.advanced[open] summary { margin-bottom: 0.9rem; }

@media (max-width: 900px) {
  .site-switcher select { max-width: 130px; }
  .field-row { flex-direction: column; }
  .field-row .port { width: auto; }
}

/* Checkboxes/radios inside stacked forms sit beside their text, not above it. */
.stack-form label.check { flex-direction: row; align-items: center; gap: 0.6rem; font-size: 0.86rem; }

/* ---------- Site agents and HTTPS ---------- */

.badge-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger-ink); }
.enroll-code {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink);
  background: var(--surface-alt);
  border: 1px dashed var(--blue-400);
  border-radius: var(--radius-sm);
  user-select: all;
}
.fingerprint { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.78rem; word-break: break-all; user-select: all; }
.install-steps { margin: 0; padding-left: 1.2rem; font-size: 0.86rem; line-height: 1.6; }
.install-steps li + li { margin-top: 0.25rem; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.panel-actions form { margin: 0; }
