/* 2026-10-11: the Google Fonts @import for Inter was removed. The vault's Content-Security-Policy (core/security_headers.py)
   allows styles and fonts from this origin only, so the font never loaded -- every page logged a CSP error and fell back
   to the system fonts below, which is what people have always seen. A password manager should not call Google on every
   page; if Inter is wanted, self-host it under client_dist/ (font-src 'self'). */

:root {
  --navy:      #0a1428;
  --blue:      #1e5eff;
  --blue-dark: #0d3bc4;
  --blue-light:#e8f0ff;
  --cyan:      #06b6d4;
  --green:     #10b981;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --orange:    #f97316;
  --gray-50:   #f8fafc;
  --gray-100:  #f1f5f9;
  --gray-200:  #e2e8f0;
  --gray-300:  #cbd5e1;
  --gray-400:  #94a3b8;
  --gray-500:  #64748b;
  --gray-600:  #4b5563;
  --gray-700:  #374151;
  --white:     #ffffff;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius:    10px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.14);

  /* PasswordNexa accent — emerald #059669 (proposed, OD-14 still open) */
  --prod-emerald:     #059669;
  --app-accent:       #059669;
  --app-accent-light: #d1fae5;
  --app-accent-dark:  #047857;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--navy);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── APP SHELL ──────────────────────────────────────────────── */

body.app-page {
  /* height (not min-height) + overflow:hidden makes this a fixed-size
     viewport pane -- .sidebar and .app-main each get their own independent
     overflow-y below, so scrolling the page content never drags the
     sidebar nav along with it (and vice versa). .sidebar's existing
     position:sticky already visually pinned it during a whole-page scroll,
     but this makes the independence explicit and unambiguous rather than
     relying on sticky's containing-block behavior. */
  height: 100vh;
  overflow: hidden;
  background: var(--gray-50);
  display: flex;
}

body.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
}

.auth-container { width: 100%; padding: 1.5rem; display: flex; justify-content: center; }
.auth-card { background: var(--white); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 2rem; width: 100%; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--navy);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: relative;
}

.sidebar-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  position: absolute; top: 0.15rem; right: 0.6rem;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: none;
  color: rgba(255,255,255,0.7); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.18); color: var(--white); }
.sidebar-collapse-btn svg { width: 13px; height: 13px; }

.sidebar-logo .app-wordmark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

.sidebar-logo .app-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--app-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo .app-icon svg { width: 20px; height: 20px; color: #fff; }

.sidebar-logo .app-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.02em;
}

.sidebar-org {
  display: block;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
  margin-top: 0.75rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav { flex: 1; padding: 1.25rem 0.75rem; }

.nav-section {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.35);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 0.75rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.10);
  color: var(--white);
}

.nav-item.active {
  background: rgba(124,58,237,0.25);
  color: #c4b5fd;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--app-accent); color: #fff;
  border-radius: 999px; font-size: 0.65rem; font-weight: 700; margin-left: auto;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user-name { display: block; font-size: 0.875rem; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { display: block; font-size: 0.75rem; color: rgba(255,255,255,0.5); text-transform: capitalize; }

.sidebar-footer-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.sidebar-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.65);
  text-decoration: none; border: none; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-icon-btn:hover { background: rgba(255,255,255,0.15); color: var(--white); }
.sidebar-icon-btn svg { width: 14px; height: 14px; }

/* ─── MAIN CONTENT ───────────────────────────────────────────── */

.app-main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 2rem 2.5rem;
}

.page-header {
  margin-bottom: 1.75rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.2rem;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--gray-500);
}

.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* ─── STAT CARDS ─────────────────────────────────────────────── */

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

.stat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--navy);
  margin-top: 0.2rem;
  line-height: 1;
}

.stat-delta {
  font-size: 0.78rem;
  color: var(--gray-500);
  margin-top: 0.35rem;
}

.stat-delta.up   { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ─── CARDS ──────────────────────────────────────────────────── */

.card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

/* Table-containing cards always get horizontal scroll if the table is
   wider than the card (many columns visible via the Columns picker,
   tablet widths, a narrowed browser window, etc) instead of silently
   clipping columns via the base overflow:hidden above. Applies at every
   width, not just the ≤768px mobile breakpoint, since overflow:hidden
   was clipping columns well above that too (the actual tablet bug). */
.card:has(.table) { overflow-x: auto; }

.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-header h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.card-header h3 { font-size: 0.9rem; font-weight: 600; margin: 0; }

.card-body { padding: 1.5rem; }
.card-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--gray-400);
  font-size: 0.9rem;
}

/* ─── TABLES ─────────────────────────────────────────────────── */

.table { width: 100%; border-collapse: collapse; }

.table th {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }

/* ─── BADGES ─────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef3c7; color: #b45309; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-gray   { background: var(--gray-100); color: var(--gray-500); }
.badge-blue   { background: var(--blue-light); color: var(--blue-dark); }
.badge-cyan   { background: #cffafe; color: #0e7490; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-violet { background: #ede9fe; color: #6d28d9; }
.badge-purple { background: #f3e8ff; color: #7c3aed; }

/* ─── BUTTONS ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-primary   { background: var(--app-accent); color: var(--white); border-color: var(--app-accent); }
.btn-primary:hover { background: var(--app-accent-dark); border-color: var(--app-accent-dark); }

.btn-secondary { background: var(--blue); color: var(--white); border-color: var(--blue); }
.btn-secondary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }

.btn-outline { background: transparent; color: var(--navy); border-color: var(--gray-200); }
.btn-outline:hover { border-color: var(--navy); }

.btn-danger { background: var(--red); color: var(--white); border-color: var(--red); }
.btn-danger:hover { background: #dc2626; }

.btn-sm  { padding: 0.35rem 0.875rem; font-size: 0.8rem; }
.btn-xs  { padding: 0.25rem 0.6rem;   font-size: 0.75rem; }
.btn-full { width: 100%; justify-content: center; }

/* ─── FORMS ──────────────────────────────────────────────────── */

.form-group { margin-bottom: 1.1rem; }

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="password"],
.form-group input[type="search"],
.form-group input[type="url"],
.form-group select,
.form-group textarea,
.form-control {
  width: 100%;
  padding: 0.6rem 0.875rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--navy);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-control:focus {
  border-color: var(--app-accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }

.form-hint   { font-size: 0.78rem; color: var(--gray-500); margin-top: 0.25rem; }
.form-error  { font-size: 0.78rem; color: var(--red); margin-top: 0.25rem; }

/* ─── ALERTS ─────────────────────────────────────────────────── */

.messages-container { margin-bottom: 1.25rem; }
.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.875rem; margin-bottom: 0.5rem; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error, .alert-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef9c3; color: #a16207; border: 1px solid #fde047; }
.alert-info { background: var(--blue-light); color: var(--blue-dark); border: 1px solid #bfdbfe; }

/* ─── SEARCH BAR ─────────────────────────────────────────────── */

.search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.search-bar input {
  flex: 1;
  padding: 0.6rem 0.875rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus { border-color: var(--app-accent); }

/* ─── EMPTY STATE ────────────────────────────────────────────── */

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state-icon {
  width: 56px; height: 56px;
  background: var(--gray-100);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  color: var(--gray-400);
}

.empty-state-icon svg { width: 28px; height: 28px; }

.empty-state h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.4rem; }
.empty-state p  { font-size: 0.875rem; color: var(--gray-500); margin-bottom: 1.25rem; }

/* ─── QUICK ACTION CARDS ─────────────────────────────────────── */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.quick-action-card {
  display: flex; align-items: center; gap: 0.875rem;
  padding: 1rem 1.25rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--navy);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.quick-action-card:hover { box-shadow: var(--shadow-md); border-color: var(--app-accent); }
.quick-action-card strong { display: block; font-size: 0.9rem; }
.quick-action-card p { font-size: 0.78rem; color: var(--gray-500); margin: 0.1rem 0 0; }

.quick-action-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.quick-action-icon svg { width: 20px; height: 20px; }
.quick-action-icon.violet { background: #ede9fe; color: #7c3aed; }
.quick-action-icon.green  { background: #dcfce7; color: #16a34a; }
.quick-action-icon.yellow { background: #fef9c3; color: #a16207; }
.quick-action-icon.orange { background: #ffedd5; color: #ea580c; }
.quick-action-icon.navy   { background: rgba(10,20,40,0.07); color: var(--navy); }

/* ─── PAGINATION ─────────────────────────────────────────────── */

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--gray-100);
  font-size: 0.8rem;
  color: var(--gray-500);
}

.pagination-links { display: flex; gap: 0.25rem; }
.pagination-links a, .pagination-links span {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--navy);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--gray-200);
}
.pagination-links a:hover { background: var(--gray-50); border-color: var(--gray-400); }
.pagination-links .current { background: var(--app-accent); color: #fff; border-color: var(--app-accent); }

/* ─── CUSTODY CHAIN TIMELINE ─────────────────────────────────── */

.custody-timeline {
  position: relative;
  padding-left: 1.25rem;
}

.custody-timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.custody-event {
  position: relative;
  padding-bottom: 1rem;
}

.custody-event:last-child {
  padding-bottom: 0;
}

.custody-dot {
  position: absolute;
  left: -1.5rem;
  top: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--app-accent);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 1px var(--app-accent);
}

.custody-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy);
}

.custody-notes {
  font-size: 0.8rem;
  color: var(--gray-600);
  margin-top: 0.15rem;
}

.custody-time {
  font-size: 0.72rem;
  color: var(--gray-400);
  margin-top: 0.15rem;
}

/* ─── MOBILE TOPBAR / DRAWER SIDEBAR (hidden on desktop) ───────── */

.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.sidebar-close { display: none; }
.mobile-topbar-portal { display: none; }
.mobile-topbar-back { display: none; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */

@media (max-width: 768px) {
  body.app-page { display: block; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    height: 56px;
    padding: 0 1.1rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
    position: sticky;
    top: 0;
    z-index: 120;
  }
  .mobile-topbar-toggle, .mobile-topbar-back {
    background: none; border: none; cursor: pointer; padding: 0.3rem;
    color: var(--navy); display: flex; align-items: center;
  }
  .mobile-topbar-toggle svg, .mobile-topbar-back svg { width: 22px; height: 22px; }
  .mobile-topbar-title { font-size: 1rem; font-weight: 800; color: var(--navy); }
  .mobile-topbar-portal {
    display: flex; align-items: center; justify-content: center;
    margin-left: auto; color: var(--navy); padding: 0.35rem;
  }
  .mobile-topbar-portal svg { width: 20px; height: 20px; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 260px;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 300;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-logo { position: relative; }
  .sidebar-close {
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; cursor: pointer; color: rgba(255,255,255,0.7); padding: 0.2rem;
    position: absolute; top: 0; right: 1.1rem;
  }
  .sidebar-close svg { width: 18px; height: 18px; }
  .sidebar-collapse-btn { top: 0; right: 2.9rem; }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(10,20,40,0.5);
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-backdrop.active { opacity: 1; pointer-events: auto; }

  .app-main { padding: 1.25rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .page-title-row { flex-direction: column; }
  .quick-actions { grid-template-columns: 1fr 1fr; }

  .card { overflow-x: auto; }
  .table { min-width: 520px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
}

/* ─── VIEW TOGGLE: Desktop ⇄ Mobile Web (manual override) ────────
   Lets a user force the mobile (off-canvas drawer) layout on a wide
   desktop window, or force the desktop layout on an actual narrow
   device -- independent of the real @media (max-width:768px) rules
   above. No CSS nesting/build step in this codebase, so the mobile
   ruleset is deliberately duplicated here rather than shared; keep
   both blocks in sync if the responsive layout above ever changes.
   Toggled via the floating "Switch to Mobile/Desktop Site" button
   injected by view-toggle.js (see base_app.html), which sets
   html.force-mobile-view / html.force-desktop-view and persists the
   choice in localStorage so it holds across every page. */
html.force-mobile-view body.app-page { display: block; }
html.force-mobile-view .mobile-topbar {
  display: flex; align-items: center; gap: 0.9rem; height: 56px; padding: 0 1.1rem;
  background: var(--white); border-bottom: 1px solid var(--gray-100);
  position: sticky; top: 0; z-index: 120;
}
html.force-mobile-view .mobile-topbar-toggle, html.force-mobile-view .mobile-topbar-back {
  background: none; border: none; cursor: pointer; padding: 0.3rem; color: var(--navy); display: flex; align-items: center;
}
html.force-mobile-view .mobile-topbar-toggle svg, html.force-mobile-view .mobile-topbar-back svg { width: 22px; height: 22px; }
html.force-mobile-view .mobile-topbar-title { font-size: 1rem; font-weight: 800; color: var(--navy); }
html.force-mobile-view .mobile-topbar-portal { display: flex; align-items: center; justify-content: center; margin-left: auto; color: var(--navy); padding: 0.35rem; }
html.force-mobile-view .mobile-topbar-portal svg { width: 20px; height: 20px; }
html.force-mobile-view .sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: 260px; max-width: 82vw;
  transform: translateX(-100%); transition: transform 0.25s ease; z-index: 300;
}
html.force-mobile-view .sidebar.open { transform: translateX(0); }
html.force-mobile-view .sidebar-logo { position: relative; }
html.force-mobile-view .sidebar-close {
  display: flex; align-items: center; justify-content: center; background: none; border: none;
  cursor: pointer; color: rgba(255,255,255,0.7); padding: 0.2rem; position: absolute; top: 0; right: 1.1rem;
}
html.force-mobile-view .sidebar-close svg { width: 18px; height: 18px; }
html.force-mobile-view .sidebar-collapse-btn { top: 0; right: 2.9rem; }
html.force-mobile-view .sidebar-backdrop {
  display: block; position: fixed; inset: 0; background: rgba(10,20,40,0.5); z-index: 250;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
html.force-mobile-view .sidebar-backdrop.active { opacity: 1; pointer-events: auto; }
html.force-mobile-view .app-main { padding: 1.25rem; }
html.force-mobile-view .stat-grid { grid-template-columns: 1fr; }
html.force-mobile-view .form-row-2, html.force-mobile-view .form-row-3 { grid-template-columns: 1fr; }
html.force-mobile-view .page-title-row { flex-direction: column; }
html.force-mobile-view .quick-actions { grid-template-columns: 1fr; }
html.force-mobile-view .card { overflow-x: auto; }
html.force-mobile-view .table { min-width: 520px; }

html.force-desktop-view .mobile-topbar,
html.force-desktop-view .sidebar-backdrop,
html.force-desktop-view .sidebar-close,
html.force-desktop-view .mobile-topbar-portal,
html.force-desktop-view .mobile-topbar-back { display: none; }
html.force-desktop-view body.app-page { display: flex; height: 100vh; overflow: hidden; }
html.force-desktop-view .sidebar {
  position: sticky; top: 0; left: auto; height: 100vh; width: 240px; max-width: none;
  transform: none; transition: none; z-index: auto; overflow-y: auto;
}
html.force-desktop-view .app-main { height: 100vh; overflow-y: auto; padding: 2rem 2.5rem; }
html.force-desktop-view .stat-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
html.force-desktop-view .form-row-2 { grid-template-columns: 1fr 1fr; }
html.force-desktop-view .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
html.force-desktop-view .page-title-row { flex-direction: row; }
html.force-desktop-view .quick-actions { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* ─── SIDEBAR COLLAPSE (desktop only, manual) ────────────────────
   Shrinks the sidebar to an icon-only rail. Expanded by default;
   state persists via localStorage in sidebar-toggle.js, which also
   applies html.sidebar-collapsed before first paint (see base.html)
   to avoid a flash of the expanded sidebar. Deliberately inert on
   the mobile off-canvas drawer (:not(.force-mobile-view) / the
   768px guard below) -- collapsing a full-width drawer to a narrow
   rail doesn't apply there. */
@media (min-width: 769px) {
  html.sidebar-collapsed:not(.force-mobile-view) .sidebar { width: 64px; }
  html.sidebar-collapsed:not(.force-mobile-view) .sidebar-logo { padding: 0 0.6rem 1.25rem; }
  html.sidebar-collapsed:not(.force-mobile-view) .sidebar-logo .app-wordmark { justify-content: center; }
  html.sidebar-collapsed:not(.force-mobile-view) .sidebar-collapse-btn { position: static; margin: 0 auto 0.5rem; }
  html.sidebar-collapsed:not(.force-mobile-view) .sidebar-logo .app-name,
  html.sidebar-collapsed:not(.force-mobile-view) .sidebar-org,
  html.sidebar-collapsed:not(.force-mobile-view) .nav-section,
  html.sidebar-collapsed:not(.force-mobile-view) .nav-item span,
  html.sidebar-collapsed:not(.force-mobile-view) .nav-badge,
  html.sidebar-collapsed:not(.force-mobile-view) .sidebar-user-name,
  html.sidebar-collapsed:not(.force-mobile-view) .sidebar-user-role { display: none; }
  html.sidebar-collapsed:not(.force-mobile-view) .nav-item { justify-content: center; padding: 0.6rem; margin-bottom: 4px; }
  html.sidebar-collapsed:not(.force-mobile-view) .sidebar-footer { padding: 1rem 0.6rem; }
  html.sidebar-collapsed:not(.force-mobile-view) .sidebar-footer-actions { flex-direction: column; align-items: center; }
}
html.force-desktop-view.sidebar-collapsed .sidebar { width: 64px; }
html.force-desktop-view.sidebar-collapsed .sidebar-logo { padding: 0 0.6rem 1.25rem; }
html.force-desktop-view.sidebar-collapsed .sidebar-logo .app-wordmark { justify-content: center; }
html.force-desktop-view.sidebar-collapsed .sidebar-collapse-btn { position: static; margin: 0 auto 0.5rem; }
html.force-desktop-view.sidebar-collapsed .sidebar-logo .app-name,
html.force-desktop-view.sidebar-collapsed .sidebar-org,
html.force-desktop-view.sidebar-collapsed .nav-section,
html.force-desktop-view.sidebar-collapsed .nav-item span,
html.force-desktop-view.sidebar-collapsed .nav-badge,
html.force-desktop-view.sidebar-collapsed .sidebar-user-name,
html.force-desktop-view.sidebar-collapsed .sidebar-user-role { display: none; }
html.force-desktop-view.sidebar-collapsed .nav-item { justify-content: center; padding: 0.6rem; margin-bottom: 4px; }
html.force-desktop-view.sidebar-collapsed .sidebar-footer { padding: 1rem 0.6rem; }
html.force-desktop-view.sidebar-collapsed .sidebar-footer-actions { flex-direction: column; align-items: center; }

/* Collapse also applies inside the mobile off-canvas drawer, same rail
   treatment and icons as desktop -- shrinks the OPEN drawer from 260px
   down to a 64px icon rail instead of being inert there. Close (X) and
   collapse buttons switch from side-by-side to stacked/centered since
   64px isn't wide enough for both side by side. */
@media (max-width: 768px) {
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar { width: 64px; max-width: 64px; }
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar-logo { padding: 0 0.6rem 1.25rem; }
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar-logo .app-wordmark { justify-content: center; }
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar-close,
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar-collapse-btn { position: static; margin: 0 auto 0.4rem; }
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar-logo .app-name,
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar-org,
  html.sidebar-collapsed:not(.force-desktop-view) .nav-section,
  html.sidebar-collapsed:not(.force-desktop-view) .nav-item span,
  html.sidebar-collapsed:not(.force-desktop-view) .nav-badge,
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar-user-name,
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar-user-role { display: none; }
  html.sidebar-collapsed:not(.force-desktop-view) .nav-item { justify-content: center; padding: 0.6rem; margin-bottom: 4px; }
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar-footer { padding: 1rem 0.6rem; }
  html.sidebar-collapsed:not(.force-desktop-view) .sidebar-footer-actions { flex-direction: column; align-items: center; }
}
html.force-mobile-view.sidebar-collapsed .sidebar { width: 64px; max-width: 64px; }
html.force-mobile-view.sidebar-collapsed .sidebar-logo { padding: 0 0.6rem 1.25rem; }
html.force-mobile-view.sidebar-collapsed .sidebar-logo .app-wordmark { justify-content: center; }
html.force-mobile-view.sidebar-collapsed .sidebar-close,
html.force-mobile-view.sidebar-collapsed .sidebar-collapse-btn { position: static; margin: 0 auto 0.4rem; }
html.force-mobile-view.sidebar-collapsed .sidebar-logo .app-name,
html.force-mobile-view.sidebar-collapsed .sidebar-org,
html.force-mobile-view.sidebar-collapsed .nav-section,
html.force-mobile-view.sidebar-collapsed .nav-item span,
html.force-mobile-view.sidebar-collapsed .nav-badge,
html.force-mobile-view.sidebar-collapsed .sidebar-user-name,
html.force-mobile-view.sidebar-collapsed .sidebar-user-role { display: none; }
html.force-mobile-view.sidebar-collapsed .nav-item { justify-content: center; padding: 0.6rem; margin-bottom: 4px; }
html.force-mobile-view.sidebar-collapsed .sidebar-footer { padding: 1rem 0.6rem; }
html.force-mobile-view.sidebar-collapsed .sidebar-footer-actions { flex-direction: column; align-items: center; }

@media print {
  .sidebar, .sidebar-backdrop, .mobile-topbar, .messages-container, .no-print { display: none !important; }
  .app-main { padding: 0 !important; margin: 0 !important; }
  .card { box-shadow: none !important; border: none !important; overflow: visible !important; }
  .table { min-width: 0 !important; }
  body { background: #fff !important; }
  a { color: inherit !important; text-decoration: none !important; }
}
