/* ================================================================
   Enterprise Unified System — Design Tokens & Theme
   ================================================================ */

/* ─── Light Mode (default) ─────────────────────────────────────── */

:root {
  /* Purple scale */
  --purple-50:  #faf5ff;
  --purple-100: #f3e8f8;
  --purple-200: #e1c4ed;
  --purple-300: #cd9ee1;
  --purple-400: #b573d2;
  --purple-500: #9c4ec1;
  --purple-600: #6c2a80;
  --purple-700: #5a226b;
  --purple-800: #481b56;
  --purple-900: #361341;
  --purple-950: #1a0a2e;

  /* Core theme tokens */
  --theme:           var(--purple-600);
  --theme-light:     var(--purple-50);
  --theme-dark:      var(--purple-900);
  --theme-text:      var(--purple-800);
  --theme-accent:    var(--purple-400);
  --top-bar-accent:  var(--purple-300);
  --top-bar-module-bg:     var(--sidebar-active-bg);
  --top-bar-module-text:   var(--purple-700);
  --top-bar-module-border: var(--purple-200);
  --top-bar-module-dot:    var(--purple-500);

  /* Semantic */
  --success:      #16a34a;
  --success-bg:   #dcfce7;
  --success-text: #166534;

  --warning:      #f59e0b;
  --warning-bg:   #fef3c7;
  --warning-text: #92400e;

  --danger:       #dc2626;
  --danger-bg:    #fce4ec;
  --danger-text:  #c62828;

  --info:         #2563eb;
  --info-bg:      #dbeafe;
  --info-text:    #1e40af;

  /* Neutral */
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Theme surfaces */
  --surface:        #f1f5f9;
  --surface-card:   #ffffff;
  --surface-elevated: #ffffff;
  --text-primary:   #0f172a;
  --text-secondary: #64748b;
  --text-inverse:   #ffffff;
  --border:         #e2e8f0;
  --border-light:   #f1f5f9;

  /* Glass tokens */
  --glass-bg:        rgba(255, 255, 255, 0.08);
  --glass-bg-strong: rgba(255, 255, 255, 0.14);
  --glass-border:    rgba(255, 255, 255, 0.12);
  --glass-blur:      8px;
  --glass-shadow:    0 4px 24px rgba(0, 0, 0, 0.12);

  /* Morph tokens */
  --morph-outset: 0 2px 0 var(--gray-300), 0 4px 8px rgba(0,0,0,0.08);
  --morph-inset:  inset 0 1px 2px rgba(0,0,0,0.12);

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono:   'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs:  11px;
  --text-sm:  12px;
  --text-base: 14px;
  --text-md:  15px;
  --text-lg:  18px;
  --text-xl:  22px;
  --text-2xl: 28px;
  --text-3xl: 32px;

  /* Spacing */
  --space-0: 0px;
  --space-01: 1.5px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border radius */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-full: 9999px;

  /* Buttons */
  --btn-h-mobile: 44px;         /* standard touch target ≤1023px */
  --btn-h-compact: 28px;        /* .btn-sm / .btn-row (table actions) */
  --btn-h-modal: 35px;          /* .btn-modal */
  --btn-form-h-mobile: var(--btn-h-mobile);
  --btn-card-h-mobile: var(--btn-h-mobile);
  --btn-dash-h-mobile: var(--btn-h-mobile);

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg:  0 4px 12px rgba(0,0,0,0.1);
  --shadow-xl:  0 8px 24px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 20px rgba(108,42,128,0.25);

  /* Sidebar */
  /* Top-bar inset from the viewport edges (top/left/right); page header aligns to it. */
  --topbar-inset: 2px;
  /* Bottom edge of the fixed .top-bar (top: var(--topbar-inset) + height: 56px). */
  /* Sticky page furniture anchors to this. */
  --topbar-bottom: calc(var(--topbar-inset) + 56px);
  /* Sticky filter bar parks just below the sticky page header. */
  --page-header-h: 65px;

  --sidebar-width: 240px;
  --sidebar-bg: var(--surface);
  --sidebar-border: var(--border);
  --sidebar-text: var(--gray-700);
  --sidebar-text-hover: #0f172a;
  --sidebar-text-active: var(--gray-900);
  --sidebar-user-name: var(--gray-900);
  --sidebar-nav-divider: var(--gray-400);
  --sidebar-hover-bg: rgba(108, 42, 128, 0.08);
  --sidebar-active-bg: rgba(108, 42, 128, 0.15);
  --sidebar-active-border: var(--purple-500);
  --sidebar-version: var(--gray-400);
}

/* ─── Dark Mode ────────────────────────────────────────────────── */

[data-theme="dark"] {
  --surface:        #0f172a;
  --surface-card:   #1e293b;
  --surface-elevated: #334155;
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-inverse:   #0f172a;
  --border:         #334155;
  --border-light:   #475569;

  --glass-bg:        rgba(0, 0, 0, 0.25);
  --glass-bg-strong: rgba(0, 0, 0, 0.35);
  --glass-border:    rgba(255, 255, 255, 0.06);

  --morph-outset: 0 2px 0 #1e293b, 0 4px 8px rgba(0,0,0,0.3);

  --sidebar-bg: var(--surface);
  --sidebar-border: var(--glass-border);
  --sidebar-text: var(--gray-300);
  --sidebar-text-hover: #ffffff;
  --sidebar-text-active: #ffffff;
  --sidebar-user-name: #ffffff;
  --sidebar-nav-divider: rgba(255, 255, 255, 0.24);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.12);
  --sidebar-active-bg: rgba(108, 42, 128, 0.3);
  --top-bar-module-text:   var(--purple-300);
  --top-bar-module-border: rgba(156, 78, 193, 0.35);
  --top-bar-module-dot:    var(--purple-400);
  --sidebar-active-border: var(--purple-500);
  --sidebar-version: rgba(255, 255, 255, 0.2);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-xl: 0 8px 24px rgba(0,0,0,0.5);
}

/* ─── Auth page theme overrides ───────────────────────────────── */
/* Each page gets its own light block for full granularity.
   Same-element selectors for auth-* classes that carry the page class.
   Descendant selectors for h1, p, a (no page class on those). */

/* ================================================================
   Login page
   ================================================================ */
[data-theme="light"] .main-page {
  background:
    radial-gradient(circle at 20% 80%, rgba(124,58,237,0.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(108,42,128,0.08) 0%, transparent 50%),
    linear-gradient(135deg,#f5f3ff,#ede9fe);
}
[data-theme="light"] .login-page.auth-card {
  background: rgba(255,255,255,0.85);
  border-color: rgba(124,58,237,0.15);
  box-shadow: 0 0 0 1px rgba(124,58,237,0.10), 0 8px 32px rgba(0,0,0,0.06);
}
[data-theme="light"] .login-page.auth-card::after { opacity: 0; }
[data-theme="light"] .login-page.auth-card h1 { color: var(--text-primary); }
[data-theme="light"] .login-page.auth-subtitle { color: var(--text-secondary); }
[data-theme="light"] .login-page.auth-card .auth-icon { stroke: var(--gray-500); }
[data-theme="light"] .login-page.auth-label { color: var(--text-primary); }
[data-theme="light"] .login-page.auth-field .icon { color: var(--gray-400); }
[data-theme="light"] .login-page.auth-input { color: var(--text-primary); background: white; border-color: var(--border); }
[data-theme="light"] .login-page.auth-input::placeholder { color: var(--gray-400); }
[data-theme="light"] .login-page.auth-input:focus { border-color: var(--purple-400); box-shadow: 0 0 0 3px rgba(124,58,237,0.15); background: white; }
[data-theme="light"] .login-page.auth-input:-webkit-autofill,
[data-theme="light"] .login-page.auth-input:-webkit-autofill:hover,
[data-theme="light"] .login-page.auth-input:-webkit-autofill:focus { -webkit-text-fill-color: var(--text-primary) !important; caret-color: var(--text-primary) !important; }
[data-theme="light"] .login-page.auth-eye-btn { color: var(--gray-400); }
[data-theme="light"] .login-page.auth-eye-btn:hover { color: var(--gray-600); }
[data-theme="light"] .login-page.auth-remember { color: var(--text-secondary); }
[data-theme="light"] .login-page.auth-footer a { color: var(--purple-600); }
[data-theme="light"] .login-page.auth-footer a:hover { color: var(--purple-700); }
[data-theme="light"] .login-page.app_version { color: var(--gray-400); }

/* ================================================================
   Recover page
   ================================================================ */
[data-theme="light"] .recover-page.auth-card {
  background: rgba(255,255,255,0.85);
  border-color: rgba(124,58,237,0.15);
  box-shadow: 0 0 0 1px rgba(124,58,237,0.10), 0 8px 32px rgba(0,0,0,0.06);
}
[data-theme="light"] .recover-page.auth-card::after { opacity: 0; }
[data-theme="light"] .recover-page.auth-card h1 { color: var(--text-primary); }
[data-theme="light"] .recover-page.auth-subtitle { color: var(--text-secondary); }
[data-theme="light"] .recover-page.auth-label { color: var(--text-primary); }
[data-theme="light"] .recover-page.auth-field .icon { color: var(--gray-400); }
[data-theme="light"] .recover-page.auth-input { color: var(--text-primary); background: white; border-color: var(--border); }
[data-theme="light"] .recover-page.auth-input::placeholder { color: var(--gray-400); }
[data-theme="light"] .recover-page.auth-input:focus { border-color: var(--purple-400); box-shadow: 0 0 0 3px rgba(124,58,237,0.15); background: white; }
[data-theme="light"] .recover-page.auth-input:-webkit-autofill,
[data-theme="light"] .recover-page.auth-input:-webkit-autofill:hover,
[data-theme="light"] .recover-page.auth-input:-webkit-autofill:focus { -webkit-text-fill-color: var(--text-primary) !important; caret-color: var(--text-primary) !important; }
[data-theme="light"] .recover-page.auth-footer a { color: var(--purple-600); }
[data-theme="light"] .recover-page.auth-footer a:hover { color: var(--purple-700); }
[data-theme="light"] .recover-page.app_version { color: var(--gray-400); }

/* ================================================================
   Reset page
   ================================================================ */
[data-theme="light"] .reset-page.auth-card {
  background: rgba(255,255,255,0.85);
  border-color: rgba(124,58,237,0.15);
  box-shadow: 0 0 0 1px rgba(124,58,237,0.10), 0 8px 32px rgba(0,0,0,0.06);
}
[data-theme="light"] .reset-page.auth-card::after { opacity: 0; }
[data-theme="light"] .reset-page.auth-card h1 { color: var(--text-primary); }
[data-theme="light"] .reset-page.auth-subtitle { color: var(--text-secondary); }
[data-theme="light"] .reset-page.auth-label { color: var(--text-primary); }
[data-theme="light"] .reset-page.auth-field .icon { color: var(--gray-400); }
[data-theme="light"] .reset-page.auth-input { color: var(--text-primary); background: white; border-color: var(--border); }
[data-theme="light"] .reset-page.auth-input::placeholder { color: var(--gray-400); }
[data-theme="light"] .reset-page.auth-input:focus { border-color: var(--purple-400); box-shadow: 0 0 0 3px rgba(124,58,237,0.15); background: white; }
[data-theme="light"] .reset-page.auth-input:-webkit-autofill,
[data-theme="light"] .reset-page.auth-input:-webkit-autofill:hover,
[data-theme="light"] .reset-page.auth-input:-webkit-autofill:focus { -webkit-text-fill-color: var(--text-primary) !important; caret-color: var(--text-primary) !important; }
[data-theme="light"] .reset-page.auth-eye-btn { color: var(--gray-400); }
[data-theme="light"] .reset-page.auth-eye-btn:hover { color: var(--gray-600); }
[data-theme="light"] .reset-page.auth-footer a { color: var(--purple-600); }
[data-theme="light"] .reset-page.auth-footer a:hover { color: var(--purple-700); }
[data-theme="light"] .reset-page.app_version { color: var(--gray-400); }

/* ================================================================
   Recovery-sent page
   ================================================================ */
[data-theme="light"] .recovery-sent-page.auth-card {
  background: rgba(255,255,255,0.85);
  border-color: rgba(124,58,237,0.15);
  box-shadow: 0 0 0 1px rgba(124,58,237,0.10), 0 8px 32px rgba(0,0,0,0.06);
}
[data-theme="light"] .recovery-sent-page.auth-card::after { opacity: 0; }
[data-theme="light"] .recovery-sent-page.auth-card h1 { color: var(--text-primary); }
[data-theme="light"] .recovery-sent-page.auth-subtitle { color: var(--text-secondary); }
[data-theme="light"] .recovery-sent-page.auth-card .auth-icon { stroke: var(--gray-500); }
[data-theme="light"] .recovery-sent-page.app_version { color: var(--gray-400); }

/* ================================================================
   License page (license-blocked)
   ================================================================ */
[data-theme="light"] .license-page.auth-card {
  background: rgba(255,255,255,0.85);
  border-color: rgba(124,58,237,0.15);
  box-shadow: 0 0 0 1px rgba(124,58,237,0.10), 0 8px 32px rgba(0,0,0,0.06);
}
[data-theme="light"] .license-page.auth-card::after { opacity: 0; }
[data-theme="light"] .license-page.auth-card h1 { color: var(--text-primary); }
[data-theme="light"] .license-page.auth-subtitle { color: var(--text-secondary); }
[data-theme="light"] .license-page.app_version { color: var(--gray-400); }
/* ================================================================
[data-theme="dark"] .login-page.auth-page,
[data-theme="dark"] .recover-page.auth-page,
[data-theme="dark"] .reset-page.auth-page,
[data-theme="dark"] .recovery-sent-page.auth-page,
[data-theme="dark"] .license-page.auth-page {
  --glass-bg:     rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.08);
}

/* ─── Base  ────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  background: var(--purple-950);
}

/* Hard right edge for the layout viewport: no document element can ever
   widen the page and cause sideways scrolling / right-side clipping.
   `clip` does not create a scroll container, so sticky positioning and
   inner horizontal scrollers (.table-container) keep working. */
html, body {
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface);
  opacity: 0;
  transition: opacity 0.3s ease;
}

body.ready {
  opacity: 1;
}

/* ================================================================
   Enterprise Unified System — Layout
   Sidebar, topbar, main content area, responsive layout, print
   ================================================================ */

/* ─── Sidebar ──────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: var(--topbar-inset);
  left: var(--topbar-inset);
  width: var(--sidebar-width);
  bottom: var(--topbar-inset);
  height: auto;
  overflow: hidden;
  z-index: 102;
  background: var(--sidebar-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-right: 1px solid var(--sidebar-border);
  border-radius: 6px;
  box-shadow: 0 10px 12px rgba(0, 0, 0, 0.08),
              0 0 0 1px var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(-100% - var(--topbar-inset)));
  transition: transform 0.70s ease-in-out;
}

.sidebar-body::-webkit-scrollbar {
  display: none;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

/* Left viewport edge — hover opens the sidebar flyout on desktop */
.sidebar-hover-zone {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 8px;
  z-index: 103;
}

@media (max-width: 639px) {
  .sidebar-hover-zone {
    display: none;
  }
}

.sidebar-user {
  padding: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-user-label {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--sidebar-user-name);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--purple-600);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-text {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
}

.avatar-sm {
  width: 32px;
  height: 32px;
}

.avatar-sm .avatar-text {
  font-size: 11px;
}

.user-avatar-icon {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 6px;
  color: var(--gray-400);
  transition: color 0.2s, background 0.2s;
}

.user-meta {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.user-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--sidebar-user-name);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta .badge {
  font-size: 10px;
}

/* Single inset-ring panel wrapping brand + user + nav */
.sidebar-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  scrollbar-color: transparent transparent;
  box-shadow: inset 0px 0px 3px 0px var(--gray-400);
}

.sidebar-brand {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--sidebar-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  padding: var(--space-4) var(--space-5);
  box-shadow: inset 0px 0px 3px 0px var(--gray-400);
  border-radius: 6px 6px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar-brand-actions {
  display: none;
  align-items: center;
  width: 100%;
  margin-bottom: var(--space-2);
}

.sidebar-brand-spacer {
  flex: 1;
}

.sidebar.open .sidebar-brand-actions {
  display: flex;
}

.sidebar.open ~ .main-body .top-bar .hamburger {
  display: none;
}

.sidebar-logo {
  width: 110px;
  height: auto;
  object-fit: contain;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.sidebar-logo--fallback {
  width: 110px;
  height: auto;
  color: var(--sidebar-text);
  transition: color 0.2s ease;
}

.sidebar-nav {
  position: relative;
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
}

/* Sliding rounded-pill accent: positioned over items by 08-delegation.js. z-index must stay above .sidebar-nav li (z-index 1) so the pill paints over the expanded group's background. */
.sidebar-nav .sidebar-nav-indicator {
  position: absolute;
  top: 0;
  left: var(--space-2);
  right: var(--space-2);
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--sidebar-active-bg);
  box-shadow: 0 2px 8px rgba(108, 42, 128, 0.12);
  pointer-events: none;
  z-index: 2;
  border-bottom: none;
  opacity: 0;
  transition: transform 0.25s ease, height 0.25s ease, opacity 0.2s ease, background 0.2s ease;
  will-change: transform, height;
}

.sidebar-nav .sidebar-nav-indicator.is-visible {
  opacity: 1;
}

.sidebar-nav .sidebar-nav-indicator.is-hover {
  background: var(--sidebar-hover-bg);
  box-shadow: none;
}

.sidebar-nav li {
  position: relative;
  z-index: 1;
}

/* Centred hairline between top-level module groups. Consumes the
   --sidebar-nav-divider token (defined in every 00-themes.css, previously unused).
   The adjacent-sibling selector skips the first group, so no markup change is needed. */
.sidebar-group + .sidebar-group::before {
  content: "";
  display: block;
  width: 64%;
  height: 1px;
  margin: var(--space-2) auto;
  background: linear-gradient(90deg,
    transparent,
    var(--sidebar-nav-divider) 22%,
    var(--sidebar-nav-divider) 78%,
    transparent);
}

.sidebar-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: color 0.2s, transform 0.2s ease;
  white-space: nowrap;
}

.sidebar-nav a:hover {
  color: var(--sidebar-text-hover);
  transform: translateX(3px);
}

.sidebar-nav a.is-active {
  color: var(--sidebar-text-active);
  font-weight: 600;
}


.sidebar-nav a .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ─── Sidebar Group (accordion) ──────────────────────────────── */

.sidebar-group-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-5);
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: color 0.2s, transform 0.2s ease;
  min-height: 44px;
}

.sidebar-group-toggle:hover {
  color: var(--sidebar-text-hover);
  transform: translateX(3px);
}

.sidebar-group-toggle .nav-label {
  flex: 1;
}

.sidebar-chevron {
  width: 16px !important;
  height: 16px !important;
  transition: transform 0.2s ease;
  flex-shrink: 0;
  transform: rotate(90deg);
}

.sidebar-group.is-expanded > .sidebar-group-toggle .sidebar-chevron {
  transform: rotate(1deg);
}

.sidebar-subnav {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.sidebar-group.is-expanded > .sidebar-subnav {
  max-height: 600px;
}

.sidebar-subnav li {
  border-bottom: none;
}

.sidebar-subnav a {
  position: relative;
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-5) var(--space-2) calc(var(--space-5) + 28px);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color 0.2s, transform 0.2s ease;
  min-height: 36px;
}

.sidebar-subnav a:hover {
  color: var(--sidebar-text-hover);
  transform: translateX(3px);
}

.sidebar-subnav a.is-active {
  color: var(--sidebar-text-active);
  font-weight: 600;
}

/* Selected module: rounded block around toggle + subnav items (bg matches sidebar, inset ring) */
.sidebar-group.is-expanded {
  background: var(--sidebar-bg);
  box-shadow: inset 0px 0px 3px 0px var(--gray-400);
}

.sidebar-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  transition: background 0.2s, box-shadow 0.2s;
}

.sidebar-logo-link:hover {
  background: var(--sidebar-hover-bg);
  box-shadow: inset 0px 0 0 var(--sidebar-active-border), var(--shadow-glow);
}

.sidebar-logo-link:hover .sidebar-logo {
  transform: scale(1.04);
  filter: brightness(1.06);
}

.sidebar-logo-link:hover .sidebar-logo--fallback {
  color: var(--sidebar-text-hover);
}

.sidebar-logo-link:focus-visible {
  outline: 2px solid var(--sidebar-active-border);
  outline-offset: 2px;
}

.sidebar-footer {
  z-index: 3;
  background: var(--sidebar-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  padding: var(--space-3) var(--space-4);
  box-shadow: inset 0px -1px 3px 0px var(--gray-400);
  border-radius: 0 0 6px 6px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-pin {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sidebar-version);
  padding: var(--space-0);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.25s ease, color 0.2s;
}

.sidebar-pin:hover {
  color: var(--sidebar-text-hover);
}

.sidebar-pin.is-pinned {
  color: var(--purple-500);
  transform: rotate(315deg);
}

.sidebar-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sidebar-version);
  padding: var(--space-0);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s;
}

.sidebar-close:hover {
  color: var(--sidebar-text-hover);
}

/* ─── Main Content ─────────────────────────────────────────────── */

.main-body {
  display: flex;
  flex-direction: column;
  padding: var(--topbar-inset);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.main-content {
  margin-left: 0;
  padding: calc(56px + var(--topbar-inset)) 0 calc(var(--space-0) + 64px);
  scroll-padding-top: calc(56px + var(--topbar-inset));
  scroll-padding-bottom: calc(55px + var(--topbar-inset));
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  scrollbar-color: transparent transparent;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.20s ease-in-out;
}

.full-width {
  margin-left: 0;
  padding: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* ─── Sidebar Version ─────────────────────────────────────────── */

.sidebar-version {
  color: var(--sidebar-version);
  font-size: var(--text-xs);
  text-align: center;
  padding: var(--space-2) 0;
  flex: 1;
}

/* ─── Top Bar ─────────────────────────────────────────────────── */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: var(--topbar-inset);
  left: var(--topbar-inset);
  right: var(--topbar-inset);
  height: 56px;
  padding: 0 clamp(8px, 1.2cqw, 16px);
  gap: clamp(6px, 1cqw, 12px);
  background: var(--surface);
  min-width: 0;
  box-sizing: border-box;
  flex-wrap: nowrap;
  container-type: inline-size;

  border-radius: 9px 9px 0 0;
  box-shadow: 0 0px 0px 0px var(--surface),
              inset 0px 0px 3px 0px var(--gray-400);
  font-size: clamp(13px, 1.1vw, 16px);
   z-index: 101;
  transition: margin-left 0.20s ease-in-out;
}

.topbar-backdrop {
  position: fixed;
  top: 0;
  left: var(--topbar-inset);
  right: var(--topbar-inset);
  height: var(--topbar-bottom);
  background: var(--surface);
  z-index: 100;
  pointer-events: none;
  transition: margin-left 0.20s ease-in-out;
}

.top-bar .top-bar-module {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 0;
  margin-left: 0;
  min-height: 28px;
  padding: 0 10px;
  font-size: clamp(11px, 1vw, 13px);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  flex: 0 0 auto;
  min-width: 0;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  justify-content: center;
}
.top-bar-company-label,
.top-bar-module-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-bar .top-bar-search input {
  border: 1px solid var(--border);
  background: var(--surface-card);
  box-shadow: var(--shadow-sm);
}
.top-bar .notification-bell {
  width: 36px;
  height: 36px;
  padding: var(--space-2);
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-card);
  box-shadow: var(--shadow-sm);
}
.top-bar .theme-toggle {
  width: 36px;
  height: 36px;
  padding: var(--space-2);
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-card);
  box-shadow: var(--shadow-sm);
}
.top-bar .user-menu-trigger {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  box-shadow: inset 0px 0px 2px 0px var(--border), inset 0 0px 3px 1px var(--purple-600);
}
.top-bar .avatar {
  background: none;
  box-shadow: none;
}

.top-bar .hamburger {
  padding: var(--space-2);
  border-radius: 18px;
  box-shadow: inset 0px 0px 2px 0px var(--border), inset 0 0px 3px 1px var(--purple-600);
}
.top-bar .badge-sysadmin {
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}

.top-bar .hamburger,
.top-bar .notification-bell,
.top-bar .theme-toggle,
.top-bar .user-menu-trigger {
  flex-shrink: 0;
  cursor: pointer;
  transition: box-shadow 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.top-bar .hamburger:hover,
.top-bar .notification-bell:hover,
.top-bar .theme-toggle:hover,
.top-bar .user-menu-trigger:hover {
  color: var(--theme);
  border-color: var(--theme-accent);
  background: var(--sidebar-hover-bg);
  box-shadow: var(--shadow-sm);
}
.top-bar .hamburger:focus-visible,
.top-bar .notification-bell:focus-visible,
.top-bar .theme-toggle:focus-visible,
.top-bar .user-menu-trigger:focus-visible,
.top-bar .top-bar-company:focus-visible,
.top-bar .top-bar-module:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
  border-radius: 0;
}

.top-bar .top-bar-module:focus-visible {
  border-radius: 0;
}


[data-theme="dark"] .top-bar .theme-toggle:hover {
  color: var(--purple-300);
}

.top-bar .user-menu-trigger:hover {
  background: var(--gray-100);
  transform: scale(1.08);
}

.top-bar .user-menu-trigger:active {
  transform: scale(0.95);
}

[data-theme="dark"] .top-bar .user-menu-trigger:hover {
  background: var(--surface-elevated);
}

.top-bar .user-menu-trigger:hover .user-avatar-icon {
  color: var(--purple-600);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.8cqw, 12px);
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.hamburger {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--space-2);
  display: flex;
  align-items: center;
}

.top-bar-search {
  flex: 1 1 200px;
  min-width: 120px;
  max-width: 320px;
  margin: 0 clamp(4px, 1cqw, 16px);
  position: relative;
}

.top-bar-search .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--gray-400);
  pointer-events: none;
}

.top-bar-search input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-card);
  color: var(--text-primary);
  font-size: clamp(11px, 1.6vw, 14px);
  min-height: 36px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.top-bar-search input:focus {
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px rgba(156, 78, 193, 0.12);
  background: var(--surface-card);
}

.top-bar-search input::placeholder {
  color: var(--gray-400);
}

.top-bar-search .search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-400);
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  line-height: 1.4;
  pointer-events: none;
}

.top-bar-search input:focus .search-shortcut {
  opacity: 0;
}

.top-bar-search input:hover {
  border-color: var(--purple-300);
  box-shadow: 0 0 0 3px rgba(156, 78, 193, 0.08);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.7cqw, 12px);
  flex: 0 0 auto;
  flex-shrink: 0;
  min-width: 0;
}

.top-bar-actions .badge-sysadmin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  min-height: 28px;
  min-width: 28px;
  max-width: 120px;
  padding: 0 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1;
  border-radius: 0;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--purple-50);
  color: var(--purple-700);
  border: 1px solid var(--purple-200);
}

[data-theme="dark"] .top-bar-actions .badge-sysadmin {
  background: color-mix(in srgb, var(--purple-500), transparent 85%);
  color: var(--purple-300);
  border: 1px solid var(--purple-500);
}

.top-bar-module {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 0;
  margin-left: 0;
  height: 28px;
  min-height: 28px;
  padding: 0 10px;
  font-size: clamp(11px, 0.9cqw, 13px);
  font-weight: 600;
  letter-spacing: clamp(0.2px, 0.04cqw, 0.3px);
  text-transform: uppercase;
  color: var(--top-bar-module-text);
  background: var(--top-bar-module-bg);
  border: 1px solid var(--top-bar-module-border);
  border-radius: 0;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  flex: 0 0 auto;
  min-width: 0;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
  line-height: 1;
  box-sizing: border-box;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.top-bar-module:hover {
  color: var(--theme);
  border-color: var(--theme-accent);
}

.top-bar-module::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 0;
  background: var(--top-bar-module-dot);
  flex-shrink: 0;
}

[data-theme="dark"] .top-bar-module {
  color: var(--top-bar-module-text);
  background: var(--top-bar-module-bg);
  border-color: var(--top-bar-module-border);
}

[data-theme="dark"] .top-bar-module::before {
  background: var(--top-bar-module-dot);
}

.top-bar-sep {
  flex-shrink: 0;
  width: 1px;
  height: 1.4em;
  margin: 0;
  background: var(--gray-300);
}

[data-theme="dark"] .top-bar-sep {
  background: var(--gray-600);
}

.top-bar-company {
  font-size: clamp(0.75rem, 0.9cqw + 0.40rem, 1.00rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  padding: 0 10px;
  border-radius: 0;
  background: var(--sidebar-active-bg);
  border: 1px solid transparent;
  min-width: 0;
  flex: 1 1 0;
  overflow: hidden;
  text-overflow: clip;
  max-width: clamp(110px, 22cqw, 240px);
  height: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
}

.top-bar-company:hover {
  color: var(--theme);
  background: var(--sidebar-hover-bg);
  border-color: var(--theme-accent);
}

@keyframes breatheGlow {
  0%, 100% { filter: drop-shadow(0 0 2px var(--purple-500)); }
  50%      { filter: drop-shadow(0 0 10px var(--purple-500)); }
}

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

.sidebar-nav a { min-height: 44px; padding: var(--space-3) var(--space-5); }

@media (max-width: 639px) {
  .sidebar {
    top: var(--topbar-inset);
    width: 280px;
    bottom: var(--topbar-inset);
    height: auto;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 101;
    border-radius: 6px;
    display: none;
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .sidebar-pin {
    display: none;
  }

  .sidebar-close {
    padding: var(--space-3);
  }

  .top-bar-search {
    display: none;
  }

  .top-bar-actions .badge-sysadmin {
    display: none;
  }

  .top-bar {
    left: var(--topbar-inset);
    right: var(--topbar-inset);
    padding: 0 6px;
    gap: 4px;
  }

  .top-bar-left {
    min-width: 0;
    flex-shrink: 1;
  }

  .top-bar-company {
    font-size: clamp(0.75rem, 3cqw, 0.95rem);
    padding: 0 8px;
    font-weight: 700;
    text-align: center;
    justify-content: center;
    white-space: nowrap;
    max-width: clamp(110px, 32cqw, 200px);
  }

  .top-bar-sep {
    display: none;
  }

  .top-bar-module {
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
    justify-content: center;
    gap: 4px;
    border-width: 1px;
    letter-spacing: 0.2px;
  }

  .top-bar-module::before {
    width: 4px;
    height: 4px;
  }

  .top-bar-actions {
    flex-shrink: 0;
    gap: var(--space-2);
  }

  .main-content {
    padding: calc(56px + var(--topbar-inset)) 0 calc(var(--space-0) + 64px);
  }
}

@media (min-width: 640px) and (max-width: 1023px) {
  .sidebar {
    top: var(--topbar-inset);
    bottom: var(--topbar-inset);
    height: auto;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 101;
    border-radius: 6px;
    display: none;
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .sidebar.open ~ .main-body .top-bar,
  .sidebar.open ~ .main-body .main-content {
    margin-left: calc(var(--sidebar-width) + var(--topbar-inset));
  }

  .sidebar.open ~ .main-body .topbar-backdrop {
    margin-left: calc(var(--sidebar-width) + var(--topbar-inset));
  }

  .sidebar.open ~ .main-body .main-content .app-footer {
    left: calc(var(--sidebar-width) + var(--topbar-inset));
    justify-content: flex-end;
  }

  .sidebar.open ~ .main-body .main-content .app-footer-copyright {
    display: none;
  }

  .sidebar.open ~ .main-body .sidebar-backdrop {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  .sidebar-backdrop {
    display: none !important;
  }

  .sidebar.open ~ .main-body .top-bar,
  .sidebar.open ~ .main-body .main-content {
    margin-left: calc(var(--sidebar-width) + var(--topbar-inset));
  }

  .sidebar.open ~ .main-body .topbar-backdrop {
    margin-left: calc(var(--sidebar-width) + var(--topbar-inset));
  }

  .sidebar.open ~ .main-body .main-content .app-footer {
    left: calc(var(--sidebar-width) + var(--topbar-inset));
    justify-content: flex-end;
  }

  .sidebar.open ~ .main-body .main-content .app-footer-copyright {
    display: none;
  }
}

/* ─── Print ────────────────────────────────────────────────────── */


/* ─── Top-bar responsive upgrades (cqw, container-aware) ─────────────────────────────────── */
@media (max-width: 1024px) {
  .top-bar-search { max-width: 240px; }
}
@media (max-width: 860px) {
  .top-bar-search { max-width: 200px; min-width: 100px; }
  .top-bar-actions .badge-sysadmin { display: none; }
}
@media (max-width: 768px) {
  .top-bar-search { max-width: 160px; min-width: 80px; }
  .top-bar-company { max-width: clamp(100px, 24cqw, 220px); font-size: clamp(0.75rem, 2.8cqw, 0.95rem); padding: 0 8px; text-align: center; justify-content: center; white-space: nowrap; font-weight: 700; }
}
@media (max-width: 380px) {
  .top-bar { gap: 4px; padding: 0 6px; }
  .top-bar .hamburger,
  .top-bar .notification-bell,
  .top-bar .theme-toggle,
  .top-bar .user-menu-trigger { width: 32px; height: 32px; min-width: 32px; min-height: 32px; }
  .top-bar-company { font-size: clamp(0.75rem, 3.4cqw, 0.95rem); max-width: 45cqw; padding: 0 8px; letter-spacing: 0.5px; text-align: center; justify-content: center; white-space: nowrap; font-weight: 700; }
  .top-bar-module { padding: 0 8px; font-size: 11px; gap: 4px; border-width: 1px; letter-spacing: 0.2px; }
  .top-bar-module::before { width: 4px; height: 4px; }
  .top-bar-left { gap: 4px; }
  .top-bar-actions { gap: 4px; }
  .top-bar-search { display: none; }
}

@media print {
  .sidebar,
  .top-bar,
  .hamburger,
  .btn,
  .btn-group,
  .page-header .btn-group,
  .filters,
  .form-actions,
  .action-bar,
  .notification-bell,
  .theme-toggle,
  .loader-overlay,
  .app-footer,
  [data-theme-toggle] {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }

  table th {
    background: #f5f5f5 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  a {
    color: black;
    text-decoration: underline;
  }
}

/* ─── Theme toggle in the user menu (mobile) ──────────────────── */
/* The top bar has no room for the theme toggle next to the bell and
   the avatar on small screens — the company and module labels
   truncate. ≤639px the toggle lives in the user menu dropdown
   instead (markup: resources/views/layouts/app.php); ≥640px the
   in-menu copy is hidden and the top-bar copy returns. Clicks are
   delegated (08-delegation.js) and 04-theme.js syncs every
   [data-icon] pair, so both copies need no extra JS. */
.user-menu .dropdown-item--theme {
  border: 0;
  background: transparent;
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
@media (min-width: 640px) {
  .user-menu .dropdown-item--theme { display: none; }
}
@media (max-width: 639px) {
  .top-bar-actions > .theme-toggle { display: none; }
  /* The freed toggle slot goes to the labels: show the company and
     module names in full instead of ellipsizing them (the ≤768px clamp
     above would otherwise keep the company pill at ~100px). */
  .top-bar-company { max-width: none; }
  .top-bar-module { max-width: none; }

  /* Card-level scroll snapping: dashboards opt in per page (snap-align on
     chart/table/KPI cards in each 03-*-dashboard.css), so a stopped scroll
     settles a card flush below the pinned page header instead of leaving
     its top half hidden under the header. Proximity keeps flick momentum
     usable; pages without snap-aligned children are unaffected. */
  .main-content { scroll-snap-type: y proximity; }
}

/* ================================================================
   Enterprise Unified System — UI Components
   Cards, stats, buttons, forms, tables, badges, alerts, etc.
   ================================================================ */

/* ─── Cards ────────────────────────────────────────────────────── */

.card {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  box-shadow: 0 0px 2px 2px rgba(0, 0, 0, 0.05);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.card-glass:hover {
  box-shadow: var(--shadow-xl);
}

.card-flat {
  box-shadow: none;
  border: 1px solid var(--border);
  padding: 0;
  background: transparent;
}

.card-flat:hover {
  box-shadow: none;
}

.card-compact {
  padding: var(--space-3);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.card-header h1,
.card-header h2,
.card-header h3 {
  margin: 0;
  color: var(--text-primary);
  /* Card titles stay one step below the page H1 (22px bold) — same scale as modal headers. */
  font-size: var(--text-lg);
  font-weight: 600;
}

.section-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-primary);
}

/* ─── Stats Grid ───────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  display: block;
  text-decoration: none;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--space-0) 0 0;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-0);
}

.stat-icon {
  color: var(--purple-500);
  margin-bottom: var(--space-0);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s, box-shadow 0.15s, filter 0.15s;
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  box-shadow: var(--morph-inset);
}

.btn-primary {
  background: var(--purple-600);
  color: white;
}
.btn-primary:hover {
  background: var(--purple-700);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--gray-300);
}

[data-theme="dark"] .btn-secondary {
  background: var(--surface-elevated);
  color: var(--text-primary);
}
[data-theme="dark"] .btn-secondary:hover {
  background: var(--border-light);
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  opacity: 0.9;
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.btn-outline {
  background: transparent;
  color: var(--purple-600);
  border: 1px solid var(--purple-600);
}
.btn-outline:hover {
  background: var(--purple-600);
  color: white;
}

[data-theme="dark"] .btn-outline {
  color: var(--purple-400);
  border-color: var(--purple-400);
}
[data-theme="dark"] .btn-outline:hover {
  background: var(--purple-400);
  color: var(--purple-950);
}

.btn-sm {
  padding: var(--space-0) var(--space-3);
  font-size: var(--text-sm);
  min-height: var(--btn-h-compact);
}

.btn-form,
.btn-card,
.btn-dash {
  /* context sizing hooks; defaults inherit the standard button size */
}

.btn-group {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-1);
  padding: 2px;
}

.btn-group--form {
  padding-left: 20px;
  justify-content: flex-end;
}

/* Record card action bar. The card is the single home for a record's actions
   (the list row carries only View), so the bar is separated from the fields
   above it rather than floating under the last card. Applied by class because
   every resource names its own bar id (#requisition-actions, #po-actions,
   #order-actions, …) but they all want the same rule. */
.card-actions {
  margin-top: var(--space-3);
  margin-bottom: 0;
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  border-top: 1px solid var(--border-light);
}

[data-theme="dark"] .card-actions {
  border-top-color: var(--border);
}

.btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

/* ─── Spinner (inline button loader) ──────────────────────────── */

.spinner-xs {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

.btn-secondary .spinner-xs {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: var(--text-secondary);
}

/* ─── Spinner (document modal loader) ──────────────────────── */

.spinner {
  display: inline-block;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--color-primary, #2563eb);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

.form {
  width: 100%;
  max-width: 800px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-4);
}

.form-group {
  margin-bottom: var(--space-0);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 500;
  font-size: var(--text-sm);
}

.form-control {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--surface-card);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(108, 42, 128, 0.15);
}

.form-control::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

/* Textarea — align outer box with selects/inputs/combobox (all modules inherit via core) */
.form-group textarea.form-control,
textarea.form-control {
  width: 100% !important;
  max-width: 100% !important;
  display: block;
  box-sizing: border-box;
  margin: 0;
}

.form .form-group {
  width: 100%;
  max-width: 100%;
}

select.form-control:not([multiple]):not(.combobox-hidden) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  cursor: pointer;
}

/* ─── Native select options — baseline, all engines ──────────── */

select.form-control option {
  background-color: var(--surface-card);
  color: var(--text-primary);
}

select.form-control option:checked {
  font-weight: 600;
}

select.form-control optgroup {
  background-color: var(--surface);
  color: var(--text-secondary);
  font-style: normal;
}

/* ─── Customizable select picker — progressive enhancement ───── */
/* Chromium 135+ / Edge 135+ / Safari 27+ only (@supports gate).  */
/* Firefox and older engines ignore this block and keep Tier 1.   */

@supports (appearance: base-select) {
  select.form-control:not([multiple]):not(.combobox-hidden),
  select.form-control:not([multiple]):not(.combobox-hidden)::picker(select) {
    appearance: base-select;
  }

  select.form-control:not([multiple]):not(.combobox-hidden)::picker(select) {
    background-color: var(--surface-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-1);
  }

  select.form-control:not([multiple]):not(.combobox-hidden) option:hover,
  select.form-control:not([multiple]):not(.combobox-hidden) option:focus-visible {
    background-color: var(--gray-100);
  }

  select.form-control:not([multiple]):not(.combobox-hidden) option:checked {
    font-weight: 700;
  }

  select.form-control:not([multiple]):not(.combobox-hidden)::picker-icon {
    display: none;
  }
}

.form-error {
  display: block;
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: var(--space-0);
  min-height: 0;
}

.form-group.has-error .form-control,
.form-field.has-error .form-control {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.field-error {
  display: none;
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: var(--space-0);
  min-height: 0;
}

.form-group.has-error .field-error,
.form-field.has-error .field-error {
  display: block;
  min-height: 1.25rem;
}

.error-summary {
  margin-bottom: var(--space-4);
}

.error-summary ul {
  margin: 0;
  padding-left: var(--space-4);
}

.error-summary li {
  margin-bottom: var(--space-0);
}

.form-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-6);
  align-items: center;
}

/* ─── Inline Checkbox ─────────────────────────────────────────── */

/* Label + checkbox on one line ("Select all", "Remember me"). The class was
   used by views that hand-sized the box with an inline style and NOTHING
   defined the class itself, so the pair had no gap and no alignment of its
   own. The box size moves here so a call site can drop its inline style. */
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  margin: 0;
}

.checkbox-inline input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
}

.checkbox-inline.is-disabled,
.checkbox-inline input[disabled] + span {
  cursor: default;
  opacity: 0.6;
}

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

.table-container {
  overflow-x: auto;
  overflow-y: clip;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  container-type: inline-size;
}

/* List pages: .main-content is a flex column, so a .table-container child
   with non-visible overflow gets a flex automatic minimum size of 0 and
   would shrink to the viewport — instead let it fill the space below the
   page-header (flex: 1) and become its OWN scroll region (overflow: auto),
   so the thead pins to THIS container at top: 0 (see the sticky block
   below) instead of to the page scrollport. */
.main-content > .table-container {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* Mobile stacked-card rows: revert to natural page scroll. */
@media (max-width: 639px) {
  .main-content > .table-container {
    flex: 0 0 auto;
    overflow: visible;
  }
}

/* Clickable table headers (JS initTableSort) — hint sortability. */
.table-container th.sortable {
  cursor: pointer;
  user-select: none;
}

/* Sort direction marker — the triangle ::after sits inline after the header
   label; all <th> in the views are plain text so it cannot overlap. The
   muted triangle on every sortable header signals the affordance before
   clicking; the sorted header's triangle tints accent. Used to be styled by
   the JS classes sort-asc/sort-desc with no CSS at all, which made header
   clicks look like a no-op. */
.table-container th.sortable::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: var(--space-1);
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid var(--text-secondary);
  opacity: 0.35;
}

.table-container th.sort-asc::after {
  opacity: 1;
  border-bottom: 5px solid var(--purple-600);
  border-top: none;
}

.table-container th.sort-desc::after {
  opacity: 1;
  border-bottom: none;
  border-top: 5px solid var(--purple-600);
}

[data-theme="dark"] .table-container th.sort-asc::after {
  border-bottom-color: var(--purple-400);
}

[data-theme="dark"] .table-container th.sort-desc::after {
  border-top-color: var(--purple-400);
}

/* While a sort request is in flight the request path itself shows no loader
   (submitSearch is silent), so the table dims and blocks repeat clicks until
   its rows change. */
.table-container table.is-sorting {
  opacity: 0.6;
  pointer-events: none;
}

/* In-place activity strip: thin top bar during a server-backed table fetch,
   shown by beginTableBusy()/endTableBusy() in 06-tables.js. Two traps handled
   here: (1) it must be one compositor-friendly transform sweep, not a width
   tween, or it freezes exactly when the page does; (2) prefers-reduced-motion
 already drops animations to 0.01ms (05-animations.css), which would otherwise
   destroy the indicator — so under reduce the sweep collapses to a static
   visible strip instead of disappearing. */
.table-busy-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 99998;
  overflow: hidden;
  pointer-events: none;
  background: var(--border);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.table-busy-bar.is-active {
  opacity: 1;
}

.table-busy-bar::after {
  content: '';
  display: block;
  width: 35%;
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, transparent, var(--purple-400), var(--purple-300), transparent);
  animation: barSweep 1.5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .table-busy-bar::after {
    animation: none !important;
    width: 100%;
    background: var(--purple-400);
    opacity: 0.6;
  }
}

/* Desktop-only: the thead (th row) is hidden on mobile (≤639px rows
   become stacked cards), so round the header's top corners only where
   a real header row renders. .table-container tables use
   border-collapse: separate so sticky headers render reliably;
   overflow-y: clip (not auto) keeps this wrapper out of the sticky
   scroll-container chain so the header pins to the page scrollport
   (.main-content / .modal-body), not to this non-scrolling box;
   tr.status-* bars are re-added via td:first-child in a ≥640px block. */
@media (min-width: 640px) {
  .table-container {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  /* Legacy .table-responsive wrapper (admin/config) — same rounding. */
  .table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

/* Sticky table headers need border-collapse: separate — with `collapse`,
   Chromium detaches/misaligns sticky th cells (see session S91). */
.table-container table {
  border-collapse: separate;
  border-spacing: 0;
}

table th {
  background: var(--gray-100);
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

/* Sticky table headers — the <thead> (parent row, not the th cells)
   pins while rows scroll. Scoped by scroll context: NESTED tables
   inside .main-content (e.g. report cards, which keep the page
   scrollport) pin below the sticky page-header (JS sets
   --page-header-h-real); direct-child list containers scroll
   internally and pin at top: 0 (rule below); modal tables pin at
   top: 0. Requires border-collapse: separate on .table-container
   table (above) and overflow-y: clip on the wrapper, or sticky binds
   to the wrong scroll container. */
.main-content .table-container thead {
  position: sticky;
  top: var(--page-header-h-real, 0px);
  z-index: 2;
}

.modal-body .table-container thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* List pages (direct child of .main-content): the wrapper scrolls
   internally, so the thead pins at the wrapper's own top — no
   page-header offset or --page-header-h-real coupling. */
.main-content > .table-container thead {
  top: 0;
  background: var(--gray-100);
}

[data-theme="dark"] .main-content > .table-container thead {
  background: var(--surface-elevated);
}

[data-theme="dark"] table th {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border-bottom-color: var(--border-light);
}

/* Card-nested tables own a capped scroll region; the thead pins at the
   card top (top: 0), never at the page-header offset — same behavior as
   list tables and procurement/inventory dashboard cards. Higher-specificity
   dashboard rules still win where present; .table-container--form keeps its
   scroll-only static-thead contract via the :not() exclusion. */
.main-content .card .table-container:not(.table-container--form) {
  overflow: auto;
  max-height: 50vh;
}

.main-content .card .table-container:not(.table-container--form) thead {
  top: 0;
  background: var(--gray-100);
}

[data-theme="dark"] .main-content .card .table-container:not(.table-container--form) thead {
  background: var(--surface-elevated);
}

table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-primary);
}

table tbody tr:hover {
  background: color-mix(in srgb, var(--purple-50), transparent 50%);
}

[data-theme="dark"] table tbody tr:hover {
  background: rgba(108, 42, 128, 0.1);
}

@media (min-width: 640px) {
  table tbody tr.status-pending td:first-child {
    border-left: 3px solid var(--warning);
  }

  table tbody tr.status-approved td:first-child {
    border-left: 3px solid var(--success);
  }

  table tbody tr.status-denied td:first-child {
    border-left: 3px solid var(--danger);
  }
}

.table-container th {
  white-space: nowrap;
  font-size: clamp(11px, 1.2cqw, 13px);
}

.table-container td {
  /* Stage 1: clamp until minimum — single line, shrink via clamp, no wrap yet */
  white-space: nowrap;
  font-size: clamp(10px, 1.1cqw, 13px);
  padding: clamp(4px, 0.6cqw, 8px) clamp(6px, 1cqw, 12px);
  overflow: hidden;
  text-overflow: clip;
  max-width: none;
  vertical-align: middle;
}

.table-container td.actions,
.table-container td.actions-cell,
.table-container td.status-cell {
  white-space: nowrap;
  overflow: visible;
  overflow-wrap: normal;
  word-break: normal;
  max-width: none;
  text-overflow: clip;
  vertical-align: middle;
}

/* Stage 3: after clamp minimum still overflows → wrap all columns readable at
   symbols/spaces (never mid-word). Header cells wrap too (S277): `th` was
   nowrap with no is-wrapped override, so the header row's min-content width was
   a hard floor that no amount of data-cell wrapping could get under — any table
   whose binding constraint was its own header row had nowhere left to go but
   cards. */
.table-container.is-wrapped td {
  white-space: normal;
  overflow: visible;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  line-break: auto;
  text-overflow: clip;
}

.table-container.is-wrapped th {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  line-break: auto;
}

/* Selective nowrap retained only for th headers when needed (data wraps via
   is-wrapped). It is a deliberate floor through the wrap stage — ID, date and
   status columns stay on one line for scanning — but NOT a permanent one:
   06-tables.js adds `is-tight` to a container that is still overflowing after
   wrapping, and the rules below override it there. BOTH sides carry
   !important on purpose, so that override is decided by SPECIFICITY (the
   tighten selectors are (0,4,1) against this (0,2,1)) rather than by source
   order — two rules meeting on equal specificity is precisely how an override
   like this silently stops working the next time the file is reordered. */
.table-container th.col-nowrap,
.table-container td.col-nowrap {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  word-break: normal;
}

/* Stage 4: still not fitting after wrap → tighten (S277), the last rung before
   cards. Applied per container and only on overflow, so a table that already
   fits never grows a two-line header. This rung exists because col-nowrap sits
   on 101 th + 47 td across the views, which meant the wrap stage alone could
   not always free enough width for the table to stay a table. */
.table-container.is-wrapped.is-tight td,
.table-container.is-wrapped.is-tight th {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  line-break: auto;
}

.table-container.is-wrapped.is-tight th.col-nowrap,
.table-container.is-wrapped.is-tight td.col-nowrap {
  white-space: normal !important;
  text-overflow: clip;
  overflow-wrap: break-word;
  word-break: normal;
}

table td.actions {
  white-space: nowrap;
  text-align: right;
}

/* Action buttons fluid shrink instead of wrapping on reduced viewport */
td.actions .btn-group,
.actions-cell .btn-group {
  flex-wrap: nowrap;
  gap: clamp(2px, 0.8cqw, 8px);
}

td.actions .btn-row,
.actions-cell .btn-row {
  font-size: clamp(9px, 1.6cqw, 12px);
  padding: clamp(2px, 0.6cqw, 4px) clamp(6px, 1.2cqw, 8px);
  min-height: clamp(24px, 4cqw, 28px);
}

td.actions .btn-sm,
.actions-cell .btn-sm {
  font-size: clamp(10px, 1.8cqw, 14px);
  padding: 0 clamp(6px, 1.2cqw, 12px);
  min-height: clamp(24px, 4cqw, 28px);
}

.card-header .btn-sm,
.card-section .card-header .btn {
  font-size: clamp(11px, 1.6vw, 14px);
  padding: 0 clamp(6px, 1vw, 12px);
  white-space: nowrap;
}

/* Stage 2: collapse action buttons — hide all except View (.btn-priority) */
.table-container:not(.is-card) .btn-group.actions-priority.is-collapsed .btn:not(.btn-priority),
.table-container.is-wrapped:not(.is-card) .btn-group.actions-priority.is-collapsed .btn:not(.btn-priority) {
  display: none;
}

/* Global card — applies at any width, all browsers */
.table-container.is-card thead { display: none !important; }
.table-container.is-card table, .table-container.is-card tbody { display: block; width: 100%; }
.table-container.is-card tbody tr {
  display: block; width: 100%; box-sizing: border-box; position: relative;
  padding: var(--space-4); margin-bottom: var(--space-3);
  background: var(--surface-card); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
}
.table-container.is-card td { display:flex; justify-content:space-between; align-items:center; max-width:none; white-space:normal; overflow:visible; overflow-wrap:break-word; word-break:normal; hyphens:auto; line-break:auto; }
.table-container td .btn { white-space:nowrap !important; overflow-wrap:normal !important; word-break:normal !important; flex-shrink:0; }

.table-container.is-card td::before {
  content: attr(data-label);
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: var(--space-3);
  flex-shrink: 0;
  font-size: var(--text-xs);
}


/* ─── Mobile Cards (table fallback) ────────────────────────────── */

.table-container thead {
  display: table-header-group;
}
/* ─── Badges ───────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}

.badge-active,
.badge-approved,
.badge-uploaded,
.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-pending,
.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-denied,
.badge-danger,
.badge-expired {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-expiring {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info-text);
}

.badge-inactive,
.badge-secondary {
  background: var(--gray-200);
  color: var(--gray-600);
}

.badge-sysadmin {
  background: var(--purple-800);
  color: white;
  border: 1px solid var(--purple-600);
}

.badge-admin {
  background: var(--purple-600);
  color: white;
}

.badge-manager {
  background: #6366f1;
  color: white;
}

.badge-employee {
  background: var(--gray-400);
  color: white;
}

/* ─── Alerts ───────────────────────────────────────────────────── */

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  font-size: var(--text-base);
  color: var(--text-primary);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info-text);
}

/* ─── Breadcrumbs ─────────────────────────────────────────────── */

.breadcrumbs {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.breadcrumbs a {
  color: var(--purple-600);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  margin: 0 var(--space-0);
  color: var(--text-secondary);
}

[aria-current="page"] {
  color: var(--text-primary);
  font-weight: 600;
}

/* ─── Empty State ──────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-4);
}

.empty-state .icon {
  margin-bottom: var(--space-3);
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin: 0 0 var(--space-0);
}

.empty-state-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0 0 var(--space-4);
}

/* ─── Quick Links ──────────────────────────────────────────────── */

.quick-links {
  margin-bottom: var(--space-6);
}

.quick-links h2 {
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin: 0 0 var(--space-3);
}

/* ─── Page Header ──────────────────────────────────────────────── */

.page-header {
  position: sticky;
  top: -2px;
  z-index: 90;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
  padding: var(--space-2) var(--space-2);
  min-width: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: inset 0 0px 4px 1px rgba(124, 58, 237, 0.35);
  background:
    radial-gradient(circle at 18% 0%, rgba(156, 78, 193, 0.30), transparent 65%),
    radial-gradient(circle at 82% 0%, rgba(108, 42, 128, 0.24), transparent 65%),
    radial-gradient(circle at 50% 120%, rgba(156, 78, 193, 0.14), transparent 55%),
    linear-gradient(180deg, #fdf7ff, var(--surface));
}

.page-header h1 {
  margin: 0;
  font-size: var(--text-xl);
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  line-height: 1.4;
}

.page-header--with-filter {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.page-header-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 32px;
}

.page-header-row h1 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  line-height: 1.4;
  padding: 3px 0;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
}

.page-header-row .btn-group {
  flex: 0 1 auto;
  flex-wrap: wrap;
  gap: clamp(4px, 1vw, 8px);
  justify-content: flex-end;
  align-items: center;
}

.page-header-row .btn {
  white-space: nowrap;
  font-size: clamp(11px, 1.6vw, 14px);
  padding: 3px clamp(6px, 1vw, 12px);
  line-height: 1.4;
  min-height: 28px;
  box-sizing: border-box;
}

[data-theme="dark"] .page-header {
  background:
    radial-gradient(circle at 18% 0%, rgba(156, 78, 193, 0.40), transparent 65%),
    radial-gradient(circle at 82% 0%, rgba(108, 42, 128, 0.34), transparent 65%),
    radial-gradient(circle at 50% 120%, rgba(156, 78, 193, 0.20), transparent 55%),
    linear-gradient(180deg, rgba(156, 78, 193, 0.10), transparent),
    var(--surface);
}

/* ─── Filters / Search ─────────────────────────────────────────── */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: end;
  margin-bottom: var(--space-4);
}

.filters .form-group {
  margin-bottom: 0;
}

.filters input,
.filters select {
  min-width: 180px;
}

/* ─── List-page filter bar (procurement top-bar search styling) ── */

.filter-bar {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  align-items: center;
  position: sticky;
  top: calc(var(--topbar-bottom) + var(--page-header-h));
  z-index: 80;
  background: var(--surface);
}

.filter-bar:not(.filters) {
  margin-bottom: var(--space-4);
}

.filter-search {
  display: flex;
  align-items: center;
  gap: 0;
}

.filter-bar .filter-search {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

.filter-col-select {
  max-width: 120px;
  min-height: 28px;
  padding: 3px 30px 3px 12px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius-full) 0 0 var(--radius-full);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  color: var(--text-primary);
  font-size: clamp(11px, 1.6vw, 14px);
  font-family: inherit;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: inset 0 0 4px rgba(124, 58, 237, 0.12);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.filter-col-select:hover {
  border-color: var(--purple-300);
  box-shadow: 0 0 0 3px rgba(156, 78, 193, 0.08);
}

.filter-col-select:focus {
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
  background-color: var(--surface-card);
}

[data-filter-col-select] {
  box-shadow: inset 0 0 2px rgba(15, 118, 110, 0.12);
}

.filter-search-input {
  position: relative;
  flex: 1;
  min-width: 220px;
  margin-left: -1px;
  box-shadow: inset 0 0 2px rgba(15, 118, 110, 0.12);
}

.filter-search-input .icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--gray-400);
  pointer-events: none;
}

.filter-search-input .filter-search-btn {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.filter-search-input .filter-search-btn .icon {
  position: static;
  transform: none;
  pointer-events: none;
}

.filter-search-input .filter-search-btn:hover {
  color: var(--purple-500);
}

.filter-search-input .filter-search-btn:focus-visible {
  outline: 2px solid var(--purple-400);
  outline-offset: 2px;
  border-radius: var(--radius-full);
}

.filter-search-input input {
  width: 100%;
  padding: 3px 10px 3px 30px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  background: var(--surface);
  color: var(--text-primary);
  font-size: clamp(11px, 1.6vw, 14px);
  outline: none;
  box-shadow: inset 0 0 4px rgba(124, 58, 237, 0.12);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  min-height: 28px;
}

.filter-search-input input:hover {
  border-color: var(--purple-300);
  box-shadow: 0 0 0 3px rgba(156, 78, 193, 0.08);
}

.filter-search-input input:focus {
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px rgba(156, 78, 193, 0.12);
  background: var(--surface-card);
}

.filter-search-input input::placeholder {
  color: var(--gray-400);
  font-size: var(--text-xs);
}

.filter-search .filter-col-select,
.filter-search .filter-search-input input {
  min-width: 0;
}

/* ─── Pagination ───────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-right: var(--space-6);
  padding-left: var(--space-6);
}

.pagination-info {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.pagination-links {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.pagination a,
.pagination span {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.pagination a:hover {
  background: var(--gray-100);
}

.pagination .active {
  background: var(--theme);
  color: white;
  border-color: var(--theme);
}

.pagination-prev.disabled,
.pagination-next.disabled,
.pagination-ellipsis {
  color: var(--gray-400);
  cursor: default;
}

.pagination-prev.disabled,
.pagination-next.disabled {
  pointer-events: none;
}

/* ─── Theme Toggle ─────────────────────────────────────────────── */

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-0);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  transition: color 0.2s, background 0.2s;
}

.theme-toggle:hover {
  color: var(--text-primary);
  background: var(--gray-200);
  transform: scale(1.08);
}

.theme-toggle:active {
  transform: scale(0.95);
}

[data-theme="dark"] .theme-toggle:hover {
  background: var(--surface-elevated);
}

.theme-toggle [hidden] {
  display: none !important;
}

.theme-toggle .icon {
  transition: transform 0.3s ease, color 0.2s;
}

.theme-toggle [data-icon] {
  animation: theme-morph 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes theme-morph {
  0%   { transform: rotate(-90deg) scale(0.5); opacity: 0; }
  60%  { transform: rotate(12deg) scale(1.15); opacity: 1; }
  100% { transform: rotate(0deg) scale(1); opacity: 1; }
}

/* ─── User Menu Dropdown ──────────────────────────────────────── */

.user-menu {
  position: relative;
}

.user-menu-trigger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  transition: box-shadow 0.2s;
}

.user-menu-trigger:hover {
  box-shadow: 0 0 0 2px var(--purple-600);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-0);
  z-index: 200;
  display: none;
}

.dropdown-menu.open {
  display: block;
}

.dropdown-label {
  display: block;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.15s;
  border-radius: var(--radius-md);
}

.dropdown-item:hover {
  background: var(--gray-100);
}

[data-theme="dark"] .dropdown-item:hover {
  background: var(--gray-700);
}

.dropdown-item--danger {
  color: var(--danger);
}

.dropdown-item--danger:hover {
  background: var(--danger-bg);
}

[data-theme="dark"] .dropdown-item--danger:hover {
  background: rgba(220, 38, 38, 0.15);
}

/* ─── Loader Overlay ───────────────────────────────────────────── */

.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(26, 10, 46, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.loader-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-8);
  opacity: 0;
  transform: scale(0.35);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.loader-overlay.active .loader-container {
  opacity: 1;
  transform: scale(1);
}

.loader-mark {
  width: 160px;
  height: auto;
  filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.55));
  animation: breatheMark 2.2s ease-in-out infinite;
  animation-play-state: paused;
}

.loader-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.loader {
  width: 34px;
  height: 34px;
  color: var(--theme-accent);
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.25));
  animation: loaderSpin 2s linear infinite;
  animation-play-state: paused;
}

.loader-overlay.active .loader-mark,
.loader-overlay.active .loader,
.loader-overlay.active .loader-text {
  animation-play-state: running;
}

@keyframes loaderSpin {
  100% { transform: rotate(1turn); }
}

@keyframes breatheMark {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

@keyframes loaderTextFade {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.loader-text {
  font-size: var(--text-lg);
  font-weight: 500;
  text-align: center;
  background: linear-gradient(90deg, var(--purple-300), var(--purple-600));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: loaderTextFade 2s ease-in-out infinite;
  animation-play-state: paused;
}

.loader-bar {
  width: 220px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.loader-bar-track {
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, transparent, var(--purple-300), transparent);
  border-radius: var(--radius-full);
  animation: barSweep 1.5s ease-in-out infinite;
}

@keyframes barSweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--purple-400), var(--purple-200));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
  display: none;
}

.loader-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: barShimmer 1.5s ease-in-out infinite;
}

@keyframes barShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* ─── Page Reveal ──────────────────────────────────────────────── */

.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: revealUp 0.4s ease forwards;
}

.reveal-delay-1 { animation-delay: 0.05s; }
.reveal-delay-2 { animation-delay: 0.15s; }
.reveal-delay-3 { animation-delay: 0.25s; }
.reveal-delay-4 { animation-delay: 0.35s; }
.reveal-delay-5 { animation-delay: 0.45s; }

@keyframes revealUp {
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Utilities ────────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

.w-full { width: 100%; }
.max-w-lg { max-width: 800px; }
.mx-auto { margin-left: auto; margin-right: auto; }


/* ─── Table refresh button spin animation ──────────────────────── */
[data-table-refresh].is-refreshing svg.icon,
[data-table-refresh].is-refreshing svg,
[data-table-refresh].is-refreshing .icon,
[data-table-refresh] .is-spinning {
  animation: spin 0.6s linear infinite !important;
  transform-origin: center center;
  transform-box: fill-box;
}

/* ─── Actions cell (table row actions) ─────────────────────────── */

.actions-cell {
  width: auto;
  white-space: nowrap;
  padding: var(--space-1) var(--space-2);
}

.actions-cell .btn-group {
  justify-content: flex-start;
}

.btn-row {
  min-height: 28px;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}

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

/* ─── Modal/detail buttons ─────────────────────────────────────── */

.btn-modal {
  min-height: 35px;
  box-shadow: 0px 0px 1px 1px rgb(255 255 255), 0px 0px 20px 1px rgb(0 0 0 / 11%);
  border-radius: 11px;
  transition: box-shadow 0.25s ease, transform 0.2s ease;
}

.btn-modal:hover {
  box-shadow: inset 0 0px 1px 4px rgb(255 255 255 / 45%);
  transform: translateY(-1px) scale(0.97);
}

.btn-modal:active {
  transform: translateY(0) scale(0.97);
}

[data-theme="dark"] .btn-modal {
  box-shadow: inset 0 0px 1px 4px rgb(108 42 128 / 35%);
}

[data-theme="dark"] .btn-modal:hover {
  box-shadow: inset 0 0px 1px 4px rgb(255 255 255 / 30%);
}

/* ─── Detail modal cards ────────────────────────────────────── */

.modal-content .card-header {
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
}

.modal-content .card .form-group {
  margin-bottom: 0;
}

.detail-value {
  font-weight: 500;
  color: var(--text-primary);
}

#requisition-detail .card-header {
  margin-bottom: var(--space-1);
  padding-bottom: var(--space-2);
}

#requisition-detail .card-header h3 {
  border-radius: 7px;
  padding: 3px;
  border: 1px solid #f0fdfa00;
}

#requisition-detail .requisition-info {
  padding: 3px;
}

#requisition-detail .requisition-info > .form-row {
  grid-template-columns: auto;
  grid-auto-flow: column;
  gap: var(--space-3);
  align-items: start;
}

#requisition-detail .form-row .form-group {
  margin-bottom: 0;
}

#requisition-detail .form-row > .form-group {
  min-width: 0;
}

#requisition-detail .form-group label {
  font-size: var(--text-base);
}

#requisition-detail .detail-value {
  font-size: var(--text-sm);
  overflow-wrap: break-word;
  word-break: break-word;
}

.detail-note {
  margin-top: var(--space-3);
  margin-bottom: 10px;
  background: var(--purple-50);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

[data-theme="dark"] .detail-note {
  background: rgba(108, 42, 128, 0.08);
}

.detail-meta {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

[data-theme="dark"] .detail-meta {
  border-top-color: var(--border);
}

#requisition-detail .card,
#requisition-detail .table-container {
  box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] #requisition-detail .card,
[data-theme="dark"] #requisition-detail .table-container {
  box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.35);
}

/* ─── Requisition action confirm summary ─────────────────────────── */

.req-confirm-summary {
  text-align: left;
  margin-top: var(--space-4);
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3) var(--space-4);
}

.req-confirm-message {
  margin: 0 0 var(--space-3);
  color: var(--text-primary);
  font-weight: 600;
}

.req-confirm-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
}

.req-confirm-row span {
  color: var(--text-secondary);
}

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

@media (max-width: 1023px) {
  .btn:not(.btn-sm):not(.btn-row):not(.btn-modal):not(.btn-form):not(.btn-card):not(.btn-dash) {
    min-height: var(--btn-h-mobile);
  }
  .btn-form { min-height: var(--btn-form-h-mobile); }
  .btn-card  { min-height: var(--btn-card-h-mobile); }
  .form-control { min-height: 44px; font-size: 16px; }
}

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

  .form-row {
    grid-template-columns: 1fr;
  }

  .page-header {
    margin-left: 0;
    margin-right: 0;
    width: auto;
    padding: var(--space-2) var(--space-2);
  }

  .filters {
    flex-direction: column;
  }

  .filters input,
  .filters select {
    min-width: 100%;
  }
}

/* ─── Tabs ─────────────────────────────────────────────────────── */

/* ─── Tabs ─────────────────────────────────────────────────────── */

.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--glass-border);
  margin-bottom: var(--spacing-md);
  overflow-x: auto;
}

.tab-btn {
  padding: var(--spacing-sm) var(--spacing-md);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.9rem;
  transition: color 0.2s, border-color 0.2s;
}

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

.tab-btn.active {
  color: var(--purple-400);
  border-bottom-color: var(--purple-400);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ─── App Footer ──────────────────────────────────────────────── */

.app-footer {
  position: fixed;
  bottom: var(--topbar-inset);
  left: var(--topbar-inset);
  right: var(--topbar-inset);
  z-index: 5;
  /* Opaque so content scrolling underneath the fixed footer is hidden. */
  background: var(--surface);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: 0 0 6px 6px;
  box-shadow: 0 0px 0px 0px var(--surface),
              inset 0px -4px 4px -4px var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  padding: 0 var(--space-2);
  min-height: 55px;
  transition: left 0.70s ease-in-out;
}

.app-footer-copyright {
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--text-tertiary, var(--gray-500));
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.app-footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.app-footer-links a {
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}

.app-footer-links a:hover {
  color: var(--purple-400);
}

@media (max-width: 639px) {
  .app-footer {
    text-align: center;
    padding: 0 var(--space-2);
  }

  .app-footer-links {
    justify-content: center;
    gap: var(--space-2) var(--space-3);
  }
}

/* ================================================================
   Enterprise Unified System — Auth Styles
   Login, recovery, error pages, auth form elements
   ================================================================ */

/* ─── Logo ─────────────────────────────────────────────────────── */

.auth-logo {
  display: block;
  margin: 0 auto;
  width: 160px;
  height: auto;
  position: relative;
  z-index: 1;
  animation: logoZoomIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ─── Auth (Login / Error) Pages ──────────────────────────────── */

.auth-page {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Centers the auth content within the page, above the footer */
.auth-center {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-4) 40px;
  position: relative;
  /* Transparent so the background is picked up from .main-page below */
  background: transparent;
}

.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

/* Wrapper around the centered auth column (auth-center inside it).
   Full viewport height; the sticky footer inside it stays anchored at
   the bottom, so auth-center + footer both fit the viewport.
   Carries the page background; auth-center above is transparent and
   picks it up from here. */
.main-page {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background:
    radial-gradient(circle at 20% 80%, rgba(124, 58, 237, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(108, 42, 128, 0.06) 0%, transparent 50%),
    linear-gradient(135deg, var(--purple-800), var(--purple-950));
  background-size: 200% 200%, 200% 200%, 400% 400%;
  animation: gradientDrift 20s ease infinite;
}

/* Footer inside the auth wrapper: sticky at the viewport bottom instead of
   the global fixed footer, so auth-center flexes above it. Transparent so
   it shows the .main-page background. */
.main-page .app-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: transparent;
  box-shadow: 0 0px 0px 11px transparent,
              inset 0px -4px 4px -4px var(--gray-400);
}

/* ─── Auth Card — lighter, vibrant glass ──────────────────────── */

.auth-card {
  background: radial-gradient(ellipse at 50% 0%, rgba(124, 58, 237, 0.15) 0%, rgba(255, 255, 255, 0.04) 70%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(124, 58, 237, 0.2);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.15), 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 48px rgba(124, 58, 237, 0.08);
  animation: authCardIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
  position: relative;
  z-index: 1;
}

/* Glass shine reflection */
.auth-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, transparent 50%);
  pointer-events: none;
}

.auth-card h1 {
  color: white;
  margin: 0 0 var(--space-2);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-card .auth-subtitle {
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: var(--space-8);
  font-size: var(--text-sm);
}

.auth-card .auth-icon {
  width: 64px;
  height: 64px;
  stroke: rgba(255, 255, 255, 0.8);
  margin-bottom: var(--space-4);
}

/* Staggered form entrance */
.auth-card form .form-group,
.auth-card form .auth-remember,
.auth-card form .form-actions {
  opacity: 0;
  animation: authCardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.auth-card form .form-group:first-of-type { animation-delay: 0.4s; }
.auth-card form .form-group ~ .form-group { animation-delay: 0.5s; }
.auth-card form .auth-remember { animation-delay: 0.6s; }
.auth-card form .form-actions { animation-delay: 0.7s; }

/* ─── Auth Form Elements ──────────────────────────────────────── */

.auth-form {
  text-align: left;
}

.auth-form-actions {
  justify-content: center;
  margin-top: 24px;
}

.auth-label {
  display: block;
  margin-bottom: var(--space-0);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  font-size: var(--text-sm);
  text-align: left;
}

.auth-field {
  position: relative;
}

.auth-field .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.25);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.auth-field .form-control {
  padding-left: 36px;
}

.auth-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: white;
  background: rgba(255, 255, 255, 0.07);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.auth-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.auth-input:focus {
  outline: none;
  border-color: rgba(156, 78, 193, 0.4);
  box-shadow: 0 0 0 3px rgba(156, 78, 193, 0.12);
  background: rgba(255, 255, 255, 0.1);
}

/* Override browser autofill background — transition intercepts Chrome's instant !important */
.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus {
  -webkit-text-fill-color: white !important;
  caret-color: white !important;
  transition: background-color 50000s ease-in-out 0s !important;
}

.auth-field .auth-input {
  padding-left: 36px;
}

/* ─── Password Toggle ─────────────────────────────────────────── */

.auth-passwrap {
  position: relative;
}

.auth-passwrap .auth-input {
  padding-right: 40px;
}

.auth-passwrap .auth-field .auth-input {
  padding-left: 36px;
}

.auth-eye-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
}

.auth-eye-btn:hover {
  color: rgba(255, 255, 255, 0.7);
}

.auth-eye-btn .icon {
  width: 16px;
  height: 16px;
}

.auth-eye-btn [data-icon="eye-off"] { display: none; }
.auth-eye-btn.is-active [data-icon="eye"] { display: none; }
.auth-eye-btn.is-active [data-icon="eye-off"] { display: block; }

/* ─── Caps Lock Indicator ─────────────────────────────────────── */

.auth-capslock {
  display: inline-flex;
  align-items: center;
  gap: var(--space-0);
  font-size: var(--text-xs);
  color: rgba(251, 191, 36, 0.8);
  margin-top: var(--space-0);
  min-height: 0;
}

.auth-capslock[hidden] {
  display: none;
}

/* ─── Remember Me ─────────────────────────────────────────────── */

.auth-remember {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

.auth-remember input[type="checkbox"] {
  accent-color: var(--purple-500);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ─── Auth Button ─────────────────────────────────────────────── */

.auth-btn {
  width: 100%;
  padding: 11px var(--space-6);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--purple-600), var(--purple-700));
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  position: relative;
  overflow: hidden;
}

.auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
  filter: brightness(1.05);
}

.auth-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─── Auth Footer / Version ───────────────────────────────────── */

.auth-footer {
  margin-top: var(--space-6);
  font-size: var(--text-sm);
}

.auth-footer a {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  transition: color 0.2s ease;
}

.auth-footer a:hover {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: underline;
}

.app_version {
  text-align: center;
  color: rgba(255, 255, 255, 0.2);
  font-size: var(--text-xs);
  margin-top: var(--space-3);
  pointer-events: none;
}

.auth-rate-limit {
  color: rgba(251, 191, 36, 0.9);
  font-size: var(--text-sm);
  margin-top: var(--space-3);
}
/* ─── Responsive ───────────────────────────────────────── */

@media (max-width: 639px) {
  .auth-card {
    padding: var(--space-8) var(--space-5);
  }
}

/* Short viewports: physically shrink the auth content to fit (no zoom/scroll) */
@media (max-height: 820px) {
  .auth-center {
    gap: var(--space-3);
    padding: var(--space-3);
  }
  .auth-logo {
    width: 128px;
  }
  .auth-card {
    padding: var(--space-8) var(--space-6);
  }
  .auth-card .auth-subtitle {
    margin-bottom: var(--space-6);
  }
}

@media (max-height: 720px) {
  .auth-logo {
    width: 116px;
  }
  .auth-card {
    padding: var(--space-8) var(--space-5);
  }
  .auth-input {
    padding: 8px 12px;
  }
}

@media (max-height: 640px) {
  .auth-center {
    gap: var(--space-2);
  }
  .auth-logo {
    width: 104px;
  }
  .auth-card {
    padding: var(--space-6) var(--space-4);
  }
  .auth-card .auth-subtitle {
    margin-bottom: var(--space-3);
  }
  .auth-label {
    font-size: var(--text-xs);
  }
  .auth-input {
    font-size: var(--text-sm);
  }
  .auth-btn {
    padding: 9px var(--space-6);
  }
  .auth-form-actions {
    margin-top: 12px;
  }
  .auth-footer {
    margin-top: var(--space-4);
  }
}

@media (max-height: 560px) {
  .auth-logo {
    width: 88px;
  }
  .auth-card {
    padding: var(--space-4) var(--space-4);
  }
  .auth-card h1 {
    font-size: var(--text-lg);
  }
  .auth-card .auth-subtitle {
    font-size: var(--text-xs);
    margin-bottom: var(--space-2);
  }
  .auth-input {
    padding: 7px 12px;
  }
  .auth-btn {
    font-size: var(--text-sm);
    padding: 8px var(--space-6);
  }
  .auth-remember {
    margin-top: var(--space-0);
  }
  .auth-footer {
    margin-top: var(--space-3);
  }
}

@media (max-height: 480px) {
  .auth-logo {
    width: 80px;
  }
  .auth-center {
    gap: var(--space-0);
    padding: var(--space-2);
  }
  .auth-card {
    padding: var(--space-3) var(--space-3);
  }
  .auth-card h1 {
    font-size: var(--text-lg);
  }
  .auth-label {
    font-size: var(--text-xs);
  }
  .auth-input {
    font-size: var(--text-sm);
  }
  .auth-btn {
    font-size: var(--text-sm);
    padding: 8px var(--space-6);
  }
  .auth-form-actions {
    margin-top: 12px;
  }
  .auth-footer {
    margin-top: var(--space-2);
  }
  .app_version {
    font-size: 11px;
  }
}

/* Extreme heights: last-resort scroll only */
@media (max-height: 520px) {
  .auth-page {
    overflow-y: auto;
  }
}

/* ─── Fit-to-viewport: continuously compact vertical spacing so the
       auth column always fits above the pinned version / page footer ─── */
@media (max-height: 960px) {
  .auth-center {
    gap: clamp(var(--space-0), 3vh, var(--space-4));
    padding-top: clamp(var(--space-2), 4vh, var(--space-4));
    padding-bottom: clamp(28px, 9vh, 56px);
  }
  .auth-card {
    padding-top: clamp(var(--space-2), 5vh, var(--space-12));
    padding-bottom: clamp(var(--space-2), 5vh, var(--space-12));
  }
  .auth-card .auth-subtitle {
    margin-bottom: clamp(var(--space-0), 2vh, var(--space-8));
  }
  .auth-card form .form-group {
    margin-bottom: clamp(var(--space-0), 2vh, var(--space-4));
  }
  .auth-remember {
    margin-top: clamp(0, 1.5vh, var(--space-4));
  }
  .auth-form-actions {
    margin-top: clamp(8px, 2vh, 24px);
  }
  .auth-footer {
    margin-top: clamp(var(--space-1), 2vh, var(--space-6));
  }
  .app_version {
    font-size: clamp(10px, 1.4vh, var(--text-xs));
  }
}

/* ─── Mobile/small devices: top-align the auth column so the narrow portrait
       viewport doesn't leave large empty bands above and below the form ─── */
@media (max-width: 639px) {
  .auth-page {
    overflow-y: auto;
  }
  .auth-center {
    justify-content: flex-start;
    gap: var(--space-3);
    padding: var(--space-6) var(--space-4) 56px;
  }
  .auth-logo {
    width: 120px;
  }
  .auth-card {
    width: 100%;
  }
}

/* ================================================================
   Enterprise Unified System — Portal Styles
   Module card grid on the portal page
   ================================================================ */

/* ─── Animations ───────────────────────────────────────────────── */

@keyframes portal-enter {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─── Portal Page ──────────────────────────────────────────────── */

.portal-page {
  width: 100%;
  padding: var(--space-6) 0 var(--space-8);
  background:
    radial-gradient(circle at 15% 85%, rgba(156, 78, 193, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 85% 15%, rgba(99, 102, 241, 0.03) 0%, transparent 50%);
}

[data-theme="dark"] .portal-page {
  background:
    radial-gradient(circle at 15% 85%, rgba(156, 78, 193, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 85% 15%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
}

/* ─── Header ───────────────────────────────────────────────────── */

.portal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
    margin-top: -26px;
  margin-bottom: var(--space-6);
}

.portal-logo {
  width: 100px;
  height: auto;
  margin-bottom: var(--space-3);
  object-fit: contain;
}

.portal-greeting-row {
  display: flex;
flex-direction: column;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}

.portal-header h1.portal-greeting {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--text-secondary);
}

.portal-date {
  margin-bottom: 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
}

.portal-name {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.portal-subtitle {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.portal-company {
  margin: var(--space-0) 0 0;
  font-size: var(--text-xs);
  color: var(--text-tertiary, var(--text-secondary));
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.7;
}

/* ─── Grid ─────────────────────────────────────────────────────── */

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-5);
}

/* ─── Card accent colors ───────────────────────────────────────── */

.portal-card {
  --card-accent: var(--purple-500);
  --card-accent-bg: rgba(156, 78, 193, 0.08);
  --card-accent-glow: rgba(156, 78, 193, 0.25);
}

.portal-card[data-module="hr"] {
  --card-accent: #3b82f6;
  --card-accent-bg: rgba(59, 130, 246, 0.08);
  --card-accent-glow: rgba(59, 130, 246, 0.25);
}

.portal-card[data-module="finance"] {
  --card-accent: #16a34a;
  --card-accent-bg: rgba(22, 163, 74, 0.08);
  --card-accent-glow: rgba(22, 163, 74, 0.25);
}

.portal-card[data-module="inventory"] {
  --card-accent: #f59e0b;
  --card-accent-bg: rgba(245, 158, 11, 0.08);
  --card-accent-glow: rgba(245, 158, 11, 0.25);
}

.portal-card[data-module="admin"] {
  --card-accent: #6366f1;
  --card-accent-bg: rgba(99, 102, 241, 0.08);
  --card-accent-glow: rgba(99, 102, 241, 0.25);
}

.portal-card[data-module="reports"] {
  --card-accent: #0891b2;
  --card-accent-bg: rgba(8, 145, 178, 0.08);
  --card-accent-glow: rgba(8, 145, 178, 0.25);
}

.portal-card[data-module="sales"] {
  --card-accent: #e11d48;
  --card-accent-bg: rgba(225, 29, 72, 0.08);
  --card-accent-glow: rgba(225, 29, 72, 0.25);
}

/* ─── Card ─────────────────────────────────────────────────────── */

.portal-card {
  background: var(--card-accent-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5) var(--space-4);
  text-align: center;
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  opacity: 0;
  animation: portal-enter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  display: flex;
  flex-direction: column;
}

.portal-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 0 24px var(--card-accent-glow);
  border-color: var(--card-accent);
}

.portal-card .icon {
  width: 36px;
  height: 36px;
  margin: 0 auto var(--space-3);
  color: var(--card-accent);
  stroke: var(--card-accent);
  fill: none;
}

.portal-card h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.portal-card-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.portal-card-link:hover {
  text-decoration: none;
}

.portal-desc {
  margin: var(--space-0) 0 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ─── Card meta (stats) ────────────────────────────────────────── */

.portal-card-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-3);
  margin: var(--space-3) 0 0;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.portal-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.portal-stat strong {
  color: var(--card-accent);
  font-weight: 700;
}

/* ─── Card sub-links ───────────────────────────────────────────── */

.portal-card-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px var(--space-2);
  margin: var(--space-3) 0 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-light);
}

.portal-card-links a {
  font-size: 11px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.portal-card-links a:hover {
  color: var(--card-accent);
  background: var(--card-accent-bg);
}

.portal-card-links .portal-more {
  font-size: 11px;
  color: var(--gray-400);
  padding: 2px 0;
}

/* ─── Search hidden state (JS toggles this) ────────────────────── */

.portal-card[hidden] {
  display: none;
}

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

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

  .portal-page {
    padding: var(--space-4) 0;
  }

  .portal-header h1.portal-greeting {
    font-size: var(--text-lg);
  }

  .portal-name {
    font-size: var(--text-lg);
  }

  .portal-card-links {
    gap: 3px var(--space-0);
  }
}

@media (min-width: 640px) and (max-width: 1023px) {
  .portal-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ================================================================
   Enterprise Unified System — Animations & Transitions
   ================================================================ */

/* ─── Global Transition Defaults ───────────────────────────────── */

*,
*::before,
*::after {
  transition-property: background-color, border-color, color, opacity, box-shadow, transform, filter;
  transition-duration: 0.2s;
  transition-timing-function: ease;
}

/* ─── Page Entry (Reveal) ─────────────────────────────────────── */

@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Loader Bar Sweep ────────────────────────────────────────── */

@keyframes barSweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ─── Loader Bar Shimmer ──────────────────────────────────────── */

@keyframes barShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* ─── Button Spinner ──────────────────────────────────────────── */

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Sidebar Slide ───────────────────────────────────────────── */

@keyframes slideIn {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

@keyframes slideOut {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* ─── Fade ────────────────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ─── Auth Page Background Drift ────────────────────────────────── */

@keyframes gradientDrift {
  0%, 100% { background-position: 0% 30%; }
  25% { background-position: 50% 70%; }
  50% { background-position: 100% 50%; }
  75% { background-position: 50% 30%; }
}

/* ─── Logo Zoom Entrance ───────────────────────────────────────── */

@keyframes logoZoomIn {
  from {
    opacity: 0;
    transform: scale(0);
  }
  70% {
    opacity: 1;
    transform: scale(1.03);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─── Auth Card Entrance ───────────────────────────────────────── */

@keyframes authCardIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ─── Toast Slide (for Swal toasts) ───────────────────────────── */

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ─── Document Modal Progress Sweep ─────────────────────────── */

@keyframes modalProgressSweep {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .loader-mark,
  .loader,
  .loader-text {
    animation: none !important;
  }

  .loader-bar-track {
    animation: none !important;
    width: 50%;
  }

  .loader-bar-fill::after {
    animation: none !important;
  }

  .spinner-xs {
    animation: none !important;
    opacity: 0.5;
  }

  .modal-progress-fill {
    animation: none !important;
  }
}

/* ================================================================
   Enterprise Unified System — SVG Icon Sizing
   ================================================================ */

.icon {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

.icon-xs {
  width: 14px;
  height: 14px;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-md {
  width: 24px;
  height: 24px;
}

.icon-lg {
  width: 32px;
  height: 32px;
}

.icon-xl {
  width: 40px;
  height: 40px;
}

.icon-48 {
  width: 48px;
  height: 48px;
}

.icon-64 {
  width: 64px;
  height: 64px;
}

/* Enterprise Unified System — /help (core bundle)
 *
 * PAGE-SCOPED, NOT SHARED
 * -----------------------
 * Every selector here is namespaced under `.help-*`. /help resolves to the core
 * bundle, and core also serves login, the error pages, /privacy and /terms — so
 * an unscoped rule in this file would restyle all of them.
 *
 * This is the same separation core/07-profile.css documents, for the same
 * reason: the pages here reuse shared classes (`.card`, `.card-body`, `.btn`,
 * `.form-control`) rather than restating them, and anything genuinely
 * page-specific is its own `.help-*` class.
 *
 * The help center was previously all inline `style` attributes inside a
 * `.page-card` wrapper — a class defined in no stylesheet in the repository (the
 * same defect tests/js/profile-styles.test.js documents for /profile). Everything
 * inline is now here.
 */

/* ─── Page header ────────────────────────────────────────────── */

.help-sub {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ─── Layout ─────────────────────────────────────────────────── */

/* One narrow column: help text is read, not scanned across, so a wide measure
 * would hurt it. Capped at the same width the old inline max-width:760px used. */
.help-layout {
  max-width: 760px;
  margin-inline: auto;
}

.help-card {
  max-width: 100%;
}

.help-section {
  margin-top: var(--space-5);
}

.help-section-title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.help-section-sub {
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ─── Search ─────────────────────────────────────────────────── */

.help-search-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

/* Icon + input + button on one row, icon absolutely placed inside the field.
 * `position: relative` on the wrapper is what anchors it. */
.help-search-field {
  position: relative;
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.help-search-icon {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.help-search-input {
  flex: 1;
  min-width: 0;
  /* Room for the absolute icon; without it the placeholder sits under the glass. */
  padding-left: 2rem;
}

.help-search-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.help-search-hint {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.help-search-hint a {
  color: var(--theme);
  font-weight: 500;
}

/* ─── Results ────────────────────────────────────────────────── */

/* Empty until a search runs, so it contributes nothing to the idle page. */
.help-results:not(:empty) {
  margin-bottom: var(--space-4);
}

.help-result + .help-result {
  margin-top: var(--space-2);
}

.help-result-kind {
  margin: 0 0 var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.help-result--guide .help-result-kind {
  color: var(--theme);
}

.help-result-heading {
  margin: 0 0 var(--space-2);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.help-result-summary {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.help-empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
}

.help-empty-title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.help-empty-text {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ─── Guides ─────────────────────────────────────────────────── */

/* One column of cards rather than a grid: a guide is a numbered sequence to be
 * read top to bottom, so two guides side by side invite the wrong reading order. */
.help-guides {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.help-guide-title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.help-guide-summary {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.help-steps {
  margin: 0 0 var(--space-3);
  padding-left: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.help-step {
  line-height: 1.6;
  color: var(--text-secondary);
}

.help-guide-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ─── FAQ ────────────────────────────────────────────────────── */

.help-faq {
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  background: var(--surface);
}

/* Hairlines between items come from the top border on each, so the group reads as
 * one list rather than N separate boxes. */
.help-faq-item + .help-faq-item {
  border-top: 1px solid var(--border);
}

.help-faq-q {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: background-color var(--transition-fast, 120ms);
}

.help-faq-q::-webkit-details-marker {
  display: none;
}

/* A drawn chevron rather than the platform marker, so it does not differ between
 * browsers; `open` on the <details> flips it. */
.help-faq-q::before {
  content: '';
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--transition-fast, 120ms);
  color: var(--text-muted);
}

.help-faq-item[open] .help-faq-q::before {
  transform: rotate(45deg);
}

.help-faq-q:hover {
  background: var(--surface-hover, var(--gray-100));
}

.help-faq-q:focus-visible {
  outline: 2px solid var(--theme);
  outline-offset: -2px;
}

.help-faq-a {
  padding: 0 var(--space-4) var(--space-4);
  color: var(--text-secondary);
  line-height: 1.6;
}

.help-faq-a p {
  margin: 0;
}

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

@media (max-width: 520px) {
  /* Stack the button under the field: three items on one line is unreadable at
   * this width, and a squashed input is worse than a tall row. */
  .help-search-field {
    flex-wrap: wrap;
  }

  .help-search-input {
    flex: 1 0 100%;
  }

  .help-search-btn {
    width: 100%;
  }

  .help-guide-links .btn {
    flex: 1 0 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .help-faq-q,
  .help-faq-q::before {
    transition: none;
  }
}

/* Enterprise Unified System — /privacy and /terms (core bundle)
 *
 * PAGE-SCOPED, NOT SHARED
 * -----------------------
 * Both routes resolve to the core bundle, which also serves /help, login and the
 * error pages — so every selector here is namespaced under `.legal-*`, the same
 * separation core/07-profile.css and core/07-help.css document.
 *
 * Both pages previously used a `.page-card` wrapper with every rule inline.
 * `.page-card` is defined in no stylesheet in the repository (the same defect
 * tests/js/profile-styles.test.js documents for /profile), so those pages were
 * carrying their entire appearance from inline `style` attributes. They now
 * re-use shared classes — `.card`, `.card-body` — for structure, and this file
 * holds only what is genuinely specific to long-form legal prose.
 */

/* Same 760px measure the help center uses: legal prose is read, not scanned. */
.legal-card {
  max-width: 760px;
  margin-inline: auto;
}

.legal-lede {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Clause spacing is uniform, and the LAST clause carries no trailing margin —
   the card's own padding is the bottom edge, so a trailing one doubles it. */
.legal-section + .legal-section {
  margin-top: var(--space-5);
}

.legal-heading {
  margin: 0 0 var(--space-2);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.legal-body {
  color: var(--text-secondary);
  line-height: 1.7;
}

.legal-body p {
  margin: 0;
}

.legal-footer-note {
  margin: var(--space-5) 0 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.legal-footer-note a {
  color: var(--theme);
  font-weight: 500;
}

@media (max-width: 520px) {
  .legal-card {
    max-width: 100%;
  }
}

/* Enterprise Unified System — /profile pages (core bundle)
 *
 * PAGE-SCOPED, NOT SHARED
 * -----------------------
 * Every rule in this file is scoped to a `.profile-*` class. No other page in
 * the application uses any of those names, so these rules cannot change how
 * login, the error pages, or any module-routed page renders — even though they
 * ship in the core bundle, which is the fallback for every non-module route.
 * tests/js/profile-styles.test.js asserts that scoping: it walks this file and
 * fails on any selector that is not namespaced under `profile`.
 *
 * This separation is deliberate. The two primitives this page was missing
 * (.badge-info, .checkbox-inline) are genuinely shared and live in
 * 02-components.css, per module — core and admin only, because those are the
 * only bundles that render them. Anything that only these pages need belongs
 * here instead of in the shared components layer.
 *
 * NOTE ON INHERITANCE: the profile pages reuse shared classes from the design
 * system (`.card`, `.form-group`, `.btn`, `.text-muted`) rather than
 * re-declaring them. That is use, not override — nothing below restates or
 * fights a shared rule. Where a page genuinely needs a *different* shape
 * (`.profile-card--wide`), it is its own profile class, not a modifier on a
 * shared one.
 */

/* ─── Layout shell ───────────────────────────────────────────── */

/* One grid for both settings pages so the two read as one area. Identity and
 * photo sit side by side on desktop; notifications spans the full width because
 * its rows are the widest content on the page. */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  max-width: 1080px;
  margin-inline: auto;
}

.profile-card {
  max-width: 100%;
}

.profile-card--wide {
  grid-column: 1 / -1;
}

/* The password form was an inline `max-width:480px`; as a class it can be
 * tested, and the note above explains why it could not stay inline. */
.profile-card--narrow {
  grid-column: 1 / -1;
  max-width: 520px;
}

/* ─── Settings tabs ──────────────────────────────────────────── */

/* Anchors, not a client-side tab widget: each section is a real page with its
 * own URL, so back/forward and a direct link both work with no JS at all. */
.profile-tabs {
  display: flex;
  gap: var(--space-1);
  max-width: 1080px;
  margin: 0 auto var(--space-4);
  padding: var(--space-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  width: fit-content;
}

.profile-tab {
  padding: var(--space-2) var(--space-4);
  border-radius: calc(var(--radius-md, 8px) - 2px);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--transition-fast, 120ms), color var(--transition-fast, 120ms);
}

.profile-tab:hover {
  background: var(--surface-hover, var(--gray-100));
  color: var(--text-primary);
}

.profile-tab--active {
  background: var(--theme);
  color: var(--text-inverse, #fff);
}

/* ─── Identity ───────────────────────────────────────────────── */

/* Avatar and text sit in one row and wrap: on a narrow screen the text drops
 * below the photo rather than squeezing it. */
.profile-identity {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--theme);
  color: var(--text-inverse, #fff);
  font-size: var(--text-xl, 24px);
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* The photo fills the circle, so its own background never shows; the fallback
 * initials sit on --theme instead. */
.profile-avatar--photo {
  background: var(--surface);
}

.profile-avatar-initials {
  pointer-events: none;
}

.profile-identity-text {
  min-width: 0;
}

.profile-identity-name {
  margin: 0 0 var(--space-1);
  font-size: var(--text-lg, 20px);
  font-weight: 600;
  color: var(--text-primary);
  /* A long name must not push the roles row off the card. */
  overflow-wrap: anywhere;
}

.profile-identity-email {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.profile-roles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* A definition list, not form-groups: these are read-only facts, and a dt/dd
 * pair announces the label/value relationship to a screen reader where a bare
 * <label> + <div> does not. */
.profile-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0 var(--space-5) var(--space-5);
}

.profile-fact dt {
  font-size: var(--text-xs, 12px);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, var(--gray-500));
  margin-bottom: var(--space-1);
}

.profile-fact dd {
  margin: 0;
  font-size: var(--text-base);
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

/* ─── Notices ────────────────────────────────────────────────── */

.profile-notice {
  max-width: 1080px;
  margin: 0 auto var(--space-4);
}

/* ─── Photo upload ───────────────────────────────────────────── */

/* `::file-selector-button` is the one place a profile class may style a
 * shadow part; the element itself is namespaced, so the scope gate holds.
 * Spacing around the field is left to the shared .form-group rule — a
 * profile-scoped selector reaching for .form-group is exactly what this
 * sheet's scope test refuses, and it would be restyling a shared primitive
 * from a page-local sheet. */
.profile-photo-form input[type="file"]::file-selector-button {
  margin-right: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--text-sm);
  cursor: pointer;
}

.profile-photo-form input[type="file"]::file-selector-button:hover {
  background: var(--surface-hover, var(--gray-100));
}

/* ─── Notification preferences ───────────────────────────────── */

/* One type per row: label left, control right, hairline between. A settings
 * list read top-to-bottom beats a two-column grid here — the labels are words,
 * not numbers, so there is nothing to scan across. */
.profile-prefs {
  display: flex;
  flex-direction: column;
}

.profile-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
  border-radius: var(--radius-sm, 6px);
  transition: background-color var(--transition-fast, 120ms);
}

/* The last row's hairline is the card edge repeating itself; the row above it
 * is the real divider. */
.profile-pref-row:last-child {
  border-bottom: 0;
}

.profile-pref-row:hover {
  background: var(--surface-hover, var(--gray-100));
}

.profile-pref-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-base);
  color: var(--text-primary);
  font-weight: 500;
}

/* The control sits in its own box rather than as a bare input, so the hit area
 * matches the row and the focus ring has something to draw on. */
.profile-pref-control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  min-height: 32px;
}

.profile-pref-control input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--theme);
}

/* Exempt rows: the control is disabled server-side, so it must read as
 * non-negotiable rather than as an option the admin failed to set. */
.profile-pref-row--exempt {
  opacity: 0.75;
}

.profile-pref-control input[disabled] {
  cursor: not-allowed;
}

.profile-pref-control input[disabled] + span {
  cursor: not-allowed;
  color: var(--text-secondary);
}

/* ─── Error summary ──────────────────────────────────────────── */

/* Replaces the inline `display:none` this div carried. 19-error-renderer.js
 * reveals it with an inline `style.display='block'`, which outranks a class, so
 * the shared renderer needs no change. */
.profile-error-summary {
  display: none;
}

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

/* 1024px: the two-column grid stops earning its keep — the photo card's form
 * has nothing to sit beside that the identity card does not already show. */
@media (max-width: 1023px) {
  .profile-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 639px) {
  .profile-card--narrow {
    max-width: 100%;
  }

  .profile-tabs {
    width: 100%;
  }

  .profile-tab {
    flex: 1;
    text-align: center;
    padding-inline: var(--space-2);
  }

  .profile-identity {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-3);
    padding: var(--space-4);
  }

  .profile-identity .profile-roles {
    justify-content: center;
  }

  .profile-facts {
    padding: 0 var(--space-4) var(--space-4);
  }

  /* Below 639px the label and control stop competing for one line. */
  .profile-pref-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .profile-pref-control {
    align-self: flex-start;
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .profile-tab,
  .profile-pref-row {
    transition: none;
  }
}
/* ================================================================
   Print all — the pager's print button, and the off-screen
   container the print stylesheet reveals.
   ================================================================ */

/* ─── The button ────────────────────────────────────────────────────
   It lives inside `.pagination-info`, which is why that element
   becomes a row here. `.pagination` is `space-between` with three
   children once this lands, so the record count and its Print button
   are grouped on the left and the page links stay on the right —
   without a wrapper that the shared `.pagination` rule in
   02-components.css would need a 10-file edit, and that file has nine
   legitimate variants. Only `display`/`align-items` are added; the
   existing colour and font-size rules still apply. */

.pagination-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.print-all-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* ─── The print container ───────────────────────────────────────────
   `display: none` rather than parked off-screen with a negative
   offset: the page sets `overflow-x: clip` on `html, body`, and an
   out-of-flow element whose containing block is the viewport is not
   reliably exempt from that clip. Nothing off-screen can be clipped
   because nothing off-screen exists. */

#print-root {
  display: none;
}

@media print {
  /* Only the print container paints, and only while a print-all is
     actually running. The body class is added immediately before
     window.print() and removed on afterprint, so a normal Ctrl+P
     still prints the page exactly as before — this feature does not
     change ordinary printing. */
  body.print-all-on > *:not(#print-root) {
    display: none !important;
  }

  body.print-all-on #print-root {
    display: block;
    color: #000;
    background: #fff;
  }

  #print-root .print-all-head {
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid #999;
  }

  #print-root .print-all-title {
    margin: 0 0 var(--space-1);
    font-size: var(--text-lg);
    font-weight: 700;
    color: #000;
  }

  #print-root .print-all-meta {
    margin: 0;
    font-size: var(--text-sm);
    color: #333;
  }

  /* `.table-container` is `overflow-x: auto` on screen so a wide table
     scrolls instead of pushing the layout. In print there is no
     viewport to scroll, so the container is un-clipped — otherwise every
     column past the page width is simply lost, silently. The shared
     `@media print` block in 01-layout.css hides the chrome but does not
     do this, which is why a plain Ctrl+P of a wide table already
     prints it clipped. */
  #print-root .table-container {
    overflow: visible !important;
    max-height: none !important;
  }

  /* Repeat the column headings on every page of a multi-page printout.
     Without this a 40-page printout has column headers on page 1 only. */
  #print-root thead {
    display: table-header-group;
  }

  /* Keep a row whole rather than splitting it across a page boundary. */
  #print-root tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Belt and braces for the dark theme: the shared print block already
     forces white `body` and a `#f5f5f5` `th`, but badges and status tints
     are painted with theme tokens that stay dark, so they are forced to
     print with their own background rather than as black-on-black. */
  #print-root .badge {
    color: #000 !important;
    background: transparent !important;
    border: 1px solid #999;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ─── Whole-page print readiness ────────────────────────────────────
   The shell clips its content to the viewport for on-screen scrolling:
   `.main-body` and `.main-content` are `height: 100vh` + `overflow:
   hidden` (01-layout.css), the list tables and dashboard card bodies are
   their own scroll regions, and `.main-content .card .table-container`
   caps at 50vh (02-components.css). In print there is no viewport to
   scroll, so everything below the fold is silently dropped. These rules
   lift the clamps for an ordinary Ctrl+P and for the dashboard Print
   buttons. The print-all path is untouched: `body.print-all-on` already
   hides every sibling of #print-root. This is a `24-` file, so it loads
   after 01-/02-; `!important` lets it beat the higher-specificity
   on-screen rules without editing those nine-variant files. */

@media print {
  .main-body {
    height: auto !important;
    overflow: visible !important;
  }

  .main-content {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  .main-content > .table-container,
  .main-content .card .table-container:not(.table-container--form),
  .table-container {
    overflow: visible !important;
    max-height: none !important;
    flex: none !important;
  }

  .card.card-section,
  .production-dashboard .card.card-section,
  .billdash-chart-wrap,
  .podash-chart-wrap {
    overflow: visible !important;
    max-height: none !important;
  }

  /* A chart or KPI card reads wrong when split across a sheet. The big
     table cards are deliberately NOT included: a multi-page table must
     break, and `break-inside: avoid` on a taller-than-page box is ignored
     anyway. */
  .podash-chart,
  .billdash-chart,
  .billdash-kpicard {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* The raw filter controls print as empty boxes. `.filters` is already
     hidden by 01-layout.css, but the integrated list toolbar
     (`.filter-toolbar`) and the two dashboard filter bars are not. The
     print header below carries the same information as text. */
  .filter-toolbar,
  .billdash-filterbar,
  .podash-filterbar {
    display: none !important;
  }
}

/* ─── Uniform print header (every list and dashboard print) ─────────
   Built by refreshHeader() in 24-print-all.js: the page title, the
   applied filters as text and the printed-at stamp, prepended to
   `.main-content`. Hidden on screen, and once more hidden on the
   print-all path because `body.print-all-on` replaces the whole body
   with #print-root. `body.page-has-print-head` suppresses the now-
   duplicate on-page <h1>, but only where this header actually exists. */

#page-print-head {
  display: none;
}

@media print {
  #page-print-head {
    display: block !important;
    color: #000;
    background: #fff;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid #999;
  }

  #page-print-head .page-print-title {
    margin: 0 0 var(--space-1);
    font-size: var(--text-lg);
    font-weight: 700;
    color: #000;
  }

  #page-print-head .page-print-meta {
    margin: 0;
    font-size: var(--text-sm);
    color: #333;
  }

  body.page-has-print-head .page-header h1 {
    display: none !important;
  }
}
/* ================================================================
   Column chooser — the disclosure that lives beside the search
   control on every list page, and the fixed columns' print rules.
   ================================================================ */

/* ─── The row it shares with the search control ─────────────────
    The form and the chooser are two children of one .filter-bar-row,
    so they sit on a single line rather than the chooser wrapping to
    its own row. (In integrated mode the page header is a flex column,
    so without this wrapper they were two stacked children.) On narrow
    screens the row collapses to a column and the chooser drops under
    the search, matching .filters at the same breakpoint.

    The panel is absolutely positioned rather than pushing the page
    down — a column chooser that reflows the table while you are
    clicking it is unusable, because the rows you are aiming at move. */

.filter-bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-width: 0;
}

.filter-bar-row > .filter-search {
  flex: 1 1 0%;
  min-width: 0;
}

.col-picker {
  position: relative;
  display: block;
  width: max-content;
  max-width: 100%;
  margin-left: auto;
  margin-top: 0;
  flex: 0 0 auto;
}

@media (max-width: 639px) {
  .filter-bar-row {
    flex-direction: column;
    align-items: stretch;
  }
  .col-picker {
    margin-left: 0;
    margin-top: var(--space-2);
    align-self: flex-start;
  }
}

.col-picker-summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  min-height: 28px;
  min-width: 28px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

/* The default disclosure triangle is dropped in favour of the icon
   already inside the summary; both WebKit and Firefox need this. */
.col-picker-summary::-webkit-details-marker {
  display: none;
}

.col-picker-summary:hover {
  color: var(--purple-600);
  border-color: var(--purple-300);
  background: var(--surface-card);
}

.col-picker-summary:focus-visible {
  outline: 2px solid var(--purple-500);
  outline-offset: 1px;
}

.col-picker[open] .col-picker-summary {
  color: var(--purple-600);
  border-color: var(--purple-300);
  background: var(--surface-card);
}

.col-picker-panel {
  position: absolute;
  z-index: 1050;
  top: calc(100% + 6px);
  right: 0;
  width: 260px;
  max-width: calc(100vw - 32px);
  max-height: 320px;
  overflow-y: auto;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  box-shadow: var(--shadow-lg);
  text-align: left;
}

.col-picker-actions {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

/* ─── One row per column ─────────────────────────────────────────── */

.col-picker-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.col-picker-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
}

.col-picker-item:hover {
  background: var(--gray-50);
}

.col-picker-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--purple-600);
  cursor: pointer;
}

/* A column that carries row behaviour rather than data. Labelled, not just
   greyed — a disabled checkbox with no explanation is a control the user has to
   guess at. */
.col-picker-item--fixed {
  color: var(--text-secondary);
  cursor: default;
}

.col-picker-item--fixed:hover {
  background: none;
}

.col-picker-item--fixed input[type="checkbox"] {
  cursor: not-allowed;
  opacity: 0.55;
}

.col-picker-item-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-picker-item-note {
  flex: 0 0 auto;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ─── Print: the two fixed columns never print ─────────────────────
   Both are blemishes on paper. The Actions column prints as a wide
   empty band, because §12.1 hides `.btn` and leaves the column
   itself; the bulk-select checkbox column prints as a column of
   little boxes. Neither is data, so neither is printed.

   The reliable half of this is in 26-col-picker.js, which knows each
   fixed column's INDEX (it found Actions by its header text, because
   30 of the 31 <th>Actions</th> in the views are bare and a CSS rule
   cannot match on text). What stays here is only what a real
   attribute or class can identify, so the two halves can never
   disagree about which columns were dropped. */

@media print {
  .table-container table thead th[data-filter-exclude] {
    display: none !important;
  }
}

/* ────────────────────────────────────────────────────────────────
   Per-module modal styles — notification + modal overlay.

   Per-module canonical copy: this file lives directly in each module
   folder (<module>/90-modal.css) and is concatenated into that module's
   compiled app.css. There is no shared/ source — keep all 9 copies
   identical and edit each module in place.

    Contents: notification bell / panel / item classes (identical in
    all 9 modules) + the canonical modal overlay/content styles
    (header/body/modal--lg layout, overlay blur, entrance animation,
    dark-mode shadow, reduced-motion guard).



    To keep modals/notifications visually identical on EVERY module, the
    component pins its own theme tokens below. This stops per-module
    theme drift (e.g. procurement's teal re-theme changing --text-primary)
    from bleeding into shared components. Light-first: base rules use the
    light values (matching the app's :root default); [data-theme="dark"]
    flips to dark — so the panel/modal follow the page theme on load.
    ──────────────────────────────────────────────────────────────── */

/* ─── Component token pin (self-contained, brand-neutral) ─────── */

.notification-bell,
.notification-panel,
.notification-panel *,
.modal-overlay,
.modal-content,
.modal-content *,
.swal2-container,
.swal2-popup,
.swal2-popup * {
  --surface-card:     #ffffff;
  --surface:          #f1f5f9;
  --surface-elevated: #ffffff;
  --border:           #e2e8f0;
  --border-light:     #f1f5f9;
  --text-primary:     #0f172a;
  --text-secondary:   #64748b;
  --info-bg:          #dbeafe;
  --danger:           #dc2626;
  --gray-200:         #e5e7eb;
  --gray-400:         #9ca3af;
  --gray-900:         #111827;
  /* Accent for the bell's interactive parts. The shared block below is
     byte-identical in all 10 modules, so a module's hover colour lives here
     rather than as a two-line divergence inside the item rules that a
     cp-sync would silently overwrite. */
  --notif-accent:      #7c3aed;
  --notif-accent-soft: #c084fc;
}

[data-theme="dark"] .notification-bell,
[data-theme="dark"] .notification-panel,
[data-theme="dark"] .notification-panel *,
[data-theme="dark"] .modal-overlay,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-content *,
[data-theme="dark"] .swal2-container,
[data-theme="dark"] .swal2-popup,
[data-theme="dark"] .swal2-popup * {
  --surface-card:     #1e293b;
  --surface:          #0f172a;
  --surface-elevated: #334155;
  --border:           #334155;
  --border-light:     #475569;
  --text-primary:     #f1f5f9;
  --text-secondary:   #94a3b8;
  --info-bg:          #dbeafe;
  --danger:           #dc2626;
  --gray-200:         #e5e7eb;
  --gray-400:         #9ca3af;
  --gray-900:         #111827;
  --notif-accent:      #b573d2;
  --notif-accent-soft: #d8b4fe;
}

/* ─── Notification Bell ────────────────────────────────────────── */

/* The bell is a <button> (layouts/app.php), so these rules reset the UA
   button chrome. 01-layout.css owns the 36px box, border and shadow; this only
   has to stop the browser from adding its own padding, border and font. */
.notification-bell {
  position: relative;
  cursor: pointer;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  padding: 0;
  font: inherit;
  background: none;
  border: none;
}

.notification-bell:focus-visible {
  outline: 2px solid var(--notif-accent);
  outline-offset: 2px;
}

.notification-bell[aria-expanded="true"] {
  color: var(--notif-accent);
}

/* min-width + padding rather than a fixed width, so "99+" becomes a pill
   instead of spilling out of an 18px circle. formatBadgeCount() in
   23-notifications.js caps the number at 99+. */
.notification-count {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--surface-card);
}

/* ─── Notification Panel (positioned below bell) ──────────────── */

.notification-panel {
  position: fixed;
  z-index: 9999;
  width: min(420px, calc(100vw - 40px));
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.95);
  transform-origin: top right;
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.notification-panel.open {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
}

.notification-panel-arrow {
  position: absolute;
  top: -6px;
  right: 16px;
  width: 12px;
  height: 12px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-right: none;
  border-bottom: none;
  transform: rotate(45deg);
  z-index: 1;
}

.notification-panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-3) 10px var(--space-4);
  border-bottom: 1px solid var(--border);
}

.notification-panel-header h3 {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.notification-panel-count {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

.notification-panel-count--clear {
  color: var(--gray-400);
}

.notification-panel-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.notification-panel-tools .btn {
  padding: 2px 8px;
  min-height: 0;
  font-size: var(--text-xs);
  white-space: nowrap;
}

.notification-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.notification-panel-close:hover {
  background: var(--gray-200);
  color: var(--text-primary);
}

.notification-panel-close:focus-visible {
  outline: 2px solid var(--notif-accent);
  outline-offset: 1px;
}

/* The scrollbar is hidden app-wide, so with up to 50 rows the panel looked
   exactly the same whether it held 3 notifications or 50. The two `local`
   layers are the white cover that hides each shadow at its own extreme, and
   the two `scroll` layers are the shadows themselves — so a fade appears only
   while there is actually more list in that direction. */
.notification-panel-body {
  max-height: 400px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background:
    linear-gradient(var(--surface-card) 40%, rgba(255, 255, 255, 0)) top / 100% 20px no-repeat local,
    linear-gradient(rgba(255, 255, 255, 0), var(--surface-card) 60%) bottom / 100% 20px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(15, 23, 42, 0.10), rgba(15, 23, 42, 0)) top / 100% 9px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(15, 23, 42, 0.10), rgba(15, 23, 42, 0)) bottom / 100% 9px no-repeat scroll;
}
.notification-panel-body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.notification-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.notification-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
}

.notification-empty .icon {
  color: var(--gray-400);
  margin: 0 auto var(--space-2);
}

.notification-empty p {
  margin: 0 0 var(--space-2);
}

.notification-empty .btn {
  margin-top: var(--space-1);
}

.notification-panel-footer {
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border);
  text-align: center;
}

.notification-panel-all {
  display: inline-block;
  font-size: var(--text-xs);
  color: var(--notif-accent);
  text-decoration: none;
  padding: 2px 0;
}

.notification-panel-all:hover {
  text-decoration: underline;
}

.notification-panel-all:focus-visible {
  outline: 2px solid var(--notif-accent);
  outline-offset: 2px;
}

/* ─── Notification Item Classes ─────────────────────────────── */

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 10px var(--space-3) 10px var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-item:hover {
  background: var(--gray-100, #f1f5f9);
}

.notification-item:focus-visible {
  outline: 2px solid var(--notif-accent);
  outline-offset: -2px;
}

/* Unread reads as an accent bar plus the weight bump, not a full-bleed wash —
   a tinted row made the text harder to read and fought the hover state. */
.notification-item--unread {
  box-shadow: inset 3px 0 0 var(--notif-accent);
  background: color-mix(in srgb, var(--info-bg) 35%, transparent);
}

.notification-item--unread:hover {
  background: color-mix(in srgb, var(--info-bg) 60%, transparent);
}

[data-theme="dark"] .notification-item--unread {
  background: color-mix(in srgb, var(--info-bg) 10%, transparent);
}

.notification-item-content {
  flex: 1;
  min-width: 0;
}

.notification-item-title {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.notification-item--unread .notification-item-title {
  font-weight: 600;
}

.notification-item-body {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notification-item-foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: 4px;
  flex-wrap: wrap;
}

.notification-item-meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--notif-accent);
}

.notification-item-meta .icon {
  width: 11px;
  height: 11px;
}

.notification-item-module {
  white-space: nowrap;
}

.notification-item-time {
  font-size: 10px;
  color: var(--gray-400);
  margin-left: auto;
  white-space: nowrap;
}

.notification-item-action {
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.notification-item:hover .notification-item-action,
.notification-item:focus-within .notification-item-action {
  opacity: 1;
}

/* Hover-reveal is a pointer affordance. Gating it on width meant a touch
   tablet between 768px and 1023px could never reach "Mark as unread" — the
   button was there and permanently invisible. Query the input device instead:
   anything without a real hover gets the control permanently. */
@media (hover: none), (pointer: coarse) {
  .notification-item-action {
    opacity: 1;
  }
}

/* ─── Tablet: narrower panel + compact items ────────────────── */

@media (max-width: 767px) {
  .notification-panel {
    width: min(360px, calc(100vw - 40px));
  }
  .notification-item {
    gap: var(--space-2);
    padding: 10px var(--space-3);
  }
}

/* ─── Mobile ────────────────────────────────────────────────── */

@media (max-width: 639px) {
  .notification-panel {
    position: fixed;
    top: var(--notif-panel-top, auto) !important;
    right: 8px !important;
    left: 8px !important;
    bottom: auto !important;
    width: auto;
    max-width: none;
  }
  .notification-panel-arrow {
    display: none;
  }
  .notification-panel-body {
    max-height: 60vh;
  }
  .notification-panel-header {
    padding: 10px var(--space-3);
  }
  .notification-item {
    padding: 12px var(--space-3);
  }
  .notification-item .btn-sm {
    font-size: 12px;
    padding: 6px 12px;
  }
  .notification-item-action {
    opacity: 1;
  }
}

/* ─── Modals (legacy - migrate to SweetAlert2) ─────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-overlay.open .modal-content {
  animation: modal-in 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-content {
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  width: fit-content;
  min-width: min(480px, 90vw);
  max-width: 90vw;
  min-height: min(260px, 70vh);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.modal-content .card {
  box-shadow: 0 0px 1px 2px rgb(0 0 0 / 7%);
}

[data-theme="dark"] .modal-content {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.modal-header h2,
.modal-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
#notification-detail-modal .modal-body {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#notification-detail-modal .modal-body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.modal-content .close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--text-xl);
  padding: var(--space-0);
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease, background 0.2s ease;
}

.modal-content .close-btn:hover {
  color: var(--text-primary);
  background: var(--surface);
}

/* Back button — same style as close-btn, placed left of it */
.modal-content .modal-back-btn {
  margin-right: auto;
}

/* Dotted borders between consecutive form-row groups inside modals */
.modal-content .form-row + .form-row {
  border-top: 1px dotted var(--border-light);
  padding-top: var(--space-3);
  margin-top: var(--space-3);
}

.modal-content.modal--lg {
  min-width: min(900px, 90vw);
  max-width: 90vw;
}

.modal-content.modal--xl {
  min-width: min(1100px, 94vw);
  max-width: 94vw;
}

/* ─── Document Preview Modal ── */

#document-modal .modal-header {
  gap: var(--space-3);
}

#document-modal-body {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#document-modal-body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

#document-modal-loading .modal-progress {
  width: min(420px, 70vw);
  height: 4px;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--surface-elevated);
  overflow: hidden;
  position: relative;
}

#document-modal-loading .modal-progress-fill {
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--theme-accent), transparent);
  animation: modalProgressSweep 1.4s ease-in-out infinite;
}

#document-frame {
  width: 100%;
  height: 72vh;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

@media (max-width: 639px) {
  #document-frame {
    height: 60vh;
  }
}

/* ─── Notification Detail Modal (preview header + record card) ── */

.notification-detail-message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* Canonical record preview: the main table sits in an outer section box; any
   FK-linked tables render as inline subsections nested inside that box. */
.preview-section {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 6px rgba(16, 24, 40, 0.06);
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  overflow: hidden;
}

.preview-section:last-child {
  margin-bottom: 0;
}

.preview-section .card-header {
  padding: var(--space-2) var(--space-2) var(--space-3);
}

.preview-section .table-container {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* Inline subsection nested inside the outer section: crisp inset ring, no
   drop shadow, tighter heading so it reads as a child of the main table. */
.preview-subsection {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--border);
}

.preview-subsection .card-header {
  padding: 0 0 var(--space-2);
}

.preview-subsection .card-header h3 {
  font-size: var(--text-sm);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.preview-subsection .table-container {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* Headers read as headers, values as content (modal preview only). */
#notification-detail-modal .card .table-container th {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .modal-overlay.open .modal-content {
    animation: none;
  }
}

/* ─── SweetAlert2 overrides ───────────────────────────────────── */
/* Canonical swal2 styling (title, popup, buttons, inputs, backdrop).
   Per-module canonical copy: this file ships directly in each module
   folder (<module>/90-modal.css); keep all 9 copies identical. */

.swal2-container {
  z-index: 1000000 !important;
}

.swal2-backdrop-show {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.swal2-popup {
  --swal2-background: var(--surface-card);
  --swal2-border-radius: var(--radius-xl);
  --swal2-title-padding: var(--space-5) var(--space-6) 0;
  --swal2-html-container-padding: 1em 1.75em 0.4em;
  --swal2-outline: 0 0 0 3px rgba(156, 78, 193, 0.35);
  --swal2-confirm-button-background-color: var(--purple-600);
  --swal2-confirm-button-color: #fff;
  --swal2-confirm-button-border-radius: var(--radius-md);
  --swal2-confirm-button-box-shadow: 0 4px 12px rgba(108, 42, 128, 0.25);
  --swal2-cancel-button-background-color: var(--gray-200);
  --swal2-cancel-button-color: var(--text-primary);
  --swal2-cancel-button-border-radius: var(--radius-md);
  --swal2-cancel-button-box-shadow: none;
  --swal2-input-border: 1px solid var(--border);
  --swal2-input-border-radius: var(--radius-md);
  --swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;
  --swal2-input-focus-border: 1px solid var(--purple-400);
  --swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(156, 78, 193, 0.2);
  --swal2-close-button-color: var(--text-secondary);
  --swal2-close-button-font-size: var(--text-2xl);
  --swal2-timer-progress-bar-background: var(--purple-500);
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(26, 10, 46, 0.35), 0 0 0 1px rgba(108, 42, 128, 0.06);
  color: var(--text-primary);
}

[data-theme="dark"] .swal2-popup {
  --swal2-cancel-button-background-color: var(--surface-elevated);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.swal2-title {
  color: var(--purple-700);
  background: linear-gradient(120deg, var(--purple-700), var(--purple-500));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: clamp(var(--text-xl), 1.3vw + 1rem, var(--text-2xl));
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

@supports not (-webkit-background-clip: text) {
  .swal2-title {
    color: var(--purple-700);
    -webkit-text-fill-color: currentColor;
    background: none;
  }
}

[data-theme="dark"] .swal2-title {
  color: var(--purple-300);
  -webkit-text-fill-color: currentColor;
  background: none;
}

.swal2-html-container {
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: 1.6;
}

.swal2-icon {
  margin-top: var(--space-5);
}

/* Icon entrance: SWAL2's success icon has no container animation (only the
   checkmark draws), and the other icons use a subtle 3D flip, so all of them
   read as a flat fade. Give every icon a snappy scale pop instead. */
@keyframes swal2-icon-pop {
  0%   { transform: scale(0.2); opacity: 0; }
  55%  { transform: scale(1.1); opacity: 1; }
  78%  { transform: scale(0.92); }
  100% { transform: scale(1); opacity: 1; }
}

.swal2-icon.swal2-icon-show {
  animation: swal2-icon-pop 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Draw the success checkmark in sync with the pop instead of the slower
   default .75s per line. */
.swal2-success.swal2-icon-show .swal2-success-line-tip,
.swal2-success.swal2-icon-show .swal2-success-line-long {
  animation-duration: 0.5s;
}

@media (prefers-reduced-motion: reduce) {
  .swal2-icon.swal2-icon-show {
    animation: none;
  }
}

.swal2-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  transition: color 0.2s, background 0.2s;
}

.swal2-close:hover {
  color: var(--text-primary);
  background: var(--surface);
}

.swal2-actions {
  margin-top: var(--space-6);
}

.swal2-styled {
  min-height: var(--btn-h-modal);
  padding: var(--space-2) var(--space-6);
  font-weight: 600;
}

.swal2-html-container .swal-status {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-3);
}

.swal2-html-container .swal-status-badge {
  padding: 3px var(--space-3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.swal2-html-container .swal-status-msg {
  margin: 0 auto;
  max-width: 34em;
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: 1.6;
  text-align: center;
  overflow-wrap: break-word;
}

@media (max-width: 639px) {
  .swal2-icon {
    margin-top: var(--space-4);
    --swal2-icon-zoom: 0.8;
  }
  .swal2-html-container {
    font-size: var(--text-sm);
  }
}

/* ────────────────────────────────────────────────────────────────
   Per-module error-page styles
   (403 / 404 / 419 / 429 / 500 / 503).

    Per-module canonical copy: this file lives directly in each module
    folder (<module>/91-errors.css) and is concatenated into that module's
    compiled app.css. There is no shared/ source. Styles are self-contained
    (purple accent, pinned text tokens) so they are never affected by
    per-module theme drift. Keep all 9 copies identical; edit in place.

   Contents: .error-page-wrap (purple animated gradient), .error-page-card
   (glass card, light/dark), hero icon, h1/p, .error-actions,
   .error-countdown (+ hint/strong), .error-ref, error-pulse, and the
   ≤639px responsive tuning. Every error page renders the identical
   canonical look in every module — the accent is always purple, never
   module-specific.

    Theme model is light-first (mirrors setup.php's error page and the
    app's :root default): the base rules assume the light purple tint/
    glass, so base TEXT is dark-on-light; [data-theme="dark"] flips to
    light-on-dark purple gradient. The purple accent stays in both modes.
    Never use --text-*/--purple-* tokens for base text here.
   ──────────────────────────────────────────────────────────────── */

/* ─── Wrap (animated purple gradient, flex-centered) ──────────── */

/* Fill the full .main-content (past its top-bar/footer padding reserves)
   so the card centers exactly on the viewport. Removing the padding
   reserves (instead of negative margins, which the fixed footer/overflow
   combo rendered unreliably) lets the wrap's plain flex-grow span the
   whole main-content — from behind the fixed top-bar down to/behind the
   fixed app-footer with no surface gap. */
.main-content:has(> .error-page-wrap) {
  padding: 0;
  overflow: visible;
}

.error-page-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  border-radius: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(124, 58, 237, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(108, 42, 128, 0.08) 0%, transparent 50%),
    linear-gradient(135deg, #f5f3ff, #ede9fe);
  animation: none;
}

[data-theme="dark"] .error-page-wrap {
  background:
    radial-gradient(circle at 20% 80%, rgba(124, 58, 237, 0.10) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(108, 42, 128, 0.06) 0%, transparent 50%),
    linear-gradient(135deg, var(--purple-800), var(--purple-950));
  background-size: 200% 200%, 200% 200%, 400% 400%;
  animation: gradientDrift 20s ease infinite;
}

/* ─── Hero Icon ──────────────────────────────────────────────── */

.error-page-icon {
  color: var(--purple-500);
  stroke: var(--purple-500);
  margin-bottom: var(--space-4);
}

[data-theme="dark"] .error-page-icon {
  color: rgba(255, 255, 255, 0.92);
  stroke: rgba(255, 255, 255, 0.92);
}

/* ─── Card (glass, centered) ──────────────────────────────────── */

.error-page-card {
  position: relative;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.10), 0 8px 32px rgba(0, 0, 0, 0.06);
  animation: authCardIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
  z-index: 1;
  overflow: hidden;
}

.error-page-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
}

.error-page-card h1 { color: var(--text-primary); }
.error-page-card p { color: var(--text-secondary); }
.error-page-card .icon { color: var(--purple-600); stroke: var(--purple-600) !important; }
.error-page-card a { color: var(--purple-600); }

[data-theme="dark"] .error-page-card {
  background: radial-gradient(ellipse at 50% 0%, rgba(124, 58, 237, 0.15) 0%, rgba(255, 255, 255, 0.04) 70%);
  border-color: rgba(124, 58, 237, 0.2);
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.15), 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 48px rgba(124, 58, 237, 0.08);
}
[data-theme="dark"] .error-page-card::after {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, transparent 50%);
}
[data-theme="dark"] .error-page-card .icon { color: rgba(255, 255, 255, 0.92); stroke: rgba(255, 255, 255, 0.92) !important; }

[data-theme="dark"] .error-page-card h1 { color: white; }
[data-theme="dark"] .error-page-card p { color: rgba(255, 255, 255, 0.55); }
[data-theme="dark"] .error-page-card a { color: rgba(255, 255, 255, 0.6); }

/* ─── Card heading / body text ────────────────────────────────── */

.error-page-card h1 {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: var(--space-4) 0 var(--space-2);
}

.error-page-card p {
  color: var(--text-secondary);
  margin: 0 0 var(--space-6);
  font-size: var(--text-base);
}

/* Dark theme flips the light-first base to light-on-dark text. */
[data-theme="dark"] .error-page-card h1 { color: white; }
[data-theme="dark"] .error-page-card p { color: rgba(255, 255, 255, 0.55); }
[data-theme="dark"] .error-page-card a { color: rgba(255, 255, 255, 0.6); }

/* ─── Action row ──────────────────────────────────────────────── */

.error-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-6);
}

.error-page-wrap .btn-secondary {
  background: var(--gray-200);
  color: var(--gray-900);
  border: 1px solid var(--border);
}
.error-page-wrap .btn-secondary:hover {
  background: var(--gray-300);
  color: var(--gray-900);
}

.error-page-wrap .btn-primary {
  color: white;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

/* ─── Countdown (419 / 429 / 503) ──────────────────────────────── */

.error-countdown {
  margin-top: var(--space-4);
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.error-countdown strong {
  color: var(--purple-600);
  font-size: var(--text-lg);
}

[data-theme="dark"] .error-countdown { color: rgba(255, 255, 255, 0.55); }
[data-theme="dark"] .error-countdown strong { color: var(--purple-400); }

.error-countdown .error-countdown-hint {
  font-size: var(--text-sm);
  opacity: 0.85;
  margin-top: var(--space-2);
  margin-bottom: 0;
}

/* ─── Error reference (500) ───────────────────────────────────── */

.error-ref {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

[data-theme="dark"] .error-ref { color: rgba(255, 255, 255, 0.45); }

/* ─── Hero icon pulse ─────────────────────────────────────────── */

@keyframes error-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.03); }
}

.error-page-wrap .icon {
  animation: error-pulse 2s ease-in-out infinite;
}

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

@media (max-width: 639px) {
  .error-page-wrap {
    padding: var(--space-6) var(--space-4);
  }
  .error-page-card {
    padding: var(--space-8) var(--space-5);
  }
  .error-page-card h1 {
    font-size: var(--text-2xl);
    margin: var(--space-3) 0 var(--space-2);
  }
  /* Shrink the hero icon on small screens (overrides .icon-64). */
  .error-page-icon,
  .error-page-wrap .error-page-icon,
  .error-page-card .error-page-icon {
    width: 52px;
    height: 52px;
  }
  /* Stack action buttons into a single full-width column on mobile. */
  .error-actions {
    flex-direction: column;
    gap: var(--space-3);
  }
  .error-actions .btn {
    width: 100%;
  }
  .error-countdown {
    font-size: var(--text-xs);
  }
}

