/**
 * PuniCodex — The Sanctum · Admin Portal design system (portal.css v2)
 *
 * Obsidian/gold enterprise shell: fixed 240px sidebar with sectioned nav on
 * desktop, backdrop drawer on mobile, slim top bar with breadcrumb, snapshot
 * time, and refresh. New components are class-prefixed `.pz-` to avoid
 * collisions; the legacy hooks the first-generation pages were built against
 * (`.stat-card`, `.panel`, `.badge`, `.state-block`, `.modal-backdrop`,
 * `.toast`, `table.data-table`, `.login-*`, …) remain fully supported.
 *
 * Canonical source: platform/public/admin-portal/portal.css
 * The copy at /admin-portal/portal.css is GENERATED by scripts/sync-admin-portal.js.
 */

/* ── Design tokens ────────────────────────────────────────── */

:root {
  --pz-bg: #0a0a0c;
  --pz-panel: #121216;
  --pz-panel-2: #16161d;
  --pz-inset: #0c0c10;
  --pz-gold: #d4af37;
  --pz-gold-bright: #f0d878;
  --pz-gold-dim: rgba(212, 175, 55, 0.16);
  --pz-gold-line: rgba(212, 175, 55, 0.32);
  --pz-text: #f0ebdf;
  --pz-text-muted: #8f8a7d;
  --pz-danger: #f26d6d;
  --pz-success: #4ade80;
  --pz-warning: #fbbf24;
  --pz-info: #7ab8f5;
  --pz-border: rgba(255, 255, 255, 0.07);
  --pz-border-strong: rgba(255, 255, 255, 0.12);
  --pz-sidebar-w: 240px;
  --pz-topbar-h: 52px;
  --pz-radius: 10px;
  --pz-font-display: 'Cinzel', serif;
  --pz-font-data:
    system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --pz-font-mono: 'SFMono-Regular', Consolas, 'Courier New', monospace;

  /* Legacy aliases — first-generation pages and inline styles reference
     these; they resolve to the v2 obsidian palette. */
  --portal-bg: var(--pz-bg);
  --portal-elevated: var(--pz-panel);
  --portal-gold: var(--pz-gold);
  --portal-gold-dim: var(--pz-gold-dim);
  --portal-text: var(--pz-text);
  --portal-text-muted: var(--pz-text-muted);
  --portal-danger: var(--pz-danger);
  --portal-success: var(--pz-success);
  --portal-warning: var(--pz-warning);
  --portal-info: var(--pz-info);
  --portal-border: var(--pz-border);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--pz-font-data);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(212, 175, 55, 0.05), transparent 60%),
    var(--pz-bg);
  color: var(--pz-text);
  min-height: 100vh;
  line-height: 1.5;
}

a {
  color: var(--pz-gold);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--pz-gold);
  color: #000;
  padding: 0.5rem 1rem;
  z-index: 400;
  font-size: 0.85rem;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

/* ══════════════════════════════════════════════════════════
   Shell — sidebar, top bar, drawer (rendered by portal.js)
   ══════════════════════════════════════════════════════════ */

.pz-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--pz-sidebar-w);
  background: var(--pz-panel);
  border-right: 1px solid var(--pz-gold-dim);
  display: flex;
  flex-direction: column;
  z-index: 130;
  transition: transform 0.22s ease;
}

.pz-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.1rem 1.25rem 1rem;
  border-bottom: 1px solid var(--pz-border);
  text-decoration: none;
}

.pz-brand img {
  display: block;
}

.pz-brand em {
  font-style: normal;
  font-family: var(--pz-font-display);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--pz-text-muted);
}

.pz-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0 1rem;
}

.pz-nav-section {
  margin-top: 0.9rem;
}

.pz-nav-section:first-child {
  margin-top: 0;
}

.pz-nav-label {
  display: block;
  padding: 0 1.25rem 0.3rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--pz-text-muted);
  opacity: 0.75;
}

.pz-nav-item {
  display: block;
  position: relative;
  padding: 0.45rem 1.25rem 0.45rem 1.4rem;
  color: var(--pz-text-muted);
  text-decoration: none;
  font-size: 0.83rem;
  border-left: 2px solid transparent;
  transition:
    color 0.15s,
    background 0.15s,
    border-color 0.15s;
}

.pz-nav-item:hover {
  color: var(--pz-text);
  background: rgba(255, 255, 255, 0.03);
}

.pz-nav-item.active {
  color: var(--pz-gold);
  border-left-color: var(--pz-gold);
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.12), transparent 75%);
  box-shadow: inset 0 0 18px rgba(212, 175, 55, 0.06);
}

.pz-sidebar-foot {
  border-top: 1px solid var(--pz-border);
  padding: 0.85rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.pz-sidebar-user {
  font-size: 0.75rem;
  color: var(--pz-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pz-sidebar-role {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pz-gold);
  background: var(--pz-gold-dim);
  border-radius: 100px;
  padding: 0.15rem 0.55rem;
}

.pz-topbar {
  position: fixed;
  top: 0;
  left: var(--pz-sidebar-w);
  right: 0;
  height: var(--pz-topbar-h);
  background: rgba(10, 10, 12, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--pz-border);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0 1.5rem;
  z-index: 120;
}

.pz-drawer-toggle {
  display: none;
  background: none;
  border: 1px solid var(--pz-gold-dim);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
}

.pz-drawer-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--pz-gold);
}

.pz-breadcrumb {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pz-breadcrumb-root {
  font-family: var(--pz-font-display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pz-gold);
}

.pz-breadcrumb-sep {
  color: var(--pz-text-muted);
  opacity: 0.6;
}

.pz-breadcrumb-page {
  color: var(--pz-text);
  font-weight: 600;
}

.pz-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pz-topbar-time {
  font-size: 0.72rem;
  color: var(--pz-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pz-topbar-refresh {
  background: none;
  border: 1px solid var(--pz-border-strong);
  border-radius: 6px;
  color: var(--pz-text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  padding: 0.32rem 0.7rem;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.pz-topbar-refresh:hover {
  color: var(--pz-gold);
  border-color: var(--pz-gold);
}

/* Pending-decisions bell: gold counter badge, absolute on the glyph; the
   `hidden` attribute keeps it out of layout when the queues are clear. */
.pz-notif {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  color: var(--pz-text-muted);
  transition: color 0.15s;
}

.pz-notif:hover {
  color: var(--pz-gold);
}

.pz-notif-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--pz-gold);
  color: #14110a;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.pz-notif-badge[hidden] {
  display: none;
}

.pz-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 125;
}

/* Content column offset while the shell is mounted */
body.pz-shell {
  padding-left: var(--pz-sidebar-w);
}

body.pz-shell .portal-main {
  padding-top: calc(var(--pz-topbar-h) + 1.5rem);
}

/* Drawer behavior (mobile) */
@media (max-width: 900px) {
  body.pz-shell {
    padding-left: 0;
  }

  .pz-sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  }

  body.pz-drawer-open .pz-sidebar {
    transform: translateX(0);
  }

  body.pz-drawer-open .pz-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .pz-topbar {
    left: 0;
    padding: 0 1rem;
  }

  .pz-drawer-toggle {
    display: flex;
  }

  .pz-topbar-time {
    display: none;
  }
}

/* ── Layout (page column) ─────────────────────────────────── */

.portal-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.portal-page-head {
  margin-bottom: 1.5rem;
}

.portal-page-head h1 {
  font-family: var(--pz-font-display);
  font-size: 1.5rem;
  color: var(--pz-gold);
  margin: 0 0 0.35rem;
  letter-spacing: 0.04em;
}

.portal-page-head p {
  color: var(--pz-text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.portal-updated {
  color: var(--pz-text-muted);
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

/* ── Stat cards ───────────────────────────────────────────── */

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

.stat-card,
.pz-stat {
  background: var(--pz-panel);
  border: 1px solid var(--pz-border);
  border-radius: var(--pz-radius);
  padding: 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.stat-card::before,
.pz-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--pz-gold-line), transparent);
}

.stat-card-value,
.pz-stat-value {
  font-family: var(--pz-font-display);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--pz-gold);
  font-variant-numeric: tabular-nums;
}

.stat-card-label,
.pz-stat-label {
  font-size: 0.68rem;
  color: var(--pz-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.25rem;
}

.stat-card-hint,
.pz-stat-sub {
  font-size: 0.68rem;
  color: var(--pz-text-muted);
  margin-top: 0.15rem;
}

.pz-stat {
  text-align: left;
  padding: 0.9rem 1rem;
}

.pz-stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Trend arrow shown beside a stat value */
.pz-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pz-trend::before {
  font-size: 0.6rem;
}

.pz-trend--up {
  color: var(--pz-success);
}

.pz-trend--up::before {
  content: '▲';
}

.pz-trend--down {
  color: var(--pz-danger);
}

.pz-trend--down::before {
  content: '▼';
}

.pz-trend--flat {
  color: var(--pz-text-muted);
}

.pz-trend--flat::before {
  content: '▬';
}

.pz-delta {
  font-size: 0.68rem;
  color: var(--pz-success);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pz-delta--muted {
  color: var(--pz-text-muted);
}

/* ── Panels ───────────────────────────────────────────────── */

.panel,
.pz-panel {
  background: var(--pz-panel);
  border: 1px solid var(--pz-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.panel-head,
.pz-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.panel-title,
.pz-panel-title {
  font-family: var(--pz-font-display);
  font-size: 1.05rem;
  color: var(--pz-gold);
  margin: 0;
  letter-spacing: 0.04em;
}

.panel-sub,
.pz-panel-sub {
  color: var(--pz-text-muted);
  font-size: 0.8rem;
  margin: 0.15rem 0 0;
}

.pz-panel-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Decision queue rows ──────────────────────────────────── */

.pz-queue {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pz-queue-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--pz-border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--pz-text);
  transition:
    border-color 0.15s,
    background 0.15s;
}

.pz-queue-row:hover {
  border-color: var(--pz-gold-line);
  background: rgba(212, 175, 55, 0.05);
}

.pz-queue-main {
  min-width: 0;
  flex: 1;
}

.pz-queue-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.pz-queue-desc {
  font-size: 0.74rem;
  color: var(--pz-text-muted);
}

.pz-queue-count {
  font-family: var(--pz-font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--pz-gold);
  font-variant-numeric: tabular-nums;
}

.pz-queue-state {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pz-warning);
  white-space: nowrap;
}

/* Zero-count queues stay visible but dimmed and read "clear" */
.pz-queue-row.clear {
  opacity: 0.55;
}

.pz-queue-row.clear .pz-queue-count {
  color: var(--pz-text-muted);
}

.pz-queue-row.clear .pz-queue-state {
  color: var(--pz-success);
}

/* ── Quick-link tiles ─────────────────────────────────────── */

.quick-links,
.pz-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.9rem;
}

.quick-link,
.pz-tile {
  display: block;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--pz-gold-dim);
  border-radius: var(--pz-radius);
  padding: 1rem 1.1rem;
  text-decoration: none;
  transition:
    border-color 0.2s,
    background 0.2s,
    transform 0.15s;
}

.quick-link:hover,
.pz-tile:hover {
  border-color: var(--pz-gold);
  background: rgba(212, 175, 55, 0.06);
  transform: translateY(-1px);
}

.quick-link-title,
.pz-tile-title {
  font-family: var(--pz-font-display);
  color: var(--pz-gold);
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
  letter-spacing: 0.03em;
}

.quick-link-desc,
.pz-tile-desc {
  color: var(--pz-text-muted);
  font-size: 0.78rem;
}

/* ── Tables ───────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--pz-border);
  border-radius: var(--pz-radius);
}

table.portal-table,
table.data-table,
table.pz-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.portal-table th,
.portal-table td,
.data-table th,
.data-table td,
.pz-table th,
.pz-table td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: top;
}

.portal-table th,
.data-table th,
.pz-table th {
  color: var(--pz-text-muted);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.02);
}

.portal-table tr:last-child td,
.data-table tr:last-child td,
.pz-table tr:last-child td {
  border-bottom: none;
}

.portal-table tbody tr:nth-child(even) td,
.data-table tbody tr:nth-child(even) td,
.pz-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}

.portal-table tbody tr:hover td,
.data-table tbody tr:hover td,
.pz-table tbody tr:hover td {
  background: rgba(212, 175, 55, 0.05);
}

.portal-table .num,
.data-table .num,
.pz-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.portal-table .cell-title,
.data-table .cell-title,
.pz-table .cell-title {
  font-weight: 600;
}

.portal-table .cell-sub,
.data-table .cell-sub,
.pz-table .cell-sub {
  font-size: 0.72rem;
  color: var(--pz-text-muted);
}

.cell-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Sortable header affordance */
th.pz-sortable {
  cursor: pointer;
  user-select: none;
}

th.pz-sortable::after {
  content: '⇅';
  margin-left: 0.35rem;
  opacity: 0.4;
  font-size: 0.7rem;
}

th.pz-sortable[aria-sort='ascending']::after {
  content: '↑';
  opacity: 1;
  color: var(--pz-gold);
}

th.pz-sortable[aria-sort='descending']::after {
  content: '↓';
  opacity: 1;
  color: var(--pz-gold);
}

/* ── Badges ───────────────────────────────────────────────── */

.badge,
.pz-badge {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge--pending,
.badge--pending_payment,
.badge--pending_application,
.badge--needs_revision,
.badge--trialing {
  background: rgba(251, 191, 36, 0.15);
  color: var(--pz-warning);
}

.badge--active,
.badge--approved,
.badge--live {
  background: rgba(74, 222, 128, 0.15);
  color: var(--pz-success);
}

.badge--rejected,
.badge--cancelled,
.badge--disabled,
.badge--error {
  background: rgba(242, 109, 109, 0.15);
  color: var(--pz-danger);
}

.badge--expired,
.badge--ended,
.badge--closed,
.badge--withdrawn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--pz-text-muted);
}

.badge--contacted,
.badge--business,
.badge--university {
  background: rgba(122, 184, 245, 0.15);
  color: var(--pz-info);
}

.badge--gold {
  background: var(--pz-gold-dim);
  color: var(--pz-gold);
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition:
    opacity 0.2s,
    background 0.2s,
    border-color 0.2s;
  text-decoration: none;
}

.btn:hover {
  opacity: 0.85;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--pz-gold);
  color: #000;
}

.btn-primary:hover {
  background: var(--pz-gold-bright);
}

.btn-secondary,
.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--pz-text);
  border: 1px solid var(--pz-border-strong);
}

.btn-secondary:hover,
.btn-ghost:hover {
  border-color: var(--pz-gold);
  color: var(--pz-gold);
}

.btn-danger {
  background: rgba(242, 109, 109, 0.12);
  color: var(--pz-danger);
  border: 1px solid rgba(242, 109, 109, 0.35);
}

.btn-danger:hover {
  background: rgba(242, 109, 109, 0.22);
}

.btn-success {
  background: var(--pz-success);
  color: #000;
}

.btn-sm {
  padding: 0.32rem 0.65rem;
  font-size: 0.7rem;
}

.btn:focus-visible,
.pz-nav-item:focus-visible,
.pz-tile:focus-visible,
.pz-queue-row:focus-visible,
.quick-link:focus-visible,
.pz-drawer-toggle:focus-visible,
.pz-topbar-refresh:focus-visible,
.pz-notif:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.pz-brand:focus-visible {
  outline: 2px solid var(--pz-gold);
  outline-offset: 2px;
}

/* ── Forms ────────────────────────────────────────────────── */

.portal-form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 160px;
  flex: 1;
}

.field label {
  font-size: 0.68rem;
  color: var(--pz-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field input,
.field select,
.field textarea {
  background: var(--pz-inset);
  border: 1px solid var(--pz-gold-dim);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  color: var(--pz-text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--pz-gold);
}

.field textarea {
  resize: vertical;
  min-height: 90px;
}

.field-hint {
  font-size: 0.7rem;
  color: var(--pz-text-muted);
}

/* ── Modal ────────────────────────────────────────────────── */

.portal-modal-overlay,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}

.portal-modal,
.pz-modal {
  background: var(--pz-panel);
  border: 1px solid var(--pz-gold-dim);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  padding: 1.5rem;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.portal-modal h2,
.pz-modal h2 {
  font-family: var(--pz-font-display);
  color: var(--pz-gold);
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.portal-modal p,
.pz-modal p {
  font-size: 0.85rem;
  color: var(--pz-text-muted);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.modal-actions .btn {
  flex: 1;
  min-width: 120px;
}

/* ── One-time credential reveal ───────────────────────────── */

.credential-box {
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}

.credential-box dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

.credential-box dt {
  color: var(--pz-text-muted);
}

.credential-box dd {
  margin: 0;
  word-break: break-all;
}

.credential-box code {
  font-family: var(--pz-font-mono);
  color: var(--pz-success);
  font-size: 0.85rem;
}

.credential-warning {
  color: var(--pz-warning);
  font-size: 0.78rem;
  font-weight: 600;
}

/* ── Toasts ───────────────────────────────────────────────── */

.portal-toast-root,
.pz-toast-root {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 300;
  max-width: min(380px, calc(100vw - 3rem));
}

.portal-toast,
.toast,
.pz-toast {
  background: var(--pz-panel-2);
  border: 1px solid var(--pz-gold-dim);
  border-left: 3px solid var(--pz-gold);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--pz-text);
  font-size: 0.82rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.portal-toast--error,
.toast--error,
.pz-toast--error {
  border-left-color: var(--pz-danger);
}

.portal-toast--success,
.toast--success,
.pz-toast--success {
  border-left-color: var(--pz-success);
}

/* ── Empty / loading states ───────────────────────────────── */

.state-block,
.pz-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--pz-text-muted);
  font-size: 0.9rem;
}

.state-block.error,
.pz-empty--error {
  color: var(--pz-danger);
}

.pz-empty-title {
  font-family: var(--pz-font-display);
  color: var(--pz-text);
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

/* Skeleton shimmer rows for loading lists/tables */
.pz-skeleton {
  display: block;
  height: 0.85rem;
  border-radius: 4px;
  margin: 0.55rem 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
}

.pz-skeleton--card {
  height: 4.5rem;
  border-radius: var(--pz-radius);
  margin: 0;
}

.pz-skeleton--row {
  height: 2.4rem;
  border-radius: 8px;
}

/* ── Health dots ──────────────────────────────────────────── */

.pz-health {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.pz-health-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--pz-text-muted);
}

.pz-health-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.pz-health-dot--ok {
  background: var(--pz-success);
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
}

.pz-health-dot--warn {
  background: var(--pz-warning);
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.6);
}

.pz-health-dot--bad {
  background: var(--pz-danger);
  box-shadow: 0 0 6px rgba(242, 109, 109, 0.6);
}

.pz-health-dot--idle {
  background: var(--pz-text-muted);
}

/* ── Sparklines ───────────────────────────────────────────── */

.pz-sparkline {
  display: block;
  width: 100%;
  height: 36px;
}

/* ── Ranked list rows (trending temples / countries) ──────── */

.pz-rank-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pz-rank-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--pz-text);
  font-size: 0.85rem;
  transition: background 0.15s;
}

.pz-rank-row:hover {
  background: rgba(212, 175, 55, 0.06);
}

.pz-rank-pos {
  width: 1.4rem;
  text-align: right;
  color: var(--pz-text-muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.pz-rank-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.pz-rank-value {
  color: var(--pz-gold);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.pz-rank-sub {
  color: var(--pz-text-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

/* ── Queue cards (scholars) ───────────────────────────────── */

.queue-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.queue-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--pz-border);
  border-radius: var(--pz-radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.9rem;
}

.queue-card-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0.5rem;
}

.queue-card-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.queue-card-body {
  font-size: 0.8rem;
  color: var(--pz-text-muted);
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  padding: 0.65rem 0.8rem;
  margin: 0.5rem 0;
}

.queue-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

/* ── Login page ───────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2.5rem 1rem;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--pz-panel);
  border: 1px solid var(--pz-gold-dim);
  border-radius: 12px;
  padding: clamp(1.75rem, 5vw, 2.75rem);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--pz-gold), transparent);
}

.login-eyebrow {
  font-family: var(--pz-font-display);
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--pz-gold);
  margin: 0 0 0.9rem;
  text-align: center;
}

.login-title {
  font-family: var(--pz-font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  color: var(--pz-text);
  margin: 0 0 0.6rem;
  text-align: center;
}

.login-subtitle {
  color: var(--pz-text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0 0 1.75rem;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.login-form[hidden] {
  display: none;
}

.login-submit {
  width: 100%;
  padding: 0.8rem 1.25rem;
  border-radius: 6px;
  font-family: var(--pz-font-display);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid var(--pz-gold);
  background: var(--pz-gold);
  color: #000;
  margin-top: 0.4rem;
  transition:
    background 0.2s,
    border-color 0.2s;
}

.login-submit:hover {
  background: var(--pz-gold-bright);
  border-color: var(--pz-gold-bright);
}

.login-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-message {
  margin-top: 1.1rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.5;
  display: none;
}

.login-message.visible {
  display: block;
}

.login-message.error {
  color: var(--pz-danger);
  background: rgba(242, 109, 109, 0.08);
  border: 1px solid rgba(242, 109, 109, 0.25);
}

.login-message.success {
  color: var(--pz-success);
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.25);
}

.login-setup {
  margin-top: 1.1rem;
  padding: 0.9rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--pz-warning);
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  display: none;
}

.login-setup.visible {
  display: block;
}

.login-setup code {
  font-family: var(--pz-font-mono);
  color: var(--pz-text);
}

.login-footer {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--pz-border);
  color: var(--pz-text-muted);
  font-size: 0.82rem;
  text-align: center;
}

.login-footer a {
  color: var(--pz-gold);
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* ── Analytics page ───────────────────────────────────────── */

.period-switch {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.period-btn {
  background: transparent;
  color: var(--pz-text-muted);
  border: 1px solid var(--pz-gold-dim);
  border-radius: 100px;
  padding: 0.45rem 1rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.period-btn.active {
  color: var(--pz-gold);
  border-color: var(--pz-gold);
  background: rgba(212, 175, 55, 0.08);
}

.period-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.panel-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel-grid-2 .panel {
  margin-bottom: 0;
}

.chart-wrap {
  position: relative;
}

.traffic-chart {
  width: 100%;
  height: 260px;
  display: block;
}

.chart-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: var(--pz-bg);
  border: 1px solid var(--pz-gold-dim);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--pz-text);
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.chart-tooltip .tt-day {
  color: var(--pz-gold);
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.chart-tooltip .tt-muted {
  color: var(--pz-text-muted);
}

.chart-legend {
  display: flex;
  gap: 1.25rem;
  font-size: 0.7rem;
  color: var(--pz-text-muted);
  margin-top: 0.6rem;
}

.legend-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.page-analytics .portal-table .num,
.page-analytics .data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.page-analytics .portal-table tbody tr:nth-child(even) td,
.page-analytics .data-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.device-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.device-name {
  width: 70px;
  font-size: 0.72rem;
  color: var(--pz-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.device-bar-track {
  flex: 1;
  height: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  overflow: hidden;
}

.device-bar-fill {
  height: 100%;
  background: var(--pz-gold);
  border-radius: 100px;
}

.device-val {
  width: 120px;
  text-align: right;
  font-size: 0.75rem;
  color: var(--pz-text-muted);
  font-variant-numeric: tabular-nums;
}

.bot-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.bot-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--pz-gold-dim);
  border-radius: 100px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  color: var(--pz-text);
}

.bot-pill b {
  color: var(--pz-gold);
  font-variant-numeric: tabular-nums;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 900px) {
  .queue-grid {
    grid-template-columns: 1fr;
  }

  .panel-grid-2 {
    grid-template-columns: 1fr;
  }

  .traffic-chart {
    height: 200px;
  }

  .portal-main {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* ── Motion ───────────────────────────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  .pz-skeleton {
    animation: pz-shimmer 1.4s linear infinite;
  }

  .pz-health-dot--ok,
  .pz-health-dot--warn,
  .pz-health-dot--bad {
    animation: pz-pulse 2.4s ease-in-out infinite;
  }
}

@keyframes pz-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes pz-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
  50% {
    box-shadow: 0 0 8px 2px currentColor;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pz-sidebar,
  .pz-backdrop,
  .quick-link,
  .pz-tile,
  .pz-queue-row,
  .pz-nav-item,
  .btn {
    transition: none;
  }
}
