/* Zengroups — Architectural Editorial */
:root {
  --navy: #14143C;
  --navy-80: #1f1f52;
  --navy-60: rgba(20, 20, 60, 0.6);
  --navy-15: rgba(20, 20, 60, 0.15);
  --navy-08: rgba(20, 20, 60, 0.1);
  --navy-05: rgba(20, 20, 60, 0.06);
  --orange: #FF6600;
  --orange-deep: #A33E00;
  --orange-12: rgba(255, 102, 0, 0.12);
  --orange-20: rgba(255, 102, 0, 0.2);
  --ink: #111827;
  --ink-muted: #4B5563;
  --ink-soft: #6B7280;
  --surface: #F3F4F6;
  --surface-low: #EBEDF2;
  --surface-lowest: #FFFFFF;
  --surface-high: #E2E5EB;
  --success: #047857;
  --success-bg: #D1FAE5;
  --warn: #B45309;
  --warn-bg: #FEF3C7;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;
  --info: #1D4ED8;
  --info-bg: #DBEAFE;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10), 0 4px 12px rgba(15, 23, 42, 0.06);
  --font: 'Manrope', ui-sans-serif, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  /* Sidebar theme tokens */
  --sidebar-bg: #FAFBFC;
  --sidebar-text: #0F172A;
  --sidebar-text-muted: #64748B;
  --sidebar-text-soft: #94A3B8;
  --sidebar-hover: rgba(15, 23, 42, 0.06);
  --sidebar-active-bg: rgba(255, 107, 43, 0.12);
  --sidebar-active-text: var(--orange);
  --sidebar-border: #E5E7EB;
  /* Bulk bar / banner tokens */
  --bar-bg: #FFFFFF;
  --bar-text: #0F172A;
  --bar-text-muted: #64748B;
  --bar-border: #E5E7EB;
  --banner-bg: #F1F5F9;
  --banner-text: #334155;
  --banner-text-muted: #64748B;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ========== Layout ========== */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.app.collapsed { grid-template-columns: 80px 1fr; }

/* ========== Sidebar ========== */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--sidebar-border);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 32px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-deep) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(255, 102, 0, 0.3);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { line-height: 1.15; }
.brand-name {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.brand-sub {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.sidebar-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sidebar-text-soft);
  padding: 0 12px;
  margin: 18px 0 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px 11px 14px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  margin-bottom: 2px;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav-item.active {
  color: var(--sidebar-active-text);
  background: var(--sidebar-active-bg);
  font-weight: 600;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--orange);
  box-shadow: 0 0 8px rgba(255, 102, 0, 0.4);
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}
.nav-item.disabled { opacity: 0.45; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; }

.sidebar-spacer { flex: 1; }

.sidebar-cta {
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-deep) 100%);
  color: #fff;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
  box-shadow: 0 8px 20px rgba(255, 102, 0, 0.25);
  transition: transform 0.15s ease;
}
.sidebar-cta:hover { transform: translateY(-1px); }

.sidebar-footer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--sidebar-text-muted);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius-md);
}
.sidebar-footer-item:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }

/* ========== Topbar ========== */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 68px;
  background: var(--surface-lowest);
  display: flex;
  align-items: center;
  padding: 0 36px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-search {
  flex: 1;
  max-width: 520px;
  background: var(--surface-low);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-muted);
  border: 1px solid var(--navy-08);
}
.topbar-search:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-12);
}
.topbar-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--ink);
}
.topbar-search kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 6px;
  background: var(--surface-high);
  border-radius: 4px;
  color: var(--ink-muted);
  border: 1px solid var(--navy-08);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ECFDF5;
  color: #065F46;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #A7F3D0;
}
.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  position: relative;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-low); color: var(--ink); }
.icon-btn .notif-dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  background: var(--orange);
  border-radius: 50%;
  border: 2px solid var(--surface-lowest);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px 6px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.user-menu:hover { background: var(--surface-low); }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbd3b8, #ff9b66);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.user-meta { line-height: 1.2; text-align: right; }
.user-meta .name { font-weight: 600; font-size: 13px; }
.user-meta .role { font-size: 11px; color: var(--ink-muted); }

/* ========== Role switcher ========== */
.role-switcher {
  display: inline-flex;
  background: var(--surface-low);
  padding: 3px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}
.role-switcher button {
  padding: 7px 16px;
  border-radius: 999px;
  color: var(--ink-muted);
  transition: all 0.15s;
}
.role-switcher button:hover:not(.active) {
  color: var(--ink);
  background: var(--surface-high);
}
.role-switcher button.active {
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ========== Content ========== */
.content {
  padding: 36px 40px 100px;
  max-width: 1440px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  gap: 20px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 8px;
  line-height: 1.1;
}
.page-head p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 14.5px;
  max-width: 560px;
}
.page-head .actions { display: flex; gap: 10px; }

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  background: var(--orange);
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-deep) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 102, 0, 0.2);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(255, 102, 0, 0.3); }
.btn-secondary {
  background: var(--surface-lowest);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--navy-15);
}
.btn-secondary:hover { box-shadow: inset 0 0 0 1.5px var(--navy); background: var(--surface-low); }
.btn-ghost { color: var(--ink-muted); }
.btn-ghost:hover { background: var(--surface-low); color: var(--ink); }
.btn-danger {
  background: linear-gradient(135deg, #d4301a 0%, #8f1e10 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(180, 35, 24, 0.25);
}
.btn-danger:hover { transform: translateY(-1px); }
.btn-sm { padding: 7px 12px; font-size: 12px; }

/* ========== Cards ========== */
.card {
  background: var(--surface-lowest);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.card-padded { padding: 32px; }
.card-nav {
  background: var(--banner-bg);
  color: var(--banner-text);
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--navy-08);
  border-left: 4px solid var(--orange);
}
.card-nav::after {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 102, 0, 0.25) 0%, transparent 70%);
}

.card h2, .card h3, .card-nav h2 {
  margin: 0 0 4px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.card h2 { font-size: 20px; color: var(--ink); }
.card h3 { font-size: 16px; color: var(--ink); }
.card-sub {
  color: var(--ink-muted);
  font-size: 13px;
  margin-bottom: 20px;
}
.card-nav .card-sub { color: var(--banner-text-muted); }

/* ========== Stat cards ========== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface-lowest);
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  position: relative;
}
.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.stat-card .value {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}
.stat-card .trend {
  font-size: 11px;
  font-weight: 700;
  position: absolute;
  top: 22px;
  right: 22px;
  padding: 3px 8px;
  border-radius: 999px;
}
.stat-card .trend.up { background: var(--success-bg); color: var(--success); }
.stat-card .trend.down { background: var(--danger-bg); color: var(--danger); }
.stat-card .trend.flat { background: var(--surface-high); color: var(--ink-muted); }
.stat-card .sublabel {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-muted);
}
.stat-card.accent-left::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 3px;
  background: var(--orange);
  border-radius: 0 3px 3px 0;
}

/* ========== Tables ========== */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl thead th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  font-weight: 700;
  text-align: left;
  padding: 14px 16px;
  background: transparent;
}
.tbl tbody tr {
  transition: background 0.12s;
}
.tbl tbody tr:hover { background: var(--surface-low); }
.tbl tbody td {
  padding: 18px 16px;
  vertical-align: middle;
}
.tbl tbody tr + tr td { box-shadow: 0 -1px 0 var(--navy-08); }

.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell .who .name { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.user-cell .who .email { font-size: 12px; color: var(--ink-muted); }

/* ========== Badges & chips ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.success::before { background: var(--success); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.warn::before { background: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.danger::before { background: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.info::before { background: var(--info); }
.badge.neutral { background: var(--surface-high); color: var(--ink-muted); }
.badge.neutral::before { background: var(--ink-soft); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-high);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--ink);
}
.chip.group { background: #DBEAFE; color: #1E40AF; }
.chip.group.prod { background: #FEE2E2; color: #B91C1C; }
.chip.group.admin { background: #EDE9FE; color: #6D28D9; }
.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

/* ========== Toggle ========== */
.toggle {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--orange-12);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
  flex-shrink: 0;
  border: 1.5px solid var(--orange-20);
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--orange);
  opacity: 0.45;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: left 0.2s, background 0.2s, opacity 0.2s;
}
.toggle.on {
  background: var(--orange);
  border-color: var(--orange-deep);
  box-shadow: 0 0 0 3px var(--orange-20), 0 2px 8px var(--orange-20);
}
.toggle.on::after {
  left: 24px;
  background: #fff;
  opacity: 1;
}
/* Submitted state — locked, green */
.toggle.submitted {
  background: var(--success);
  border-color: var(--success);
  cursor: not-allowed;
  opacity: 0.85;
}
.toggle.submitted::after {
  left: 24px;
  background: #fff;
}

/* ========== Expiration row ========== */
.expire-days {
  font-weight: 700;
  font-size: 13.5px;
}
.expire-days.danger { color: var(--danger); }
.expire-days.warn { color: var(--warn); }
.expire-days .sub {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ========== Sublabel / Kbd ========== */
.kbd-code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--surface-low);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--ink);
}

/* ========== Modal ========== */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(20, 20, 60, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadein 0.2s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface-lowest);
  border-radius: var(--radius-xl);
  padding: 36px;
  width: 540px;
  max-width: 92vw;
  box-shadow: var(--shadow-lg);
  animation: modalup 0.25s cubic-bezier(0.2, 0.9, 0.35, 1.1);
}
@keyframes modalup { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h2 {
  margin: 0 0 10px;
  font-size: 22px;
  letter-spacing: -0.015em;
}
.modal p { color: var(--ink-muted); font-size: 14px; margin: 0 0 20px; }
.modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }

/* ========== Inputs ========== */
.input {
  background: var(--surface-lowest);
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  width: 100%;
  border: 1.5px solid var(--navy-08);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  color: var(--ink);
}
.input::placeholder { color: var(--ink-soft); }
.input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-12); background: var(--surface-lowest); }
.input.underline {
  background: var(--surface-low);
  border-radius: 8px 8px 0 0;
  box-shadow: inset 0 -2px 0 var(--navy-15);
}
.input.underline:focus { box-shadow: inset 0 -2px 0 var(--orange); }
.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
}

/* ========== Misc ========== */
.spacer-y-8 { height: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.space { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }

/* ========== Tweaks panel ========== */
.tweaks-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 300px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  z-index: 80;
  font-size: 13px;
}
.tweaks-panel h4 { margin: 0 0 14px; font-size: 14px; }
.tweak-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.tweak-row:last-child { margin-bottom: 0; }
.tweak-label { font-size: 12.5px; color: var(--ink-muted); }

/* ========== Login ========== */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
}
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}
.login-form {
  width: 100%;
  max-width: 400px;
}
.login-brand { margin-bottom: 36px; text-align: center; }
.login-card {
  background: var(--surface-lowest);
  border-radius: var(--radius-lg);
  padding: 32px;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--orange) 0%, var(--orange-deep) 100%);
}
.login-hero {
  background: var(--navy);
  color: #fff;
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero-graphic {
  position: absolute;
  inset: 0;
  opacity: 0.6;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  font-weight: 600;
  margin: 24px 0 20px;
}
.divider-text::before, .divider-text::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--navy-08);
}

/* ========== Bulk action bar ========== */
.bulk-bar {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bar-bg);
  color: var(--bar-text);
  border: 1px solid var(--bar-border);
  border-radius: 999px;
  padding: 12px 14px 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  z-index: 60;
  animation: slideup 0.25s cubic-bezier(0.2, 0.9, 0.35, 1.1);
}
@keyframes slideup {
  from { transform: translate(-50%, 40px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.bulk-bar .count {
  background: var(--orange);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 700;
  font-size: 12px;
}

/* ========== Progress bar ========== */
.progress {
  height: 6px;
  background: var(--surface-high);
  border-radius: 999px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--orange) 0%, var(--orange-deep) 100%);
  border-radius: 999px;
}

/* ========== Checkbox ========== */
.checkbox {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--surface-low);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1.5px var(--navy-15);
  transition: all 0.15s;
}
.checkbox.on {
  background: var(--orange);
  box-shadow: inset 0 0 0 1.5px var(--orange);
}
.checkbox.on svg { display: block; }
.checkbox svg { display: none; color: #fff; width: 12px; height: 12px; }

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--navy-15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--navy-60); }

/* ========== Timeline ========== */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--navy-08);
}
.timeline-item {
  position: relative;
  padding-bottom: 18px;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface-lowest);
  box-shadow: 0 0 0 2px var(--navy-15);
}
.timeline-item.accent::before { background: var(--orange); box-shadow: 0 0 0 3px var(--orange-20); }

/* ========== Hover lift rows ========== */
.row-actions { opacity: 0; transition: opacity 0.15s; display: flex; gap: 6px; }
.tbl tbody tr:hover .row-actions { opacity: 1; }

/* ========== Error / Empty States ========== */
.error-state {
  text-align: center;
  padding: 72px 24px;
  max-width: 420px;
  margin: 0 auto;
}
.error-state--compact { padding: 40px 16px; }
.error-state__icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.error-state--compact .error-state__icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.error-state__title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 8px;
}
.error-state--compact .error-state__title { font-size: 16px; }
.error-state__message {
  color: var(--ink-muted);
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0 0 20px;
}
.error-state--compact .error-state__message { font-size: 12.5px; margin-bottom: 14px; }
.error-state__actions { display: flex; gap: 8px; justify-content: center; }

/* Degraded banner */
.degraded-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 20px;
}

/* ========== Light Mode Enhancements ========== */

/* Topbar — subtle bottom border */
.topbar {
  border-bottom: 1px solid var(--navy-08);
}

/* Stat cards — visible borders + subtle shadow */
.stat-card {
  border: 1px solid var(--navy-08);
  box-shadow: var(--shadow-sm);
}

/* Main cards — border definition */
.card {
  border: 1px solid var(--navy-08);
  box-shadow: var(--shadow-sm);
}

/* User rows inside PM dashboard — border definition */
.card .pm-row-grid + div,
.card [style*="surface-lowest"] {
  border: 1px solid var(--navy-05);
}

/* Role-switcher tabs — stronger active contrast */
.role-switcher {
  border: 1px solid var(--navy-08);
}

/* Inputs — border/focus handled in main .input rule */

/* Select dropdowns — match input borders */
select {
  border: 1.5px solid var(--navy-08) !important;
}

/* Progress bar track — visible in light mode */
.progress {
  background: var(--surface-high);
  border: 1px solid var(--navy-05);
}

/* Knowledge base placeholder cards */
.card [style*="surface-low"] {
  border: 1px solid var(--navy-05);
}

/* Timeline items — left border visibility */
.timeline::before {
  background: var(--navy-15);
}
.timeline-item::before {
  border: 2px solid var(--navy-15);
}

/* Group decoder cards in expanded view */
.stack-sm > div {
  box-shadow: var(--shadow-sm);
}

/* ========== Dark Mode ========== */
[data-theme="dark"] {
  --navy: #0e0e24;
  --navy-80: #18183a;
  --navy-60: rgba(14, 14, 36, 0.7);
  --navy-15: rgba(200, 200, 255, 0.12);
  --navy-08: rgba(200, 200, 255, 0.07);
  --navy-05: rgba(200, 200, 255, 0.04);
  --ink: #e8eaed;
  --ink-muted: #b0b5bd;
  --ink-soft: #7f8694;
  --surface: #111122;
  --surface-low: #171730;
  --surface-lowest: #1c1c3a;
  --surface-high: #222244;
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.4);
  --sidebar-bg: var(--navy);
  --sidebar-text: #FFFFFF;
  --sidebar-text-muted: rgba(255, 255, 255, 0.6);
  --sidebar-text-soft: rgba(255, 255, 255, 0.35);
  --sidebar-hover: rgba(255, 255, 255, 0.04);
  --sidebar-active-bg: rgba(255, 102, 0, 0.14);
  --sidebar-active-text: #FFFFFF;
  --sidebar-border: transparent;
  --bar-bg: var(--surface-lowest);
  --bar-text: var(--ink);
  --bar-text-muted: var(--ink-muted);
  --bar-border: var(--navy-15);
  --banner-bg: var(--navy);
  --banner-text: #FFFFFF;
  --banner-text-muted: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] html, [data-theme="dark"] body { background: var(--surface); color: var(--ink); }

/* Dark topbar */
[data-theme="dark"] .topbar { background: var(--surface-lowest); border-bottom: 1px solid var(--navy-08); }
[data-theme="dark"] .topbar-search { border-color: var(--navy-08); }
[data-theme="dark"] .topbar-search:focus-within { border-color: var(--orange); }
[data-theme="dark"] .topbar-search input { color: var(--ink); }
[data-theme="dark"] .topbar-search kbd { background: var(--surface-high); color: var(--ink-soft); border-color: transparent; }

/* Dark cards */
[data-theme="dark"] .card { background: var(--surface-lowest); }
[data-theme="dark"] .stat-card { background: var(--surface-lowest); }
/* Dark tables */
[data-theme="dark"] .tbl tbody tr:hover { background: var(--surface-low); }
[data-theme="dark"] .tbl tbody tr + tr td { box-shadow: 0 -1px 0 var(--navy-08); }

/* Dark inputs */
[data-theme="dark"] .input { background: var(--surface-low); color: var(--ink); border-color: var(--navy-15); }
[data-theme="dark"] .input:focus { background: var(--surface-high); border-color: var(--orange); }
[data-theme="dark"] .input::placeholder { color: var(--ink-soft); }
[data-theme="dark"] .input.underline { box-shadow: inset 0 -2px 0 var(--navy-15); }

/* Dark badges keep readability */
[data-theme="dark"] .badge.success { background: var(--success-bg); color: var(--success); }
[data-theme="dark"] .badge.warn { background: var(--warn-bg); color: var(--warn); }
[data-theme="dark"] .badge.danger { background: var(--danger-bg); color: var(--danger); }
[data-theme="dark"] .badge.info { background: var(--info-bg); color: var(--info); }
[data-theme="dark"] .badge.neutral { background: var(--surface-high); color: var(--ink-muted); }

/* Dark chips */
[data-theme="dark"] .chip { background: var(--surface-high); color: var(--ink); }
[data-theme="dark"] .chip.group { background: rgba(96, 165, 250, 0.15); color: #93bbfd; }
[data-theme="dark"] .chip.group.prod { background: rgba(248, 113, 113, 0.15); color: #fca5a5; }
[data-theme="dark"] .chip.group.admin { background: rgba(167, 139, 250, 0.15); color: #c4b5fd; }

/* Dark buttons */
[data-theme="dark"] .btn-secondary { background: var(--surface-high); color: var(--ink); box-shadow: inset 0 0 0 1px var(--navy-15); }
[data-theme="dark"] .btn-secondary:hover { background: var(--surface-low); box-shadow: inset 0 0 0 1.5px var(--ink-soft); }
[data-theme="dark"] .btn-ghost { color: var(--ink-muted); }
[data-theme="dark"] .btn-ghost:hover { background: var(--surface-high); color: var(--ink); }

/* Dark modal */
[data-theme="dark"] .modal-scrim { background: rgba(0, 0, 0, 0.6); }
[data-theme="dark"] .modal { background: var(--surface-lowest); }

/* Dark toggle — keep accent tint visible on dark backgrounds */
[data-theme="dark"] .toggle { background: var(--orange-12); border-color: var(--orange-20); }
[data-theme="dark"] .toggle::after { background: var(--orange); opacity: 0.5; }
[data-theme="dark"] .toggle.on::after { background: #fff; opacity: 1; }
[data-theme="dark"] .toggle.submitted { background: var(--success); border-color: var(--success); }
[data-theme="dark"] .toggle.submitted::after { background: #fff; }

/* Dark checkbox */
[data-theme="dark"] .checkbox { background: var(--surface-low); box-shadow: inset 0 0 0 1.5px var(--navy-15); }

/* Dark scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(200, 200, 255, 0.15); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(200, 200, 255, 0.3); }

/* Dark timeline */
[data-theme="dark"] .timeline::before { background: var(--navy-15); }
[data-theme="dark"] .timeline-item::before { background: var(--surface-lowest); box-shadow: 0 0 0 2px var(--navy-15); }

/* Dark role-switcher */
[data-theme="dark"] .role-switcher { background: var(--surface-high); }
[data-theme="dark"] .role-switcher button:hover:not(.active) { background: var(--surface-low); }
[data-theme="dark"] .role-switcher button.active { background: var(--navy); color: #fff; }

/* Dark status pill */
[data-theme="dark"] .status-pill { background: var(--success-bg); color: var(--success); border-color: transparent; }

/* Dark login */
[data-theme="dark"] .login-shell { background: var(--surface); }
[data-theme="dark"] .login-card { background: var(--surface-lowest); }
[data-theme="dark"] .login-hero { background: var(--navy); }

/* Dark card-nav banner */
[data-theme="dark"] .card-nav { border: none; border-left: none; }

/* Dark kbd code */
[data-theme="dark"] .kbd-code { background: var(--surface-high); color: var(--ink); }

/* Dark tweaks panel */
[data-theme="dark"] .tweaks-panel { background: rgba(28, 28, 58, 0.95); color: var(--ink); }

/* Dark progress bar */
[data-theme="dark"] .progress { background: var(--surface-high); }

/* Dark degraded banner */
[data-theme="dark"] .degraded-banner { background: var(--warn-bg); color: var(--warn); }

/* Dark — neutralize light-mode border/shadow enhancements */
[data-theme="dark"] .stat-card { border-color: var(--navy-08); box-shadow: none; }
[data-theme="dark"] .card { border-color: var(--navy-08); box-shadow: none; }
[data-theme="dark"] .topbar { border-bottom-color: var(--navy-08); }
[data-theme="dark"] .role-switcher { border-color: transparent; }
/* input border handled in Dark inputs section */
[data-theme="dark"] select { border-color: var(--navy-15) !important; }
[data-theme="dark"] .progress { border-color: var(--navy-08); }
[data-theme="dark"] .stack-sm > div { box-shadow: none; }

/* Dark user-menu */
[data-theme="dark"] .user-menu:hover { background: var(--surface-high); }
[data-theme="dark"] .icon-btn:hover { background: var(--surface-high); color: var(--ink); }

/* Dark divider-text */
[data-theme="dark"] .divider-text { color: var(--ink-soft); }
[data-theme="dark"] .divider-text::before, [data-theme="dark"] .divider-text::after { background: var(--navy-15); }

/* ========== Responsive ========== */

/* Tablet — collapse grids to single column */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .content { padding: 28px 24px 48px; }
  .page-head h1 { font-size: 28px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .tbl { display: block; overflow-x: auto; }
}

/* Small tablet / large phone */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    width: 260px;
    z-index: 90;
    transition: left 0.25s ease;
  }
  .sidebar.open { left: 0; }
  .sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 89;
    display: none;
  }
  .sidebar-scrim.open { display: block; }
  .topbar { padding: 0 16px; gap: 12px; }
  .topbar-search { max-width: none; }
  .topbar-search kbd { display: none; }
  .status-pill { display: none; }
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-panel { padding: 32px 20px; }
}

/* Phone */
@media (max-width: 640px) {
  .content { padding: 20px 16px 40px; }
  .page-head { flex-direction: column; gap: 12px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .page-head h1 { font-size: 24px; }
  .stat-grid { grid-template-columns: 1fr; }
  .card-padded { padding: 20px; }
  .card { padding: 20px; }
  .tbl { font-size: 12px; }
  .tbl thead th { padding: 10px 8px; }
  .tbl tbody td { padding: 12px 8px; }
  .user-cell { gap: 8px; }
  .avatar { width: 30px; height: 30px; font-size: 11px; }
  .bulk-bar { left: 16px; right: 16px; transform: none; border-radius: var(--radius-lg); }
  @keyframes slideup {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  .modal { padding: 24px; width: calc(100vw - 32px); }
  .role-switcher { font-size: 11px; }
  .role-switcher button { padding: 5px 10px; }
  .btn { padding: 9px 14px; font-size: 12px; }
  .btn-sm { padding: 6px 10px; font-size: 11px; }

  /* PM dashboard user rows — hide less important columns on mobile */
  .pm-row-grid { grid-template-columns: 42px 1fr auto 36px !important; }
  .pm-row-grid .pm-col-expires,
  .pm-row-grid .pm-col-days,
  .pm-row-grid .pm-col-note { display: none; }

  .audit-filters-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 900px) {
  .pm-row-grid { grid-template-columns: 42px 1fr auto auto 36px !important; }
  .pm-row-grid .pm-col-note { display: none; }
}

/* Mobile hamburger button */
.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  flex-shrink: 0;
}
@media (max-width: 900px) {
  .hamburger { display: flex; }
}

/* ========== Mobile table improvements ========== */
@media (max-width: 640px) {
  /* Admin dashboard user queue - card layout on mobile */
  .tbl { font-size: 12px; }
  .tbl th, .tbl td { padding: 8px 6px; }

  /* Hide less-important columns on small screens */
  .tbl .col-hide-mobile { display: none; }

  /* Stat cards compact grid */
  .stats-grid, .stat-cards {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* Group chips overflow */
  .chip-list, .group-chips {
    display: flex;
    flex-wrap: nowrap;
    overflow: hidden;
    max-width: 120px;
  }

  /* Audit log table mobile */
  .audit-table td:nth-child(5),
  .audit-table th:nth-child(5),
  .audit-table td:nth-child(6),
  .audit-table th:nth-child(6) {
    display: none;
  }

  /* User menu compact */
  .user-menu .user-meta { display: none; }

  /* Topbar search compact */
  .topbar-search { max-width: 160px; }
  .topbar-search input { font-size: 12px; }
  .topbar-search kbd { display: none; }

  /* Status pill compact */
  .status-pill { font-size: 10px; padding: 4px 8px; }
}

/* Tablet - admin dashboard improvements */
@media (max-width: 900px) {
  /* Group pills overflow handling */
  .chip.group {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
