/* ═══════════════════════════════════════════════════════════════════
   DocTracker — Design System (Claude-inspired, spec 002)

   Table of Contents
   ─────────────────
   ~L1    TOKENS          — :root + [data-theme="dark"]
   ~L230  RESET           — universal reset + base elements
   ~L280  LAYOUT          — app shell, navbar, main, control panel
   ~L500  COMPONENTS      — cards, buttons, forms, tables, badges,
                            dropdowns, empty state, skeletons, toasts
   ~L2500 PAGES           — page-specific styles (documents, scanner…)
   ~L4000 UTILITIES       — small helper classes (.text-*, .flex, etc.)
   ═══════════════════════════════════════════════════════════════════ */

/* Fonts — Inter (UI) + Fraunces (display for hero numerics) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,500;9..144,600&display=swap');

/* =========== TOKENS =========== */
:root {
  /* ── Color palette: warm, Claude-inspired neutrals ── */
  --app-bg:           #FAF9F7;   /* page body */
  --surface:          #FFFFFF;   /* card / surface */
  --surface-subtle:   #F4F2EE;   /* cream — alternate surface */
  --surface-muted:    #EBE8E1;   /* muted backgrounds */
  --surface-sunken:   #F0EDE6;   /* scanner dropzones, code blocks */

  --border:           #E5E1D8;
  --border-strong:    #D6D1C5;
  --border-subtle:    #EEEBE4;

  --text-strong:      #1F1D1A;   /* headings, emphasized */
  --text-default:     #38342E;   /* body */
  --text-muted:       #6E6860;   /* secondary, captions */
  --text-subtle:      #95907F;   /* hints, disabled labels */

  /* ── Brand + accent ── */
  --primary:          #714B67;
  --primary-hover:    #5E3D55;
  --primary-active:   #4C3145;
  --primary-bg:       #F5EFF3;   /* very subtle plum tint for selection */
  --primary-ring:     rgba(113, 75, 103, 0.18);

  /* ── Semantic status (refined for warm base) ── */
  /* -bg-subtle: ~4% saturation — for data viz / ambient state display.
     -bg:        ~12% saturation — for alerts / banners / active attention. */
  --success:             #1D7F5E;
  --success-bg:          #E4EFE4;
  --success-bg-subtle:   #F1F6EE;
  --success-text:        #1A4F3C;
  --danger:              #B33A3A;
  --danger-bg:           #FBE8E4;
  --danger-bg-subtle:    #FAF1EE;
  --danger-text:         #7A2323;
  --warning:             #B07417;
  --warning-bg:          #FBEFD9;
  --warning-bg-subtle:   #FAF5E9;
  --warning-text:        #5E3E08;
  --info:                #2F6EAD;
  --info-bg:             #E6EEF6;
  --info-bg-subtle:      #F1F5F9;
  --info-text:           #1E456D;
  --neutral-bg:          #EFECE5;
  --neutral-text:        #5F5A50;

  /* ── Type-specific badge colors (kept for BL/Facture/Avoir) ── */
  --badge-bl-bg:      var(--info-bg);
  --badge-bl-text:    var(--info-text);
  --badge-fac-bg:     var(--warning-bg);
  --badge-fac-text:   var(--warning-text);
  --badge-avoir-bg:   #F2E4EB;
  --badge-avoir-text: #5D1F36;

  /* ── Typography scale ── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Fraunces', 'Inter', Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --text-2xs: 11px;
  --text-xs:  12px;
  --text-sm:  13px;
  --text-md:  15px;    /* body default */
  --text-lg:  17px;
  --text-xl:  20px;
  --text-2xl: 26px;
  --text-3xl: 34px;
  --text-4xl: 40px;
  --text-hero: 48px;

  --weight-regular: 400;
  --weight-medium:  500;
  --weight-semibold: 600;
  --weight-bold:    700;

  --lh-tight:  1.15;
  --lh-snug:   1.35;
  --lh-normal: 1.55;
  --lh-loose:  1.7;

  /* ── Spacing (8-point grid) ── */
  --space-0:  0;
  --space-1:  2px;
  --space-2:  4px;
  --space-3:  6px;
  --space-4:  8px;
  --space-5:  12px;
  --space-6:  16px;
  --space-7:  20px;
  --space-8:  24px;
  --space-9:  32px;
  --space-10: 40px;
  --space-11: 48px;
  --space-12: 64px;
  --space-13: 80px;
  --space-14: 96px;
  --space-15: 128px;

  /* ── Radius ── */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-pill: 999px;

  /* ── Shadows — dual-layer (tight rim + soft diffusion) for real depth ── */
  --shadow-xs: 0 1px 2px hsl(30 12% 10% / 0.05), 0 0 0 1px hsl(30 12% 10% / 0.02);
  --shadow-sm: 0 1px 2px hsl(30 12% 10% / 0.06), 0 2px 6px hsl(30 12% 10% / 0.04);
  --shadow-md: 0 2px 4px hsl(30 12% 10% / 0.06), 0 8px 20px hsl(30 12% 10% / 0.08);
  --shadow-lg: 0 4px 8px hsl(30 12% 10% / 0.06), 0 16px 40px hsl(30 12% 10% / 0.14);
  --shadow-xl: 0 8px 16px hsl(30 12% 10% / 0.08), 0 32px 80px hsl(30 12% 10% / 0.20);
  /* Inset top highlight — gives the classic "raised" look on cards */
  --shadow-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.6);

  /* ── Motion ── */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in:  cubic-bezier(0.4, 0, 0.6, 1);
  --ease-in-out: cubic-bezier(0.4, 0.0, 0.2, 1);
  --dur-fast: 120ms;
  --dur-med:  200ms;
  --dur-slow: 320ms;
  --transition: var(--dur-med) var(--ease-out);

  /* ── Focus ── */
  --focus-ring: 0 0 0 3px var(--primary-ring);

  /* ── Layout ── */
  --navbar-height: 52px;
  --control-panel-height: 48px;

  /* Horizontal breathing room from the viewport edge (~1 cm at desktop).
     All top-level containers align to this variable so navbar items,
     control-panel items, and page-body content all line up. */
  --page-inset-x: var(--space-9);   /* 32 px */
  --page-inset-y: var(--space-8);   /* 24 px */
  --page-max-width: 1440px;

  /* ── Backwards-compat aliases (legacy classes still reference these) ── */
  --bg-body:          var(--app-bg);
  --bg-white:         var(--surface);
  --bg-header:        var(--surface-subtle);
  --bg-hover:         var(--surface-subtle);
  --bg-selected:      var(--primary-bg);
  --bg-primary:       var(--surface);
  --bg-secondary:     var(--surface-subtle);
  --bg-muted:         var(--surface-muted);

  --border-color:     var(--border);
  --border-light:     var(--border-subtle);

  --text-primary:     var(--text-strong);
  --text-secondary:   var(--text-default);
  --text-light:       var(--text-subtle);

  --primary-light:    #8B6581;
  --primary-dark:     var(--primary-hover);
  --primary-bg-hover: #EDE4EB;

  --status-stamped-bg:   var(--success-bg);
  --status-stamped-text: var(--success-text);
  --status-missing-bg:   var(--danger-bg);
  --status-missing-text: var(--danger-text);
  --status-exempt-bg:    var(--neutral-bg);
  --status-exempt-text:  var(--neutral-text);
  --status-exam-bg:      var(--warning-bg);
  --status-exam-text:    var(--warning-text);

  --progress-high: var(--success);
  --progress-mid:  var(--warning);
  --progress-low:  var(--danger);

  --chip-bg:   var(--primary-bg);
  --chip-text: var(--primary);

  --payment-paid:    var(--success-text);
  --payment-unpaid:  var(--warning-text);
  --payment-partial: #8B6200;

  --toast-success: var(--success);
  --toast-warning: var(--warning);
  --toast-error:   var(--danger);
  --toast-info:    var(--info);

  --accent:       var(--primary);
  --accent-light: var(--primary-bg);
  --red:          var(--danger-text);
  --red-bg:       var(--danger-bg);
  --yellow:       var(--warning-text);
  --yellow-bg:    var(--warning-bg);
  --green-500:    var(--success);
  --red-500:      var(--danger);
  --blue-500:     var(--info);
  --amber-500:    var(--warning);
}

/* ── Dark theme ───────────────────────────────────────────────── */
[data-theme="dark"] {
  --app-bg:           #1C1B1A;
  --surface:          #26241F;
  --surface-subtle:   #2D2A25;
  --surface-muted:    #37332D;
  --surface-sunken:   #22201C;

  --border:           #3D3830;
  --border-strong:    #4E4840;
  --border-subtle:    #332F28;

  --text-strong:      #F2EEE5;
  --text-default:     #D9D4C8;
  --text-muted:       #A49E91;
  --text-subtle:      #7C7668;

  --primary:          #A67A98;
  --primary-hover:    #B889AB;
  --primary-active:   #C99BBE;
  --primary-bg:       #3D2F38;
  --primary-ring:     rgba(166, 122, 152, 0.25);

  --success-bg:          #1E3A2C;
  --success-bg-subtle:   #242E27;
  --success-text:        #B8E0CD;
  --danger-bg:           #3E2020;
  --danger-bg-subtle:    #2F2622;
  --danger-text:         #F1B9B9;
  --warning-bg:          #3A2C11;
  --warning-bg-subtle:   #2E2922;
  --warning-text:        #F2D6A1;
  --info-bg:             #1E3350;
  --info-bg-subtle:      #232A34;
  --info-text:           #B8D1EE;
  --neutral-bg:          #2F2D28;
  --neutral-text:        #B5B1A6;

  --badge-bl-bg:      var(--info-bg);
  --badge-bl-text:    var(--info-text);
  --badge-fac-bg:     var(--warning-bg);
  --badge-fac-text:   var(--warning-text);
  --badge-avoir-bg:   #3D2530;
  --badge-avoir-text: #E8B4C7;

  --shadow-xs: 0 1px 2px hsl(0 0% 0% / 0.3);
  --shadow-sm: 0 1px 3px hsl(0 0% 0% / 0.4);
  --shadow-md: 0 4px 12px hsl(0 0% 0% / 0.5);
  --shadow-lg: 0 12px 32px hsl(0 0% 0% / 0.6);
  --shadow-xl: 0 24px 64px hsl(0 0% 0% / 0.7);
}

/* =========== RESET =========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--text-md);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--lh-normal);
  color: var(--text-default);
  background: var(--app-bg);
  min-height: 100vh;
  font-feature-settings: "ss01", "cv11";   /* Inter's humanist numerals + single-story a */
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-strong);
  font-weight: var(--weight-semibold);
  line-height: var(--lh-snug);
  letter-spacing: -0.005em;
}

h1 { font-size: var(--text-3xl); line-height: var(--lh-tight); letter-spacing: -0.02em; }
h2 { font-size: var(--text-2xl); line-height: var(--lh-tight); letter-spacing: -0.015em; }
h3 { font-size: var(--text-xl);  letter-spacing: -0.01em; }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md);  font-weight: var(--weight-semibold); }
h6 { font-size: var(--text-sm);  font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

p { line-height: var(--lh-normal); }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid var(--app-bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

::selection { background: var(--primary-bg); color: var(--primary-active); }

/* ── App Layout ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* =========== LAYOUT — Navbar ============ */
.o-navbar {
  display: flex;
  align-items: center;
  height: var(--navbar-height);
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
  padding: 0 var(--page-inset-x);
  position: sticky;
  top: 0;
  z-index: 1000;
  flex-shrink: 0;
  box-shadow: 0 1px 0 0 rgba(255,255,255,0.06) inset, 0 1px 3px rgba(0,0,0,0.1);
}

.o-navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-right: var(--space-8);
  color: #fff;
  font-weight: var(--weight-semibold);
  font-size: var(--text-md);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.o-navbar-logo {
  width: 30px;
  height: 30px;
  background: rgba(255,255,255,0.16);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.o-navbar-nav {
  display: flex;
  align-items: center;
  list-style: none;
  gap: var(--space-1);
  flex: 1;
}

.o-navbar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  height: var(--navbar-height);
  color: rgba(255,255,255,0.72);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}

.o-navbar-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,0.06);
  text-decoration: none;
}

.o-navbar-nav a.active {
  color: #fff;
  background: rgba(255,255,255,0.10);
  border-bottom-color: rgba(255,255,255,0.9);
}

.o-navbar-nav .nav-badge {
  background: rgba(255,255,255,0.22);
  color: #fff;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  min-width: 18px;
  text-align: center;
  letter-spacing: 0.02em;
}

.o-navbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-left: auto;
}

/* Direct-child selector so dropdown <a> descendants are NOT forced to 32x32 */
.o-navbar-right > a {
  color: rgba(255,255,255,0.72);
  font-size: 16px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--dur-fast) var(--ease-out);
}

.o-navbar-right > a:hover {
  color: #fff;
  background: rgba(255,255,255,0.12);
  text-decoration: none;
}

.o-navbar-right > a.active {
  color: #fff;
  background: rgba(255,255,255,0.18);
}

.o-navbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  border: 1px solid rgba(255,255,255,0.14);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}

.o-navbar-avatar:hover {
  background: rgba(255,255,255,0.28);
  border-color: rgba(255,255,255,0.24);
  transform: translateY(-0.5px);
}

/* ── Navbar Dropdowns (user menu, company switcher) ───────── */
.company-switcher,
.user-menu {
  position: relative;
}

.company-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px var(--space-5);
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.92);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}

.company-chip:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-color: rgba(255,255,255,0.38);
}

.navbar-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  overflow: hidden;
  padding: var(--space-2) 0;
  animation: dropdown-in var(--dur-fast) var(--ease-out);
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.navbar-dropdown.show { display: block; }

.navbar-dropdown .dropdown-header {
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-2);
}

.navbar-dropdown .dropdown-header .name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-md);
  color: var(--text-strong);
}

.navbar-dropdown .dropdown-header .meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.navbar-dropdown .dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  width: 100%;
  padding: var(--space-4) var(--space-6);
  color: var(--text-default);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
  box-sizing: border-box;
}

.navbar-dropdown .dropdown-item svg {
  flex-shrink: 0;
  opacity: 0.65;
  color: var(--text-muted);
}

.navbar-dropdown .dropdown-item:hover {
  background: var(--surface-subtle);
  color: var(--text-strong);
  text-decoration: none;
}

.navbar-dropdown .dropdown-item:hover svg { opacity: 0.9; color: var(--text-default); }

.navbar-dropdown .dropdown-item.is-active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: var(--weight-medium);
}

.navbar-dropdown .dropdown-item.is-active svg { opacity: 1; color: var(--primary); }

.navbar-dropdown .dropdown-item.is-danger { color: var(--danger-text); }
.navbar-dropdown .dropdown-item.is-danger:hover { background: var(--danger-bg); color: var(--danger); }

.navbar-dropdown .dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-2) 0;
}

/* ── Control Panel ─────────────────────────────────────────── */
.o-control-panel {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-4) var(--page-inset-x);
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
  min-height: var(--control-panel-height);
  flex-wrap: wrap;
}

.o-cp-breadcrumb {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.o-cp-spacer {
  flex: 1;
}

/* ═══ Documents Toolbar (Sprint 7 redesign) ═══════════════ */
.doc-toolbar {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  gap: 0;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  flex-wrap: wrap;
}

.toolbar-row + .toolbar-row {
  border-top: 1px solid var(--border-light);
}

/* Row 1: Status pills + progress bar */
.toolbar-status-row {
  padding: 8px 16px;
  background: var(--bg-secondary);
}

.status-pills {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.status-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-white);
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-pill-btn:hover {
  border-color: var(--text-muted);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.status-pill-btn .pill-count {
  font-weight: 700;
  font-size: 12px;
  min-width: 18px;
  text-align: center;
}

.status-pill-btn.pill-missing { color: var(--status-missing-text, #B42318); border-color: rgba(180,35,24,0.3); }
.status-pill-btn.pill-stamped { color: var(--status-stamped-text, #1D6B45); border-color: rgba(29,107,69,0.3); }
.status-pill-btn.pill-exempt  { color: var(--status-exempt-text, #6B5E00); border-color: rgba(107,94,0,0.3); }

.status-pill-btn.active {
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.status-pill-btn.pill-missing.active { background: var(--status-missing-bg, #FCEBEB); border-color: var(--status-missing-text, #B42318); }
.status-pill-btn.pill-stamped.active { background: var(--status-stamped-bg, #EAF3DE); border-color: var(--status-stamped-text, #1D6B45); }
.status-pill-btn.pill-exempt.active  { background: var(--status-exempt-bg, #F1EFE8); border-color: var(--status-exempt-text, #6B5E00); }

/* Progress summary in status row */
.toolbar-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.toolbar-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.toolbar-progress-bar {
  width: 120px;
  height: 8px;
}

/* Row 2: Filter row */
.toolbar-filter-row {
  padding: 6px 16px;
}

/* Type toggles */
.type-toggles {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.type-toggle-btn {
  border: none;
  background: var(--bg-white);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
  border-right: 1px solid var(--border-color);
}

.type-toggle-btn:last-child { border-right: none; }

.type-toggle-btn:hover { background: var(--bg-hover); }

.type-toggle-btn.toggle-bl.active { background: var(--badge-bl-bg); color: #0C447C; }
.type-toggle-btn.toggle-fac.active { background: var(--badge-fac-bg); color: #633806; }
.type-toggle-btn.toggle-avoir.active { background: var(--badge-avoir-bg, #FBEAF0); color: #72243E; }

/* Toolbar separator */
.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-light);
  flex-shrink: 0;
}

/* Period dropdown */
.period-dropdown-wrap {
  position: relative;
  flex-shrink: 0;
}

.toolbar-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-secondary);
  background: var(--bg-white);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.toolbar-dropdown-btn:hover {
  border-color: var(--text-muted);
  background: var(--bg-hover);
}

.toolbar-dd-arrow {
  font-size: 10px;
  color: var(--text-muted);
}

/* Toolbar dropdown menu (shared for period + more) */
.toolbar-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 500;
  display: none;
  animation: dropdownOpen 0.15s ease;
}

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

.toolbar-dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s ease;
}

.toolbar-dd-item:hover { background: var(--bg-hover); }
.toolbar-dd-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 500; }

.toolbar-dd-section-title {
  padding: 6px 12px 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.toolbar-dd-sep {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

.toolbar-dd-action { color: var(--primary); font-weight: 500; }

/* View switcher */
.view-switcher {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: var(--bg-white);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
  border-right: 1px solid var(--border-color);
  white-space: nowrap;
}

.view-btn:last-child { border-right: none; }
.view-btn:hover { background: var(--bg-hover); }
.view-btn.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }

/* Toolbar search (simplified) */
.toolbar-search {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  background: var(--bg-white);
  position: relative;
  transition: all 0.2s ease;
}

.toolbar-search:focus-within {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.toolbar-search .search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.toolbar-search input[type="text"] {
  flex: 1;
  border: none;
  outline: none;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-primary);
  min-width: 80px;
  padding: 3px 0;
  background: transparent;
}

.toolbar-search input[type="text"]::placeholder {
  color: var(--text-light);
}

/* More button */
.toolbar-more-wrap {
  position: relative;
  flex-shrink: 0;
}

.toolbar-more-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toolbar-more-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.toolbar-more-menu {
  right: 0;
  left: auto;
  min-width: 220px;
  max-height: 400px;
  overflow-y: auto;
}

/* Context row (alerts) */
.toolbar-context-row {
  padding: 4px 16px;
  background: var(--bg-secondary);
  gap: 12px;
}

.context-alerts {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.ctx-alert {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.ctx-alert.ctx-info {
  color: var(--text-muted);
  background: transparent;
}

.ctx-alert.ctx-warn {
  color: #92400E;
  background: #FEF3C7;
  border-radius: var(--radius-sm);
}

[data-theme="dark"] .ctx-alert.ctx-warn {
  color: #FCD34D;
  background: rgba(252,211,77,0.15);
}

/* Filter Chips (in search bar) */
.o-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  transition: all 0.2s ease;
  animation: chipAppear 0.2s ease;
}

@keyframes chipAppear {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.o-chip .chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: none;
  background: none;
  color: var(--chip-text);
  cursor: pointer;
  font-size: 12px;
  border-radius: 50%;
  line-height: 1;
  opacity: 0.7;
  transition: all 0.2s ease;
}

.o-chip .chip-remove:hover {
  opacity: 1;
  background: rgba(113,75,103,0.15);
}

@keyframes dropdownOpen {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Type-ahead suggestions */
.o-search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 600;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  animation: dropdownOpen 0.2s ease;
}

.o-search-suggestions.open {
  display: block;
}

.o-search-suggestions .suggestion-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.o-search-suggestions .suggestion-item:hover {
  background: var(--bg-hover);
}

.o-search-suggestions .suggestion-category {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.o-search-suggestions .suggestion-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Pagination ────────────────────────────────────────────── */
.o-pager {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.o-pager .pager-value {
  font-weight: 600;
  color: var(--text-primary);
}

.o-pager button {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.o-pager button:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.o-pager button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── Action Bar (when rows selected) ───────────────────────── */
.o-action-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--primary-bg);
  border-bottom: 1px solid var(--primary-light);
  animation: slideDown 200ms ease;
}

.o-action-bar.visible {
  display: flex;
}

.o-action-bar .selection-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--bg-white);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--primary);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-body {
  flex: 1;
  padding: var(--page-inset-y) var(--page-inset-x);
  max-width: var(--page-max-width);
  width: 100%;
  margin: 0 auto;
}

/* Responsive inset — reduce margins on small viewports */
@media (max-width: 640px) {
  :root {
    --page-inset-x: var(--space-6);  /* 16 px */
    --page-inset-y: var(--space-6);
  }
}

/* Wider default on large monitors */
@media (min-width: 1600px) {
  :root {
    --page-inset-x: var(--space-10); /* 40 px */
  }
}

/* Documents page — full-width workspace (table extends edge to edge).
   Control-panel keeps its inset so the toolbar items still align with the
   navbar. Only the page-body under it goes flush. */
body.page-documents .page-body {
  padding: 0;
  max-width: none;
}

/* All-companies banner — shown when superadmin is in cross-tenant mode (spec 005) */
.all-companies-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--page-inset-x);
  background: var(--warning-bg-subtle);
  border-bottom: 1px solid color-mix(in srgb, var(--warning) 22%, transparent);
  color: var(--warning-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.all-companies-banner svg {
  flex-shrink: 0;
  opacity: 0.8;
}

/* ── Flash Messages ────────────────────────────────────────── */
.flash-messages {
  padding: var(--space-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.flash {
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  border: 1px solid transparent;
  animation: slideDown 200ms ease;
}

.flash-success { background: var(--success-bg); color: var(--success-text); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.flash-error   { background: var(--danger-bg);  color: var(--danger-text);  border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.flash-warning { background: var(--warning-bg); color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.flash-info    { background: var(--info-bg);    color: var(--info-text);    border-color: color-mix(in srgb, var(--info) 25%, transparent); }

/* auth-flash (login/password pages) mirrors the same palette */
.auth-flash {
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
  border: 1px solid transparent;
}
.auth-flash.error   { background: var(--danger-bg);  color: var(--danger-text);  border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.auth-flash.warning { background: var(--warning-bg); color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.auth-flash.info    { background: var(--info-bg);    color: var(--info-text);    border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.auth-flash.success { background: var(--success-bg); color: var(--success-text); border-color: color-mix(in srgb, var(--success) 25%, transparent); }

/* ── Tables ────────────────────────────────────────────────── */
.o-table-wrap {
  background: var(--bg-white);
  flex: 1;
  overflow-x: auto;
}

.o-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.o-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.o-table thead th {
  background: var(--bg-header);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
}

.o-table thead th:hover {
  color: var(--text-primary);
}

.o-table thead th.sorted {
  color: var(--primary);
  background: var(--primary-bg);
}

.o-table thead th .sort-arrow {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.6;
}

.o-table thead th.sorted .sort-arrow {
  opacity: 1;
}

.o-table thead th.th-checkbox {
  width: 36px;
  text-align: center;
}

.o-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.o-table tbody tr:nth-child(even) {
  background: rgba(0,0,0,0.015);
}

.o-table tbody tr:hover {
  background: var(--bg-hover);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.o-table tbody tr.selected {
  background: var(--bg-selected);
}

.o-table tbody tr.row-exempt {
  opacity: 0.45;
}

.o-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  line-height: 1.5;
}

.o-table tbody td.td-checkbox {
  width: 36px;
  text-align: center;
}

.o-table input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.o-table .clickable-row {
  cursor: pointer;
}

/* ── Type Badges (BL / FAC / AVOIR) ────────────────────────── */
.type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

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

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

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

/* ── Status Pills ──────────────────────────────────────────── */
/* ── Status Tags (table cells) ─────────────────────────────── */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-sizing: content-box;
}
.tag-stamped { color: var(--status-stamped-text); }
.tag-stamped .tag-dot {
  background: var(--status-stamped-text);
  box-shadow: 0 0 0 3px var(--status-stamped-bg);
}
.tag-missing { color: var(--status-missing-text); }
.tag-missing .tag-dot {
  background: transparent;
  border: 2px solid var(--status-missing-text);
  box-shadow: 0 0 0 3px var(--status-missing-bg);
  animation: pulse-dot 2s ease-in-out infinite;
}
.tag-exempt { color: var(--status-exempt-text); }
.tag-exempt .tag-dot {
  background: var(--status-exempt-text);
  box-shadow: 0 0 0 3px var(--status-exempt-bg);
  opacity: 0.5;
}

/* Auto-detected Odoo return awaiting operator confirmation —
   distinctly orange so it stands out both from missing (red) and
   exempt (grey), and pulses to draw the eye like the missing pill. */
.tag-awaiting-review {
  color: #C77800;
}
.tag-awaiting-review .tag-dot {
  background: #F59E0B;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
  animation: pulse-dot 2s ease-in-out infinite;
}

/* Inline "Confirmer" button next to the awaiting-review pill */
.btn-confirm-retour {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 3px 10px;
  border: 1px solid #F59E0B;
  background: #FFFBEB;
  color: #C77800;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn-confirm-retour:hover {
  background: #F59E0B;
  color: #fff;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.35);
}
.btn-confirm-retour .icon { flex-shrink: 0; }

/* Row-level accent for auto-detected returns awaiting review —
   replaces the .row-exempt dim with a warm left-border so the eye
   naturally walks down the column looking for them. */
.o-table tbody tr.row-awaiting-review {
  background: rgba(245, 158, 11, 0.06);
  border-left: 3px solid #F59E0B;
}
.o-table tbody tr.row-awaiting-review:hover {
  background: rgba(245, 158, 11, 0.12);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Payment Status ────────────────────────────────────────── */
.payment-status {
  font-size: 12px;
  font-weight: 500;
}

.payment-paid {
  color: var(--payment-paid);
}

.payment-unpaid {
  color: var(--payment-unpaid);
}

.payment-partial {
  color: var(--payment-partial);
}

/* ── Progress Bars ─────────────────────────────────────────── */
.o-progress {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
  flex: 1;
  min-width: 60px;
}

.o-progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 400ms ease;
}

.o-progress-bar.progress-high {
  background: var(--progress-high);
}

.o-progress-bar.progress-mid {
  background: var(--progress-mid);
}

.o-progress-bar.progress-low {
  background: var(--progress-low);
}

.progress-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-pct {
  font-size: 11px;
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

/* ── Grouped View ──────────────────────────────────────────── */
.o-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.o-group-header:hover {
  background: var(--bg-hover);
}

.o-group-header .group-arrow {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 200ms ease;
  width: 16px;
  text-align: center;
}

.o-group-header .group-arrow.expanded {
  transform: rotate(90deg);
}

.o-group-header .group-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.o-group-header .group-count {
  font-size: 12px;
  color: var(--text-muted);
}

.o-group-header .group-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  min-width: 140px;
}

.o-group-rows {
  display: none;
}

.o-group-rows.expanded {
  display: table-row-group;
}

.o-group-rows td:first-child {
  padding-left: 32px;
}

/* ── Group Cards Grid ─────────────────────────────────────── */
.group-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 0;
}

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

.group-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--progress-mid);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.group-card.gc-expanded {
  grid-column: 1 / -1;
}

/* Focus mode: when a card is expanded, hide all OTHER cards so the
   operator can work on just that month's docs without distractions.
   The "Retour aux mois" button inside the focused card restores the
   grid. Replaces the pain of "I just scanned September, where are
   the remaining non-scanned?" with a single-click drilldown. */
.group-cards-grid.focused .group-card:not(.gc-expanded) {
  display: none;
}
.group-cards-grid.focused .group-card.gc-expanded {
  animation: focusFadeIn 0.2s ease both;
}
@keyframes focusFadeIn {
  from { opacity: 0.6; }
  to   { opacity: 1; }
}

/* Retour button at the top of the focused card */
.gc-focus-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 8px;
  align-self: flex-start;
}
.gc-focus-back:hover {
  background: var(--bg-selected);
  color: var(--text-primary);
}

.group-card.gc-loading {
  opacity: 0.7;
}

.gc-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gc-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: transform 0.2s ease;
}

.gc-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gc-stats {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* SVG Progress Ring */
.progress-ring .ring-bg {
  stroke: var(--border-color);
}

.progress-ring .ring-fill {
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dasharray 0.6s ease;
}

.progress-ring .ring-text {
  font-size: 8px;
  font-weight: 700;
  fill: var(--text-primary);
}

.gc-counts {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.gc-count-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gc-count-num {
  font-weight: 600;
  color: var(--text-primary);
  min-width: 24px;
}

.gc-count-num.gc-stamped { color: var(--progress-high); }
.gc-count-num.gc-missing { color: var(--progress-low); }

/* Clickable stat rows */
.gc-filter-btn {
  cursor: pointer;
  transition: opacity 0.15s;
  user-select: none;
}
.gc-filter-btn:hover {
  opacity: 0.7;
}
.gc-show-more {
  text-align: center;
  padding: 10px;
  border-top: 1px solid var(--border-color);
}

.gc-progress-bar {
  margin-top: -4px;
}

.gc-progress-bar .o-progress {
  height: 5px;
}

/* Expandable card body */
.gc-body {
  display: none;
  border-top: 1px solid var(--border-color);
  margin: 0 -16px -16px;
  padding: 0;
  overflow: hidden;
}

.gc-body.gc-body-open {
  display: block;
  animation: gcSlideDown 0.25s ease;
}

@keyframes gcSlideDown {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 600px; }
}

.gc-body .gc-table {
  margin: 0;
  border: none;
  font-size: 12.5px;
}

.gc-body .gc-table th {
  font-size: 11px;
  padding: 8px 10px;
  background: var(--bg-header);
}

.gc-body .gc-table td {
  padding: 6px 10px;
}

.gc-body .gc-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Buttons ───────────────────────────────────────────────── */
/* ── Button system ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: 0 var(--space-6);
  height: 36px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: inherit;
  letter-spacing: -0.005em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn[disabled], .btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.08), var(--shadow-xs);
}
.btn-primary:hover    { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-primary:active   { background: var(--primary-active); border-color: var(--primary-active); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-strong);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--surface-subtle); border-color: var(--text-subtle); color: var(--text-strong); }

.btn-tertiary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-tertiary:hover  { background: var(--surface-subtle); color: var(--text-default); }

.btn-ghost {
  background: transparent;
  color: var(--text-default);
  border-color: transparent;
}
.btn-ghost:hover     { background: var(--surface-subtle); color: var(--text-strong); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.08), var(--shadow-xs);
}
.btn-danger:hover    { background: #9B2F2F; border-color: #9B2F2F; color: #fff; }

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}
.btn-danger-outline:hover { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger); }

.btn-sm { height: 28px; padding: 0 var(--space-5); font-size: var(--text-xs); }
.btn-lg { height: 44px; padding: 0 var(--space-7); font-size: var(--text-md); }

.btn-icon { padding: 0; width: 36px; height: 36px; }
.btn-icon.btn-sm { width: 28px; height: 28px; }
.btn-icon.btn-lg { width: 44px; height: 44px; }

.btn-block { width: 100%; }

/* Inline-form modifier — for forms that need to sit inline with text/adjacent items */
.inline-form { display: inline-block; }
.inline-form.ml-4 { margin-left: var(--space-4); }

/* Quick-assign extracted utility classes (used from JS in scanner_results) */
.qa-create-title { font-size: var(--text-xs); font-weight: var(--weight-semibold); margin-bottom: var(--space-2); color: var(--text-strong); }
.qa-type-select  { width: auto; padding: 4px var(--space-4); font-size: var(--text-xs); min-height: 28px; }
.qa-ref-input    { flex: 1; padding: 4px var(--space-4); font-size: var(--text-xs); min-height: 28px; }
.qa-contact-input{ padding: 4px var(--space-4); font-size: var(--text-xs); min-height: 28px; }
.qa-create-btn   { align-self: flex-start; }

.qa-result-item .badge { font-size: 10px; padding: 2px var(--space-3); height: 18px; }

/* Soft "row updated" highlight animation */
@keyframes rowFadeIn {
  from { background: var(--success-bg-subtle); }
  to   { background: transparent; }
}
.o-table tbody tr.row-updated { animation: rowFadeIn 1.2s ease-out; }

.is-assigning { opacity: 0.5; pointer-events: none; }

/* Small text-color helpers */
.text-success { color: var(--success-text); font-weight: var(--weight-medium); }
.text-danger  { color: var(--danger-text);  font-weight: var(--weight-medium); }
.text-warning { color: var(--warning-text); font-weight: var(--weight-medium); }
.text-primary-accent { color: var(--primary); font-weight: var(--weight-medium); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* Toggle switch (iOS-style, used in Settings) */
.o-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.o-switch input { opacity: 0; width: 0; height: 0; }

.o-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  transition: background var(--dur-med) var(--ease-out),
              border-color var(--dur-med) var(--ease-out);
  border-radius: var(--radius-pill);
}

.o-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--dur-med) var(--ease-out);
  box-shadow: var(--shadow-xs);
}

.o-switch input:checked + .o-slider {
  background: var(--primary);
  border-color: var(--primary);
}
.o-switch input:focus-visible + .o-slider { box-shadow: var(--focus-ring); }
.o-switch input:checked + .o-slider::before { transform: translateX(18px); }

/* ═══════════════════════════════════════════════════════════════
   PAGE: Settings
   ═══════════════════════════════════════════════════════════════ */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}

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

.settings-section { display: flex; flex-direction: column; }

/* Settings card-header: always has an icon slot */
.settings-section .card-header {
  gap: var(--space-4);
}

.settings-section .card-header-icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Storage metrics table (key/value) */
.kv-table {
  width: 100%;
  border-collapse: collapse;
}

.kv-table td {
  padding: var(--space-3) 0;
  font-size: var(--text-sm);
  vertical-align: middle;
}

.kv-table td:first-child {
  color: var(--text-muted);
  width: 45%;
}

.kv-table td:last-child {
  color: var(--text-strong);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}

.kv-table td .muted-suffix {
  color: var(--text-muted);
  font-weight: var(--weight-regular);
  margin-left: var(--space-2);
}

/* Card-body footnote (small tip/help text below content) */
.card-body-note {
  padding-top: var(--space-6);
  margin-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.card-body-note code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--surface-muted);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  color: var(--text-default);
}

/* Inline switch row (label + toggle) */
.switch-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.switch-row label + span { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-default); }

/* Settings form row — a single-line form (input + button) */
.settings-inline-form {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

.settings-inline-form .form-input { flex: 1; }

/* Tag chip (excluded companies) */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.tag-list .inline-form { margin: 0; }

.tag-list .tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px 4px 3px var(--space-5);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-default);
  transition: border-color var(--dur-fast) var(--ease-out);
}

.tag-list .tag:hover { border-color: var(--text-subtle); }

.tag-list .tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.tag-list .tag-remove:hover { background: var(--danger-bg); color: var(--danger-text); }

/* "Track from" active indicator */
.track-from-active {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
}

.track-from-active .active-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--primary);
}

/* Flex spacer — pushes following siblings to the right */
.flex-spacer { flex: 1; }

/* Modal body no-padding modifier */
.o-modal-body.flush { padding: 0; }

/* Inline progress bar width attribute-driven — for progress bars set via JS */
.progress-fill[data-width] { width: attr(data-width); }

/* card-header-icon-inline severity variants (tinted backgrounds) */
.card-header-icon-inline.info    { background: var(--info-bg);    color: var(--info-text); }
.card-header-icon-inline.danger  { background: var(--danger-bg);  color: var(--danger-text); }
.card-header-icon-inline.warning { background: var(--warning-bg); color: var(--warning-text); }
.card-header-icon-inline.success { background: var(--success-bg); color: var(--success-text); }

/* ═══════════════════════════════════════════════════════════════
   PAGE: Export
   ═══════════════════════════════════════════════════════════════ */

.export-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}
@media (max-width: 960px) { .export-grid { grid-template-columns: 1fr; } }

.export-card-header.info   { background: var(--info-bg-subtle);   color: var(--info-text);   border-bottom-color: color-mix(in srgb, var(--info) 18%, transparent); }
.export-card-header.danger { background: var(--danger-bg-subtle); color: var(--danger-text); border-bottom-color: color-mix(in srgb, var(--danger) 18%, transparent); }

/* ═══════════════════════════════════════════════════════════════
   PAGE: Admin users (refinements)
   ═══════════════════════════════════════════════════════════════ */

.form-input-multi { min-height: 78px; }

.form-group .label-spacer { visibility: hidden; height: var(--text-xs); }
.form-group-action .btn { justify-content: center; }

/* Wide form group: spans full grid width (for multi-selects / role pickers) */
.field-grid .form-group-wide { grid-column: 1 / -1; }

.form-group-count {
  margin-left: var(--space-3);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  background: var(--surface-subtle);
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  letter-spacing: 0;
  text-transform: none;
}

.user-name { font-weight: var(--weight-medium); color: var(--text-strong); }
.user-handle { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

.empty-row {
  text-align: center;
  padding: var(--space-8) !important;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ═══════════════════════════════════════════════════════════════
   Role Picker — visual radio-group of role cards
   ═══════════════════════════════════════════════════════════════ */

.role-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}

.role-option {
  position: relative;
  cursor: pointer;
  display: block;
}

.role-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.role-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
  transition: all var(--dur-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.role-card .role-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur-fast) var(--ease-out);
}

.role-card .role-name {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  letter-spacing: -0.005em;
}

.role-card .role-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--lh-snug);
}

.role-option:hover .role-card {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm), var(--shadow-highlight);
}

/* Checked state — plum tint + primary-colored icon + accent bar */
.role-option input:checked ~ .role-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--primary-bg) 100%);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm), var(--shadow-highlight),
              0 0 0 1px var(--primary) inset;
}

.role-option input:checked ~ .role-card .role-icon {
  background: var(--primary);
  color: #fff;
  transform: scale(1.05);
}

.role-option input:checked ~ .role-card .role-name {
  color: var(--primary-hover);
}

/* Subtle corner accent that appears when checked */
.role-option input:checked ~ .role-card::after {
  content: '';
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 12px 12px;
  background-position: center;
  background-repeat: no-repeat;
}

.role-option input:focus-visible ~ .role-card {
  box-shadow: var(--focus-ring);
}

/* ═══════════════════════════════════════════════════════════════
   Company Chip Picker — multi-select chips
   ═══════════════════════════════════════════════════════════════ */

.company-chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  min-height: 56px;
}

.company-chip-option {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.company-chip-option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.company-chip-option .chip-body {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-default);
  box-shadow: var(--shadow-xs);
  transition: all var(--dur-fast) var(--ease-out);
}

.company-chip-option .chip-icon {
  display: inline-flex;
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease-out);
}

.company-chip-option .chip-name {
  letter-spacing: -0.005em;
}

.company-chip-option .chip-check {
  display: inline-flex;
  color: var(--primary);
  opacity: 0;
  transform: scale(0.6) rotate(-20deg);
  transition: all var(--dur-fast) var(--ease-out);
  margin-left: calc(-1 * var(--space-2));
  width: 0;
  overflow: hidden;
}

/* Hover */
.company-chip-option:hover .chip-body {
  border-color: var(--text-subtle);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Checked */
.company-chip-option input:checked ~ .chip-body {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary-hover);
  box-shadow: var(--shadow-sm), 0 0 0 2px color-mix(in srgb, var(--primary) 12%, transparent);
}

.company-chip-option input:checked ~ .chip-body .chip-icon {
  color: var(--primary);
}

.company-chip-option input:checked ~ .chip-body .chip-check {
  opacity: 1;
  transform: scale(1) rotate(0);
  width: 14px;
  margin-left: 0;
}

.company-chip-option input:focus-visible ~ .chip-body {
  box-shadow: var(--focus-ring);
}

/* Empty-picker state: when no companies are available */
.company-chip-picker:empty::before {
  content: 'Aucune entreprise disponible. Créez-en depuis les paramètres.';
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: var(--space-5);
  text-align: center;
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════
   PAGE: Admin activity log
   ═══════════════════════════════════════════════════════════════ */

.activity-table .td-nowrap { white-space: nowrap; }
.activity-table .td-timestamp {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}
.activity-table .td-target {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.activity-table .td-ip {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ── Modals ────────────────────────────────────────────────── */
.o-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 150ms ease;
}

.o-modal-backdrop.open {
  display: flex;
}

.o-modal {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 950px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 250ms ease;
}

.o-modal.modal-sm {
  max-width: 480px;
}

.o-modal.modal-lg {
  max-width: 1100px;
}

.o-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.o-modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.o-modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 16px;
  transition: all 0.2s ease;
}

.o-modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.o-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.o-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

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

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Document Viewer Modal ─────────────────────────────────── */
.doc-viewer {
  display: flex;
  gap: 0;
  min-height: 450px;
}

.doc-viewer-preview {
  flex: 0 0 60%;
  background: #F5F5F5;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-right: 1px solid var(--border-light);
  overflow: hidden;
}

.doc-viewer-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.doc-viewer-preview .no-scan {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

.doc-viewer-preview .no-scan .no-scan-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.doc-viewer-preview .no-scan .no-scan-text {
  font-size: 14px;
}

.doc-viewer-info {
  flex: 0 0 40%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.doc-viewer-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}

.doc-viewer-section:last-child {
  border-bottom: none;
}

.doc-viewer-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.doc-viewer-field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  font-size: 13px;
}

.doc-viewer-field .field-label {
  color: var(--text-muted);
  font-size: 12px;
}

.doc-viewer-field .field-value {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
}

.doc-viewer-actions {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.doc-viewer-actions .action-row {
  display: flex;
  gap: 8px;
}

/* Page navigator */
.page-navigator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px;
  background: var(--bg-header);
  border-top: 1px solid var(--border-light);
}

.page-navigator button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.page-navigator button:hover:not(:disabled) {
  background: var(--bg-hover);
}

.page-navigator button:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-navigator .page-indicator {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Toast Notifications ───────────────────────────────────── */
.o-toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.o-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toastSlideIn 300ms ease;
  max-width: 400px;
}

.o-toast.toast-success {
  background: var(--toast-success);
}

.o-toast.toast-warning {
  background: var(--toast-warning);
}

.o-toast.toast-error {
  background: var(--toast-error);
}

.o-toast.toast-info {
  background: var(--toast-info);
}

.o-toast.toast-out {
  animation: toastSlideOut 300ms ease forwards;
}

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

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

/* Legacy toast animation aliases */
@keyframes toastIn {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

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

/* ── Empty State ───────────────────────────────────────────── */
.o-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.o-empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.o-empty-state .empty-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.o-empty-state .empty-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Week Ticker ───────────────────────────────────────────── */
.o-week-ticker {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
}

.o-week-ticker .week-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
  white-space: nowrap;
  background: var(--bg-white);
  color: var(--text-secondary);
}

.o-week-ticker .week-badge:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.o-week-ticker .week-badge.audited {
  background: var(--status-stamped-bg);
  color: var(--status-stamped-text);
  border-color: transparent;
}

.o-week-ticker .week-badge.pending {
  background: var(--badge-fac-bg);
  color: var(--badge-fac-text);
  border-color: transparent;
}

.o-week-ticker .week-badge.future {
  opacity: 0.5;
}

/* ── Forms ─────────────────────────────────────────────────── */
.o-form-group {
  margin-bottom: 14px;
}

.o-form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.o-form-group input,
.o-form-group select,
.o-form-group textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-white);
  transition: all 0.2s ease;
}

.o-form-group input:focus,
.o-form-group select:focus,
.o-form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

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

/* ── Upload Area (Scanner / Import) ────────────────────────── */
.o-upload-area {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.o-upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
  animation: uploadPulse 2s ease infinite;
}

@keyframes uploadPulse {
  0%, 100% { background: var(--primary-bg); }
  50% { background: #F0E8EE; }
}

.o-upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-bg);
  transform: scale(1.01);
  border-width: 2px;
}

.o-upload-area .upload-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.o-upload-area .upload-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.o-upload-area .upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Cards (Queue) ─────────────────────────────────────────── */
.o-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px;
}

.o-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: all 0.2s ease;
}

.o-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.o-card-thumb {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--bg-header);
  display: block;
}

.o-card-body {
  padding: 20px;
}

.o-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.o-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.o-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.o-card-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-light);
}

/* ── Settings page ─────────────────────────────────────────── */
.o-settings-section {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.o-settings-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  font-weight: 600;
}

.o-settings-body {
  padding: 20px;
}

/* ── Lightbox ──────────────────────────────────────────────── */
.o-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.o-lightbox.open {
  display: flex;
}

.o-lightbox img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
}

/* ── Utility ───────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fs-11 { font-size: 11px; }
.fs-12 { font-size: 13px; }
.fs-13 { font-size: 13px; }
.fs-14 { font-size: 14px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.d-flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-100 { width: 100%; }

/* Page wrapper for sub-pages (import, scanner, settings, export).
   Parent .page-body already provides the horizontal viewport inset +
   overall max-width. This wrapper only constrains width for form-style
   pages that shouldn't stretch as wide as tables. */
.o-page-wrap {
  max-width: 1100px;
  margin: 0 auto;
}

.o-page-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* Table inside settings / import history */
.o-simple-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.o-simple-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.o-simple-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.o-simple-table tr:hover td {
  background: var(--bg-hover);
}

/* ── Scan History (Scanner page) ───────────────────────────── */
.scan-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.scan-history-item:last-child {
  border-bottom: none;
}

/* Processing progress bar */
.o-scan-progress {
  width: 100%;
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.o-scan-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 300ms ease;
}

/* ── Loading Skeletons ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-row { height: 44px; margin-bottom: 4px; }
.skeleton-card { height: 80px; }
.skeleton-text { height: 14px; width: 60%; margin-bottom: 8px; }

/* ── Empty States (new generic) ────────────────────────────── */
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #555;
}

.empty-state-desc {
  font-size: 13px;
}

/* ── Suggestion Banner (Queue) ─────────────────────────────── */
.suggestion-banner {
  background: #FFF8E1;
  border: 1px solid #FFE082;
  border-left: 4px solid #FFA000;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.suggestion-banner-text {
  font-size: 13px;
  color: #5D4037;
}

.suggestion-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Focus States (global) ─────────────────────────────────── */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ============================================
   LEGACY COMPAT ALIASES — Sprint 4A Stabilizer
   Temporary bridge for old template class names.
   Remove after full migration to o-* classes.
   ============================================ */

/* ── 3A: Shared aliases ────────────────────────────────────── */
/* ── Card — raised surface with inset highlight (premium "lifted" feel) ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);   /* softer border */
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm), var(--shadow-highlight);
  transition: box-shadow var(--dur-med) var(--ease-out),
              border-color var(--dur-med) var(--ease-out),
              transform var(--dur-med) var(--ease-out);
}

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

.card.card-compact { border-radius: var(--radius-md); }

.card.card-feature {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-subtle) 100%);
  border-color: var(--border-strong);
}

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

.card-header {
  padding: var(--space-6) var(--space-8);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
  letter-spacing: -0.01em;
  line-height: var(--lh-snug);
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.card-header .card-subtitle {
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
  margin-top: var(--space-3);
  letter-spacing: 0;
}

/* Optional leading icon for card headers */
.card-header .card-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text-muted);
  margin-right: var(--space-4);
  flex-shrink: 0;
}

.card-header.with-icon {
  display: flex;
  align-items: center;
}

.card-body {
  padding: var(--space-8);
}

.card-compact .card-body { padding: var(--space-6); }
.card-compact .card-header { padding: var(--space-5) var(--space-6); }

.card-footer {
  padding: var(--space-5) var(--space-8);
  background: var(--surface-subtle);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-4);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.status-green, .status-badge.status-green {
  background: var(--status-stamped-bg);
  color: var(--status-stamped-text);
}

.status-red, .status-badge.status-red {
  background: var(--status-missing-bg);
  color: var(--status-missing-text);
}

.status-yellow, .status-badge.status-yellow {
  background: var(--badge-fac-bg);
  color: var(--badge-fac-text);
}

.status-grey, .status-badge.status-grey {
  background: var(--status-exempt-bg);
  color: var(--status-exempt-text);
}

.type-transfer {
  background: var(--badge-bl-bg);
  color: var(--badge-bl-text);
}

.type-invoice {
  background: var(--badge-fac-bg);
  color: var(--badge-fac-text);
}

.btn-success {
  background: var(--progress-high);
  color: #fff;
  border-color: var(--progress-high);
}

.btn-success:hover {
  background: #178A65;
  border-color: #178A65;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-outline:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── Form inputs ── */
.form-input {
  width: 100%;
  padding: 8px var(--space-5);
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--text-strong);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.form-input::placeholder { color: var(--text-subtle); }

.form-input:hover:not(:focus):not(:disabled) { border-color: var(--text-subtle); }

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.form-input:disabled {
  background: var(--surface-muted);
  color: var(--text-subtle);
  cursor: not-allowed;
}

.form-input[type="checkbox"], .form-input[type="radio"] {
  width: auto;
  min-height: 0;
}

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

select.form-input {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236E6860' 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;
  padding-right: 32px;
  appearance: none;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.doc-ref {
  font-family: 'Consolas', 'SF Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #8C8C8C;
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: #555;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  color: #8C8C8C;
  margin-bottom: 16px;
}

/* ── 3B: Scanner aliases ───────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
  animation: uploadPulse 2s ease infinite;
}

.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-bg);
  transform: scale(1.01);
}

.upload-zone .upload-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.upload-zone .upload-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.upload-zone .upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Import Format Guide ── */
.import-format-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}
@media (max-width: 900px) {
  .import-format-grid {
    grid-template-columns: 1fr;
  }
}
.import-format-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--bg-card);
}
.import-format-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.import-format-source {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding: 4px 8px;
  background: var(--bg-subtle, rgba(0,0,0,0.03));
  border-radius: var(--radius-sm);
  font-style: italic;
}
.import-format-table {
  width: 100%;
  font-size: 0.82rem;
  border-collapse: collapse;
}
.import-format-table th {
  text-align: left;
  padding: 5px 8px;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}
.import-format-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-light, var(--border));
}
.import-format-table code {
  font-size: 0.82rem;
  background: var(--bg-subtle, rgba(113,75,103,0.08));
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--primary);
  font-weight: 500;
}

.scanner-phases {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scanner-phase {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.scanner-phase.active {
  color: var(--primary);
  background: var(--primary-bg);
  border-color: var(--primary);
  font-weight: 600;
}

.scanner-phase.completed {
  color: var(--status-stamped-text);
  background: var(--status-stamped-bg);
  border-color: transparent;
}

.phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-color);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.scanner-phase.active .phase-dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(113, 75, 103, 0.2);
  animation: phasePulse 1.5s ease-in-out infinite;
}

@keyframes phasePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(113, 75, 103, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(113, 75, 103, 0.1); }
}

.scanner-phase.completed .phase-dot {
  background: var(--status-stamped-text);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 300ms ease;
}

/* ── 3C: Import / Export aliases ────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

.export-columns-list {
  list-style: disc;
  padding-left: 20px;
  font-size: 12px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.export-columns-list strong {
  color: var(--text-primary);
}

/* ── 3D: Queue aliases ─────────────────────────────────────── */
.queue-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.queue-item:last-child {
  border-bottom: none;
}

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

.queue-item-thumb {
  flex-shrink: 0;
  width: 120px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
  cursor: pointer;
}

.queue-item-thumb img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.queue-item-thumb-lg {
  flex-shrink: 0;
  width: 200px;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
  cursor: pointer;
}

.queue-item-thumb-lg img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.queue-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.queue-item-info {
  flex: 1;
  min-width: 0;
}

.queue-search-box {
  position: relative;
}

.queue-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  animation: dropdownOpen 0.2s ease;
}

.queue-search-results.open {
  display: block;
}

.queue-search-item {
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.queue-search-item:hover {
  background: var(--bg-hover);
}

.queue-search-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.queue-ocr-dump {
  font-family: 'Consolas', 'SF Mono', monospace;
  font-size: 11px;
  background: var(--bg-header);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
}

.continuation-group {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  background: #FFFDF5;
  border-left: 3px solid #FFE082;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.continuation-group:last-child {
  border-bottom: none;
}

.continuation-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.continuation-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cont-thumb-item {
  position: relative;
  width: 80px;
  text-align: center;
}

.cont-thumb-item img {
  width: 80px;
  height: 100px;
  object-fit: contain;
  background: #f5f5f5;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cont-thumb-item img:hover {
  border-color: var(--primary);
}

.cont-thumb-item input[type="checkbox"] {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
}

.cont-thumb-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
}

.zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.zoom-overlay img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
}

/* Legacy queue toast (CSS-only compat) */
.app-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-md);
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease, transform 300ms ease, visibility 300ms ease;
  background: var(--toast-success);
}

.app-toast.toast-error {
  background: var(--toast-error);
}

.app-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ── 3E: Settings aliases ──────────────────────────────────── */
.settings-section {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.settings-section .card-header {
  background: var(--bg-header);
}

/* ── 3F: Utility aliases ───────────────────────────────────── */
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.w-full { width: 100%; }
.mb-24 { margin-bottom: 24px; }
.mt-24 { margin-top: 24px; }
.text-sm { font-size: 13px; }

/* ── End Legacy Compat ─────────────────────────────────────── */

/* ── 4A: Sprint 4B Product CSS ─────────────────────────────── */
/* Scanner Results Redesign */
.scan-summary-strip {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}
.scan-metric-card {
  flex: 1;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: all 0.2s ease;
}
.scan-metric-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.scan-metric-card.stat-matched { border-top: 3px solid var(--status-stamped-bg); }
.scan-metric-card.stat-continuation { border-top: 3px solid var(--status-exam-bg); }
.scan-metric-card.stat-pending { border-top: 3px solid var(--status-missing-bg); }
.scan-metric-card.stat-unidentified { border-top: 3px solid var(--red-bg); }

.scan-metric-val {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-dark);
}
.scan-metric-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* Settings Restyling */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Queue Card Layout */
.q-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 20px;
}
@media (max-width: 900px) {
  .q-card-grid { grid-template-columns: 1fr; }
}
.q-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: all 0.2s ease;
}
.q-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}
.q-card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.q-card-thumb {
  width: 100px;
  height: 140px;
  object-fit: cover;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.q-card-thumb:hover {
  transform: scale(1.03);
}
.q-card-body {
  padding: 14px 16px;
  flex: 1;
}
.q-card-body .form-input {
  font-size: 13px;
  padding: 8px 12px;
}
.q-card-actions {
  display: flex;
  border-top: 1px solid var(--border-light);
  background: #fafafa;
}
.q-card-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  border-right: 1px solid var(--border-light);
  transition: all 0.2s ease;
}
.q-card-btn:last-child { border-right: none; }
.q-card-btn:hover { background: #f0f0f0; }

/* ── OCR Text Panel (structured) ── */
.ocr-panel {
  margin-top: 10px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  overflow: hidden;
  font-size: 12px;
}
.ocr-panel-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-hover, #f8f8f8);
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
  font-size: 12px;
  border: none;
  width: 100%;
  text-align: left;
}
.ocr-panel-toggle:hover { background: var(--bg-secondary, #f0f0f0); }
.ocr-panel-toggle .ocr-arrow {
  transition: transform 0.2s;
  font-size: 10px;
}
.ocr-panel-toggle.open .ocr-arrow { transform: rotate(90deg); }
.ocr-panel-body {
  display: none;
  padding: 10px;
  background: #fafafa;
  border-top: 1px solid var(--border-light);
}
.ocr-panel-body.open { display: block; }
.ocr-refs-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin-bottom: 8px;
}
.ocr-refs-grid .ocr-label {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 0;
}
.ocr-refs-grid .ocr-value {
  font-size: 12px;
  padding: 2px 0;
}
.ocr-raw-text {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 11px;
  background: #fff;
  border: 1px solid var(--border-light);
  padding: 8px;
  border-radius: 4px;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  color: var(--text-secondary);
}
.ocr-raw-text .ocr-highlight {
  background: rgba(113,75,103,0.15);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
  color: var(--primary);
}

/* ── Search Results Dropdown (bigger) ── */
.queue-search-results {
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  border: 1px solid var(--border) !important;
  max-height: 280px !important;
}
.queue-search-results .search-result-item {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s;
}
.queue-search-results .search-result-item:hover {
  background: var(--bg-hover, #f5f5f5);
}
.queue-search-results .search-result-item .sr-ref {
  font-weight: 600;
  font-size: 13px;
}
.queue-search-results .search-result-item .sr-contact {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-search-results .search-result-item .sr-status {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
}

.q-dissolve-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.q-dissolve-btn:hover {
  background: var(--bg-hover);
}

.table-hover-row:hover {
  background: var(--bg-hover);
}

/* Search Suggestions */
#searchSuggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
  display: none;
  animation: dropdownOpen 0.2s ease;
}
#searchSuggestions.open {
  display: block;
}
.suggestion-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}
.suggestion-item:last-child {
  border-bottom: none;
}
.suggestion-item:hover {
  background: var(--bg-hover);
}
.suggestion-category {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
}
.suggestion-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark);
}

/* ── Sprint 5 Overhaul: Transitions & Animations ─────────── */

/* Page entrance animation */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-body > * {
  animation: fadeSlideIn 0.3s ease both;
}

.page-body > *:nth-child(1) { animation-delay: 0ms; }
.page-body > *:nth-child(2) { animation-delay: 40ms; }
.page-body > *:nth-child(3) { animation-delay: 80ms; }
.page-body > *:nth-child(4) { animation-delay: 120ms; }

/* Table row stagger animation */
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.o-table tbody tr {
  animation: rowFadeIn 0.25s ease both;
}

/* Modal entrance — scale from 0.96 */
.o-modal-content {
  animation: modalScaleIn 0.2s ease both;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* Card hover lift */
.metric-card,
.scan-metric-card,
.q-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Button loading state */
.btn.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.75;
  color: transparent !important;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
}

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

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

.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
  vertical-align: -2px;
}

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

/* Filter change fade */
.o-table-wrap.refreshing {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.o-table-wrap.refreshed {
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* Search hint badge */
.search-hint {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-header);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  margin-left: 8px;
  font-family: monospace;
}

/* Additional utility classes */
.text-center { text-align: center; }
.p-16 { padding: 16px; }
.p-48 { padding: 48px; }
.border-left-accent { border-left: 3px solid var(--primary); }
.bg-hover:hover { background: var(--bg-hover); }

/* Confidence bar for queue continuation cards */
.confidence-bar {
  height: 3px;
  border-radius: 2px;
  margin-top: 6px;
}

.confidence-high { background: var(--progress-high); }
.confidence-medium { background: var(--progress-mid); }
.confidence-low { background: var(--progress-low); }

/* Card fade-out animation for queue actions */
@keyframes cardFadeOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.95); }
}

.card-removing {
  animation: cardFadeOut 0.3s ease forwards;
}

/* ── Responsive: Documents Toolbar ─────────────────────────── */
@media (max-width: 900px) {
  .toolbar-filter-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  .toolbar-sep { display: none; }
  .toolbar-search { min-width: 140px; order: 10; }
  .o-pager { order: 11; }
  .status-pills { flex-wrap: wrap; }
  .toolbar-progress { margin-left: 0; width: 100%; margin-top: 4px; }
  .pill-label { display: none; }
  .status-pill-btn { padding: 4px 8px; }
}

/* ── Print Stylesheet ──────────────────────────────────────── */
@media print {
  .o-navbar,
  .o-control-panel,
  .o-action-bar,
  .o-toast-container,
  .o-pager,
  .o-week-ticker,
  .flash-messages,
  .o-searchbar,
  .btn,
  input[type="checkbox"] {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  .o-table {
    font-size: 10pt;
  }

  .o-table thead th {
    background: #f0f0f0 !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .o-table tbody tr {
    page-break-inside: avoid;
  }

  .type-badge,
  .status-tag {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .main-content {
    padding: 0;
  }

  .o-table-wrap {
    overflow: visible;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Dark Mode
   ═══════════════════════════════════════════════════════════════ */
/* ── Dashboard Layout ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-blue .stat-value { color: var(--primary); }
.stat-green .stat-value { color: #16a34a; }
.stat-red .stat-value { color: #ef4444; }
.stat-yellow .stat-value { color: #d97706; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.mb-24 { margin-bottom: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 8px; }

.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }

.text-sm { font-size: 13px; }
.text-muted { color: var(--text-muted); }
.fw-600 { font-weight: 600; }

.queue-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}

.queue-summary-item {
  display: block;
  text-decoration: none;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.queue-summary-item:hover {
  background: var(--bg-hover);
}

.qs-count {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.qs-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.text-yellow { color: #d97706; }
.text-blue { color: var(--primary); }
.text-red { color: #ef4444; }

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.15s;
}

.quick-action-btn:hover {
  background: var(--bg-hover);
}

.qa-icon {
  color: var(--primary);
}

.qa-label {
  font-size: 11px;
  font-weight: 500;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-header);
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.progress-bar {
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.type-badge.type-transfer {
  background: var(--badge-bl-bg, #dbeafe);
  color: var(--badge-bl-text, #1d4ed8);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.type-badge.type-invoice {
  background: var(--badge-fac-bg, #fef3c7);
  color: var(--badge-fac-text, #92400e);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* Dark mode dashboard overrides */
[data-theme="dark"] .stat-card {
  background: var(--bg-white);
  border-color: var(--border-color);
}

[data-theme="dark"] .data-table th { background: var(--bg-header); }
[data-theme="dark"] .data-table td { border-color: var(--border-color); }

/* ── Dashboard: Urgency Badges ────────────────────────────── */
.urgency-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.urgency-red {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

.urgency-amber {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fcd34d;
}

.urgency-ok {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #86efac;
}

/* ── Dashboard: Weekly Summary ────────────────────────────── */
.weekly-summary {
  display: flex;
  gap: 16px;
  justify-content: space-around;
}

.ws-item {
  text-align: center;
}

.ws-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.ws-value.ws-green { color: var(--progress-high); }
.ws-value.ws-amber { color: #d97706; }

.ws-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Dashboard: Quick Links ──────────────────────────────── */
.dash-quick-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-qlink {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.15s;
}

.dash-qlink:hover {
  background: var(--bg-hover);
}

.dash-qlink svg {
  flex-shrink: 0;
  color: var(--primary);
}

.dql-title {
  font-size: 13px;
  font-weight: 600;
}

.dql-desc {
  font-size: 11px;
  color: var(--text-muted);
}

[data-theme="dark"] {
  /* Primary — slightly lighter for dark bg contrast */
  --primary: #9B7491;
  --primary-light: #B08FA8;
  --primary-dark: #7D5F74;
  --primary-bg: #2A2035;
  --primary-bg-hover: #352840;

  /* Backgrounds */
  --bg-body: #1A1A2E;
  --bg-white: #16213E;
  --bg-header: #1A2744;
  --bg-hover: #1E2A4A;
  --bg-selected: #2A2035;

  /* Borders */
  --border-color: #2E3A5C;
  --border-light: #253050;

  /* Text */
  --text-primary: #E0E0E0;
  --text-secondary: #B0B8C8;
  --text-muted: #7889A8;
  --text-light: #5A6A88;

  /* Type badges */
  --badge-bl-bg: #1A2F4A;
  --badge-bl-text: #6BA3D6;
  --badge-fac-bg: #2E2516;
  --badge-fac-text: #D4A95A;
  --badge-avoir-bg: #2E1A24;
  --badge-avoir-text: #D48AA0;

  /* Status pills */
  --status-stamped-bg: #1A2E16;
  --status-stamped-text: #6DBF4A;
  --status-missing-bg: #2E1616;
  --status-missing-text: #E06060;
  --status-exempt-bg: #252420;
  --status-exempt-text: #A0A09A;
  --status-exam-bg: #2E2010;
  --status-exam-text: #F0A030;

  /* Progress bars */
  --progress-high: #2CB88A;
  --progress-mid: #D4952A;
  --progress-low: #E86060;

  /* Filter chips */
  --chip-bg: #2A2035;
  --chip-text: #B08FA8;

  /* Payment status */
  --payment-paid: #6DBF4A;
  --payment-unpaid: #D4952A;
  --payment-partial: #C4A020;

  /* Shadows — stronger for dark bg */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);

  /* Toast */
  --toast-success: #2CB88A;
  --toast-warning: #D4952A;
  --toast-error: #E86060;
  --toast-info: #5B9BF6;

  /* Focus ring */
  --focus-ring: 0 0 0 3px rgba(155,116,145,0.3);

  /* Legacy aliases */
  --accent: var(--primary);
  --accent-light: var(--primary-bg);
  --red: var(--status-missing-text);
  --red-bg: var(--status-missing-bg);
  --yellow: var(--badge-fac-text);
  --yellow-bg: var(--badge-fac-bg);
}

/* Dark mode overrides for elements that use hardcoded colors */
[data-theme="dark"] .o-navbar {
  background: #0F1528;
  border-bottom-color: #2E3A5C;
}

[data-theme="dark"] .o-navbar-brand {
  color: #E0E0E0;
}

[data-theme="dark"] .o-navbar-nav a {
  color: #B0B8C8;
}

[data-theme="dark"] .o-navbar-nav a:hover,
[data-theme="dark"] .o-navbar-nav a.active {
  color: #E0E0E0;
}

[data-theme="dark"] .card {
  background: var(--bg-white);
  border-color: var(--border-color);
}

[data-theme="dark"] .card-header {
  background: var(--bg-header);
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .o-table thead th {
  background: var(--bg-header);
  color: var(--text-secondary);
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .o-table tbody td {
  border-bottom-color: var(--border-light);
}

[data-theme="dark"] .o-table tbody tr:hover {
  background: var(--bg-hover);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #1A2744;
  color: var(--text-primary);
  border-color: var(--border-color);
}

[data-theme="dark"] .btn-outline {
  color: var(--text-secondary);
  border-color: var(--border-color);
}

[data-theme="dark"] .btn-outline:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

[data-theme="dark"] ::-webkit-scrollbar-track { background: #1A1A2E; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3A4A6A; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4A5A7A; }

[data-theme="dark"] .flash { background: var(--bg-header); color: var(--text-primary); }

[data-theme="dark"] .zoom-overlay,
[data-theme="dark"] .o-lightbox {
  background: rgba(0,0,0,0.85);
}

[data-theme="dark"] .group-card { box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
[data-theme="dark"] .group-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
[data-theme="dark"] .gc-body { border-top-color: var(--border-color); }

/* ── Hierarchy Breadcrumb ─────────────────────────────────── */
.hierarchy-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 13px;
  flex-wrap: wrap;
}

.hbc-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.hbc-clickable {
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
  transition: color 0.15s;
}

.hbc-clickable:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.hbc-current {
  font-weight: 600;
  color: var(--text-primary);
}

.hbc-sep {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
}

.hbc-exit {
  margin-left: auto;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.hbc-exit:hover {
  color: var(--progress-low);
  background: rgba(239,68,68,0.1);
}

.o-chip-hierarchy {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary);
}

/* Hierarchy slide animations */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Skeleton for loading cards */
.gc-skeleton {
  opacity: 0.5;
  pointer-events: none;
}

.skeleton-block {
  background: var(--border-color);
  border-radius: var(--radius-sm);
  animation: skeletonPulse 1.2s ease infinite;
}

@keyframes skeletonPulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.8; }
}

/* Dark mode: urgency + dashboard */
[data-theme="dark"] .urgency-red { background: #3a1c1c; color: #f87171; border-color: #7f1d1d; }
[data-theme="dark"] .urgency-amber { background: #3a2d1c; color: #fbbf24; border-color: #78350f; }
[data-theme="dark"] .urgency-ok { background: #1a2e1a; color: #4ade80; border-color: #14532d; }
[data-theme="dark"] .dash-qlink:hover { background: var(--bg-hover); }

/* ── QuickAssign Dropdown (scanner results) ── */
.qa-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 999;
}
.qa-container {
  position: fixed;
  z-index: 1000;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  width: 380px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.qa-input-wrap {
  padding: 10px;
  border-bottom: 1px solid var(--border-light);
}
.qa-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  outline: none;
}
.qa-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(113,75,103,0.15);
}
.qa-results {
  overflow-y: auto;
  max-height: 320px;
}
.qa-result-item {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.15s;
}
.qa-result-item:hover {
  background: var(--bg-hover, #f5f5f5);
}
.qa-result-ref {
  font-weight: 600;
  font-size: 13px;
  color: var(--primary);
  font-family: 'Consolas', monospace;
}
.qa-result-contact {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qa-result-status {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
}
.qa-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.qa-hint {
  padding: 12px;
  background: #FFF8E1;
  border-bottom: 1px solid #FFE082;
  font-size: 12px;
  color: #795548;
  line-height: 1.5;
}
.qa-create-form {
  padding: 12px;
  background: #fafafa;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.qa-create-form .qa-create-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ═══════════════════════════════════════════════════════════════
   Eyebrow — shared small-caps categorization label
   ═══════════════════════════════════════════════════════════════ */

.eyebrow {
  display: inline-block;
  font-size: var(--text-xs);       /* bumped from 11 → 12 for presence */
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
}

/* ═══════════════════════════════════════════════════════════════
   Page header + form group + field grid (spec 002 refinements)
   ═══════════════════════════════════════════════════════════════ */

.page-header {
  margin-bottom: var(--space-8);
}

.page-header h2 {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  letter-spacing: -0.015em;
}

.page-header h2 svg { opacity: 0.6; color: var(--text-muted); }

.page-header .subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.page-header.with-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
}

/* Form group used across admin + auth forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.form-group label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-default);
  letter-spacing: 0.01em;
}

.form-group .form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-6);
  align-items: end;
}

/* ═══════════════════════════════════════════════════════════════
   Badge (unified — replaces role-badge, action-badge, type-badge)
   ═══════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px var(--space-4);
  height: 20px;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  letter-spacing: 0.01em;
  background: var(--neutral-bg);
  color: var(--neutral-text);
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-info    { background: var(--info-bg);    color: var(--info-text); }
.badge-primary { background: var(--primary-bg); color: var(--primary); }

.badge-lg { height: 24px; padding: 3px var(--space-5); font-size: var(--text-xs); }

/* Legacy wrapper classes — keep role-badge / action-badge selectors working */
.role-badge, .action-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px var(--space-4);
  height: 20px;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.role-badge.role-superadmin    { background: var(--warning-bg); color: var(--warning-text); }
.role-badge.role-company_admin { background: var(--info-bg);    color: var(--info-text); }
.role-badge.role-scanner       { background: var(--success-bg); color: var(--success-text); }
.role-badge.role-viewer        { background: var(--neutral-bg); color: var(--neutral-text); }

.action-badge.action-login     { background: var(--info-bg);    color: var(--info-text); }
.action-badge.action-create,
.action-badge.action-import    { background: var(--success-bg); color: var(--success-text); }
.action-badge.action-delete,
.action-badge.action-failed    { background: var(--danger-bg);  color: var(--danger-text); }
.action-badge.action-other     { background: var(--neutral-bg); color: var(--neutral-text); }

/* Status dot for user active/inactive */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.status-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.status-dot.is-active   { color: var(--success); }
.status-dot.is-inactive { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════
   Empty state + Skeleton
   ═══════════════════════════════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-8);
  color: var(--text-muted);
}

.empty-state .empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-6);
}

.empty-state .empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  letter-spacing: -0.005em;
  margin-bottom: var(--space-3);
}

.empty-state .empty-state-description {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--lh-normal);
  max-width: 380px;
  margin-bottom: var(--space-6);
}

.empty-state .empty-state-actions {
  display: flex;
  gap: var(--space-4);
}

.empty-state.compact {
  padding: var(--space-9) var(--space-6);
}
.empty-state.compact .empty-state-icon { width: 44px; height: 44px; margin-bottom: var(--space-5); }
.empty-state.compact .empty-state-title { font-size: var(--text-md); }

/* Skeleton loaders */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.8; }
}

.skeleton,
.skeleton-line,
.skeleton-row,
.skeleton-card {
  background: linear-gradient(90deg, var(--surface-muted) 0%, var(--surface-subtle) 50%, var(--surface-muted) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-line   { height: 14px; margin: var(--space-3) 0; width: 100%; }
.skeleton-line.w-half   { width: 50%; }
.skeleton-line.w-third  { width: 33%; }
.skeleton-line.w-quarter{ width: 25%; }
.skeleton-row    { height: 48px; margin: var(--space-2) 0; }
.skeleton-card   { height: 120px; border-radius: var(--radius-lg); }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-8);
}

.pagination .page-info {
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: 0 var(--space-4);
}

/* ═══════════════════════════════════════════════════════════════
   Auth pages (login / change password) — standalone
   ═══════════════════════════════════════════════════════════════ */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, color-mix(in srgb, var(--primary-bg) 50%, transparent) 0%, transparent 50%),
    var(--app-bg);
  padding: var(--space-7);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-10) var(--space-9);
}

.auth-brand {
  text-align: center;
  margin-bottom: var(--space-9);
}

.auth-brand .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: var(--text-xl);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.auth-brand h1 {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  letter-spacing: -0.015em;
}

.auth-brand p {
  margin: var(--space-3) 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.auth-form .form-input {
  padding: 10px var(--space-5);
  font-size: var(--text-md);
  min-height: 44px;
}

.auth-form .btn {
  justify-content: center;
  padding: 11px 14px;
  font-size: 14px;
}

/* auth-flash moved to the Flash Messages section above */

/* ═══════════════════════════════════════════════════════════════
   PAGE: Dashboard (spec 002 — v2, denser + more balanced)
   ═══════════════════════════════════════════════════════════════ */

/* ── Hero strip: full-width, compact, inline stats ── */
.dash-hero {
  position: relative;
  background: linear-gradient(145deg, var(--surface) 0%, var(--surface-subtle) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-9);
  margin-bottom: var(--space-7);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-8);
  align-items: center;
}

.dash-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--primary) 10%, transparent) 0%, transparent 50%),
    radial-gradient(circle at 0% 100%, color-mix(in srgb, var(--warning) 6%, transparent) 0%, transparent 40%);
  pointer-events: none;
}

.dash-hero > * { position: relative; }

.dash-hero-content { min-width: 0; }

.dash-hero-eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: var(--space-3);
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.dash-hero-eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 20%, transparent);
}

.dash-hero.is-complete .dash-hero-eyebrow::before { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent); }

.dash-hero-number {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: 64px;
  line-height: 1;
  color: var(--text-strong);
  letter-spacing: -0.03em;
  font-feature-settings: "lnum" 1;
  margin-bottom: var(--space-5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-hero-number .unit {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
  margin-left: var(--space-4);
  letter-spacing: 0;
}

.dash-hero-inline-stats {
  display: flex;
  gap: var(--space-7);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.dash-hero-inline-stats .hero-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-hero-inline-stats .hero-stat .value {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  font-feature-settings: "lnum" 1;
  letter-spacing: -0.005em;
}

.dash-hero-inline-stats .hero-stat .label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.dash-hero-inline-stats .hero-stat.success .value { color: var(--success-text); }
.dash-hero-inline-stats .hero-stat.danger  .value { color: var(--danger-text); }

.dash-progress-xl {
  height: 8px;
  background: color-mix(in srgb, var(--border-strong) 40%, transparent);
  border-radius: var(--radius-pill);
  overflow: hidden;
  max-width: 640px;
}

.dash-progress-xl > .dash-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success) 0%, color-mix(in srgb, var(--success) 80%, var(--primary) 20%) 100%);
  border-radius: inherit;
  transition: width 400ms var(--ease-out);
}

/* Hero right-hand action panel */
.dash-hero-cta {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: stretch;
  min-width: 200px;
}

.dash-hero-cta .btn { justify-content: flex-start; }

@media (max-width: 860px) {
  .dash-hero { grid-template-columns: 1fr; }
  .dash-hero-number { font-size: 48px; }
}

/* ── KPI row: horizontal strip of 3-4 compact cards ── */
.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-9);
}

@media (max-width: 860px) { .dash-kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .dash-kpi-row { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-5);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.kpi-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}

.kpi-card .kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--surface-subtle);
  color: var(--text-muted);
}

.kpi-card.accent-success .kpi-icon { background: var(--success-bg); color: var(--success-text); }
.kpi-card.accent-warning .kpi-icon { background: var(--warning-bg); color: var(--warning-text); }
.kpi-card.accent-danger  .kpi-icon { background: var(--danger-bg);  color: var(--danger-text); }
.kpi-card.accent-info    .kpi-icon { background: var(--info-bg);    color: var(--info-text); }
.kpi-card.accent-primary .kpi-icon { background: var(--primary-bg); color: var(--primary); }

.kpi-card .kpi-content { min-width: 0; flex: 1; }
.kpi-card .kpi-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  font-feature-settings: "lnum" 1;
}
.kpi-card .kpi-label {
  font-size: var(--text-sm);
  color: var(--text-default);
  font-weight: var(--weight-medium);
  margin-top: 2px;
}
.kpi-card .kpi-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-card .kpi-trend {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text-muted);
}

/* ── Sections + headers ── */
.dash-section { margin-bottom: var(--space-9); }

.dash-section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.dash-section-header h3 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  letter-spacing: -0.015em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Accent bar anchoring the section title */
.dash-section-header h3::before {
  content: '';
  width: 3px;
  height: 20px;
  background: var(--primary);
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.dash-section-header .dash-section-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-3);
  /* Indent to align with title (past the accent bar) */
  padding-left: calc(3px + var(--space-4));
}

.dash-section-header .dash-section-link {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: var(--weight-medium);
  flex-shrink: 0;
}
.dash-section-header .dash-section-link:hover { color: var(--primary); }

/* ── Section-title helper (eyebrow is defined earlier, unified) ── */
/* Standalone section title (use when .dash-section-header doesn't fit).
   Wraps a title with the same plum accent-bar anchor. */
.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  letter-spacing: -0.015em;
  line-height: var(--lh-snug);
  margin: 0 0 var(--space-4);
}

.section-title::before {
  content: '';
  width: 3px;
  height: 20px;
  background: var(--primary);
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.section-title.neutral::before { background: var(--text-subtle); }
.section-title.success::before { background: var(--success); }
.section-title.warning::before { background: var(--warning); }
.section-title.info::before    { background: var(--info); }

/* ── Main grid: clients (7/12) + aside (5/12) ── */
.dash-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: var(--space-6);
  margin-bottom: var(--space-9);
  align-items: start;
}

@media (max-width: 1100px) { .dash-main-grid { grid-template-columns: 1fr; } }

.dash-main-grid .dash-aside {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* ── Dense client table inside a card ── */
.clients-table {
  width: 100%;
  border-collapse: collapse;
}

.clients-table thead th {
  text-align: left;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-5) var(--space-6);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.clients-table thead th.num { text-align: right; }

.clients-table tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
  cursor: pointer;
}

.clients-table tbody tr:hover { background: var(--surface-subtle); }

.clients-table tbody tr + tr td { border-top: 1px solid var(--border-subtle); }

.clients-table td {
  padding: var(--space-5) var(--space-6);
  font-size: var(--text-sm);
  color: var(--text-default);
  vertical-align: middle;
}

.clients-table td.name {
  font-weight: var(--weight-medium);
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}

.clients-table td.num {
  text-align: right;
  font-feature-settings: "lnum" 1;
  font-variant-numeric: tabular-nums;
}

.clients-table td.missing { color: var(--danger-text); font-weight: var(--weight-semibold); }

.clients-table td.progress-cell {
  width: 160px;
}

.clients-table .progress-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.clients-table .progress-bar {
  flex: 1;
  height: 5px;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.clients-table .progress-bar > span {
  display: block;
  height: 100%;
  background: var(--success);
  border-radius: inherit;
  transition: width 400ms var(--ease-out);
}

.clients-table .progress-bar.warning > span { background: var(--warning); }

.clients-table .progress-pct {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-feature-settings: "lnum" 1;
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: right;
}

/* ── Small stacked cards in aside ── */
.aside-card { }
.aside-card .card-body { padding: var(--space-6) var(--space-7); }

.type-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-3);
}

.type-row .type-label-group { display: flex; align-items: baseline; gap: var(--space-3); }

.type-row .type-total {
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  font-size: var(--text-md);
  font-feature-settings: "lnum" 1;
}

.type-row .type-label-extra {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.type-row .type-ratio {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-feature-settings: "lnum" 1;
}

.type-progress {
  height: 5px;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: var(--space-6);
}

.type-progress:last-child { margin-bottom: 0; }

.type-progress > span {
  display: block;
  height: 100%;
  background: var(--success);
  border-radius: inherit;
  transition: width 400ms var(--ease-out);
}

.type-progress.warning > span {
  background: var(--warning);
}

/* Dense import list */
.import-list { display: flex; flex-direction: column; }

.import-list .import-item {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: var(--space-4);
}

.import-list .import-item:first-child { border-top: none; }

.import-list .import-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-list .import-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.import-list .import-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-feature-settings: "lnum" 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Quick actions: full-width row ── */
.dash-quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

@media (max-width: 860px) { .dash-quick { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .dash-quick { grid-template-columns: 1fr; } }

.dash-quick-card {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: all var(--dur-fast) var(--ease-out);
}

.dash-quick-card:hover {
  background: var(--surface-subtle);
  border-color: var(--border-strong);
  color: inherit;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.dash-quick-card .qc-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dash-quick-card .qc-text { min-width: 0; }
.dash-quick-card .qc-text .title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
}

.dash-quick-card .qc-text .desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Flush card-body (no padding) for tables/lists that bring their own spacing */
.card-body.card-body-flush { padding: 0; }

/* Static chip (for single-company case) */
.company-chip.is-static {
  cursor: default;
  border-color: rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.05);
}
.company-chip.is-static:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.18);
}

/* ═══════════════════════════════════════════════════════════════
   PAGE: Dashboard v3 — Morning Radar (spec 004)
   ═══════════════════════════════════════════════════════════════ */

/* ── Header strip: compact single-row of totals ── */
.header-strip {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-9);
  margin-bottom: var(--space-9);
  display: flex;
  align-items: center;
  gap: var(--space-10);
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm), var(--shadow-highlight);
  position: relative;
  overflow: hidden;
}

.header-strip::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--primary) 4%, transparent) 0%, transparent 50%);
  pointer-events: none;
}

.header-strip > * { position: relative; }

.header-strip .strip-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.header-strip .strip-value {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: var(--text-3xl);
  color: var(--text-strong);
  letter-spacing: -0.028em;
  line-height: 1;
  font-feature-settings: "lnum" 1, "tnum" 1;
  display: flex;
  align-items: baseline;
}

.header-strip .strip-value.muted   { color: var(--text-default); }   /* default ≈ text-default, not muted */
.header-strip .strip-value.success { color: var(--success-text); }
.header-strip .strip-value.danger  { color: var(--danger-text); }

.header-strip .strip-value .suffix {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  margin-left: var(--space-2);
  font-family: var(--font-sans);
  letter-spacing: 0;
}

.header-strip .strip-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  letter-spacing: 0;
  font-weight: var(--weight-medium);
}

.header-strip .strip-divider {
  width: 1px;
  height: 44px;
  background: var(--border-subtle);
}

/* ── Aging panel ── */
.aging-panel { margin-bottom: var(--space-10); }

.aging-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-4);
}

@media (max-width: 960px) {
  .aging-bar { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  .aging-bar { grid-template-columns: repeat(2, 1fr); }
}

.aging-bucket {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-7) var(--space-6);   /* 20×16 — more breathing */
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  min-height: 120px;
  box-shadow: var(--shadow-xs), var(--shadow-highlight);
  transition: transform var(--dur-med) var(--ease-out),
              box-shadow var(--dur-med) var(--ease-out),
              border-color var(--dur-med) var(--ease-out);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.aging-bucket:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--shadow-highlight);
  border-color: var(--border);
  text-decoration: none;
  color: inherit;
}

/* Subtle left accent bar that picks up severity color */
.aging-bucket::before {
  content: '';
  position: absolute;
  top: var(--space-5);
  bottom: var(--space-5);
  left: 0;
  width: 2px;
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  background: transparent;
  transition: background var(--dur-med) var(--ease-out);
}

.aging-bucket .bucket-label {
  font-size: var(--text-xs);                /* 11 → 12 */
  color: var(--text-muted);
  font-weight: var(--weight-semibold);      /* 500 → 600 */
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.aging-bucket .bucket-count {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  line-height: 1;
  letter-spacing: -0.025em;
  font-feature-settings: "lnum" 1, "tnum" 1;
  margin-top: var(--space-3);
}

.aging-bucket .bucket-footer {
  margin-top: var(--space-4);
  font-size: var(--text-xs);                /* 11 → 12 */
  color: var(--text-subtle);
  font-weight: var(--weight-medium);
}

/* Severity — very subtle background tints, accent bar carries the signal */
.aging-bucket.severity-ok        { background: var(--surface); }
.aging-bucket.severity-ok::before        { background: var(--success); opacity: 0.3; }

.aging-bucket.severity-attention { background: var(--surface-subtle); }
.aging-bucket.severity-attention::before { background: var(--text-muted); opacity: 0.5; }

.aging-bucket.severity-warning   { background: var(--warning-bg-subtle); }
.aging-bucket.severity-warning::before { background: var(--warning); }
.aging-bucket.severity-warning .bucket-count { color: var(--warning-text); }

.aging-bucket.severity-danger    { background: var(--danger-bg-subtle); }
.aging-bucket.severity-danger::before  { background: var(--danger); }
.aging-bucket.severity-danger .bucket-count  { color: var(--danger-text); }
.aging-bucket.severity-danger .bucket-footer { color: var(--danger-text); opacity: 0.7; }

.aging-redzone-note {
  margin-top: var(--space-6);
  padding: var(--space-6) var(--space-7);
  background: var(--danger-bg-subtle);
  border: 1px solid color-mix(in srgb, var(--danger) 18%, transparent);
  border-radius: var(--radius-md);
  color: var(--danger-text);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

.aging-redzone-note .rz-main {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.aging-redzone-note .rz-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
}

.aging-redzone-note .rz-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--danger-text);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  white-space: nowrap;
  transition: gap var(--dur-fast) var(--ease-out);
}
.aging-redzone-note .rz-link:hover { gap: var(--space-3); }
.aging-redzone-note .rz-link svg { transition: transform var(--dur-fast) var(--ease-out); }
.aging-redzone-note .rz-link:hover svg { transform: translateX(2px); }

/* ── Middle grid: Velocity + Operational ── */
.dash-mid-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-9);
}
@media (max-width: 960px) { .dash-mid-grid { grid-template-columns: 1fr; } }

/* Velocity panel */
.velocity-panel .card-body {
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
}

.velocity-primary {
  display: flex;
  align-items: baseline;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.velocity-primary .v-count {
  font-family: var(--font-display);
  font-size: var(--text-4xl);               /* tokenized — was hardcoded 44px */
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  line-height: 1;
  letter-spacing: -0.03em;
  font-feature-settings: "lnum" 1, "tnum" 1;
}

.velocity-primary .v-unit {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.delta-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 3px 9px;
  height: 22px;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
}

.delta-chip.positive { background: var(--success-bg); color: var(--success-text); }
.delta-chip.negative { background: var(--danger-bg);  color: var(--danger-text); }
.delta-chip.neutral  { background: var(--neutral-bg); color: var(--neutral-text); }
.delta-chip svg { width: 10px; height: 10px; flex-shrink: 0; }

/* Sparkline */
.velocity-spark { display: flex; flex-direction: column; gap: var(--space-3); }

.velocity-spark svg {
  width: 100%;
  height: 64px;
  display: block;
}

.velocity-spark .spark-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.velocity-spark .spark-area { fill: var(--primary-bg); stroke: none; }
.velocity-spark .spark-dot  { fill: var(--primary); }
.velocity-spark .spark-last-dot { fill: var(--primary); r: 4; }

.spark-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-2xs);
  color: var(--text-subtle);
  letter-spacing: 0.02em;
}

.spark-labels .now {
  color: var(--primary);
  font-weight: var(--weight-semibold);
}

.net-flow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6) var(--space-7);
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.net-flow .nf-label { display: flex; flex-direction: column; gap: var(--space-2); }

.net-flow .nf-title {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: var(--weight-semibold);
}

.net-flow .nf-formula {
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.net-flow .nf-value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.015em;
  line-height: 1;
  font-feature-settings: "lnum" 1, "tnum" 1;
}

.net-flow.positive .nf-value { color: var(--success-text); }
.net-flow.negative .nf-value { color: var(--danger-text); }
.net-flow.neutral  .nf-value { color: var(--text-muted); }

.velocity-projection {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--lh-normal);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.velocity-projection .trend-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.velocity-projection.positive .trend-icon { color: var(--success); }
.velocity-projection.negative .trend-icon { color: var(--danger); }
.velocity-projection.neutral  .trend-icon { color: var(--text-muted); }

.velocity-projection strong {
  color: var(--text-strong);
  font-weight: var(--weight-semibold);
}

/* Operational panel */
.op-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.op-chip {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-7);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: transform var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.op-chip:hover {
  transform: translateX(2px);
  text-decoration: none;
  color: inherit;
}

.op-chip .op-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.op-chip .op-content { flex: 1; min-width: 0; }

.op-chip .op-count {
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  font-size: var(--text-md);
  font-feature-settings: "lnum" 1, "tnum" 1;
  line-height: var(--lh-snug);
}

.op-chip .op-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.op-chip .op-arrow {
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  transition: transform var(--dur-fast) var(--ease-out);
}

.op-chip:hover .op-arrow { transform: translateX(2px); color: var(--text-muted); }

/* Severity — subtle background tints, dot + text carries the signal */
.op-chip.danger  { background: var(--danger-bg-subtle);  border-color: color-mix(in srgb, var(--danger) 18%, transparent); }
.op-chip.danger  .op-dot { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.op-chip.danger  .op-count { color: var(--danger-text); }

.op-chip.warning { background: var(--warning-bg-subtle); border-color: color-mix(in srgb, var(--warning) 18%, transparent); }
.op-chip.warning .op-dot { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 18%, transparent); }
.op-chip.warning .op-count { color: var(--warning-text); }

.op-chip.ok { background: var(--success-bg-subtle); border-color: color-mix(in srgb, var(--success) 18%, transparent); }
.op-chip.ok .op-dot { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent); }
.op-chip.ok .op-count { color: var(--success-text); }

/* ── Worklist table ── */
.worklist-card .card-body { padding: 0; }

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

.worklist-table thead th {
  text-align: left;
  font-size: var(--text-xs);                    /* 11 → 12 */
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-5) var(--space-7);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.worklist-table thead th.num { text-align: right; }

.worklist-table tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
  cursor: pointer;
}

.worklist-table tbody tr:hover { background: var(--surface-subtle); }

.worklist-table tbody tr + tr td { border-top: 1px solid var(--border-subtle); }

.worklist-table td {
  padding: var(--space-6) var(--space-7);
  font-size: var(--text-sm);
  color: var(--text-default);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.worklist-table td.name {
  font-weight: var(--weight-medium);
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}

.worklist-table td.num {
  text-align: right;
  font-feature-settings: "lnum" 1;
  font-variant-numeric: tabular-nums;
}

.worklist-table td.missing {
  color: var(--danger-text);
  font-weight: var(--weight-semibold);
}

.worklist-table .impact-cell { width: 180px; }

.worklist-table .impact-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.worklist-table .impact-bar {
  flex: 1;
  height: 5px;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.worklist-table .impact-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.worklist-table .impact-value {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-feature-settings: "lnum" 1;
  min-width: 56px;
  text-align: right;
}

/* ═══════════════════════════════════════════════════════════════
   SHARED — .status-pill (inline indicator used in tables/lists)
   ═══════════════════════════════════════════════════════════════ */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px var(--space-4);
  height: 22px;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  background: var(--neutral-bg);
  color: var(--neutral-text);
  white-space: nowrap;
}

.status-pill svg { width: 12px; height: 12px; flex-shrink: 0; }

.status-pill.pill-stamped,
.status-pill.pill-matched     { background: var(--success-bg); color: var(--success-text); }
.status-pill.pill-missing,
.status-pill.pill-unidentified { background: var(--danger-bg); color: var(--danger-text); }
.status-pill.pill-pending     { background: var(--warning-bg); color: var(--warning-text); }
.status-pill.pill-continuation { background: var(--info-bg); color: var(--info-text); }
.status-pill.pill-exempt      { background: var(--neutral-bg); color: var(--neutral-text); }

/* Confidence pills (OCR match confidence) */
.conf-pill       { background: var(--neutral-bg); color: var(--neutral-text); }
.conf-pill.high  { background: var(--success-bg); color: var(--success-text); }
.conf-pill.mid   { background: var(--warning-bg); color: var(--warning-text); }
.conf-pill.low   { background: var(--danger-bg);  color: var(--danger-text); }

/* ═══════════════════════════════════════════════════════════════
   SHARED — Attention banner (card-flagged "needs attention" callout)
   ═══════════════════════════════════════════════════════════════ */

.attention-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-5) var(--space-7);
  background: var(--primary-bg);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
  border-left-width: 3px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-7);
}

.attention-banner .ab-main {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-width: 0;
}

.attention-banner .ab-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.attention-banner .ab-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
}

.attention-banner .ab-description {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Warning variant (amber) */
.attention-banner.warning { background: var(--warning-bg-subtle); border-color: color-mix(in srgb, var(--warning) 22%, transparent); }
.attention-banner.warning .ab-icon { color: var(--warning); }

/* ═══════════════════════════════════════════════════════════════
   PAGE: Scanner (spec 002 polish)
   ═══════════════════════════════════════════════════════════════ */

/* "How it works" ordered list refinement */
.how-it-works {
  list-style: decimal;
  padding-left: var(--space-7);
  line-height: var(--lh-loose);
  color: var(--text-default);
}

.how-it-works li + li { margin-top: var(--space-2); }

.how-it-works ul {
  list-style: disc;
  padding-left: var(--space-7);
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.how-it-works strong { color: var(--text-strong); font-weight: var(--weight-semibold); }

/* Scanner results — metric strip on top */
.scan-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

@media (max-width: 960px) { .scan-summary-strip { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .scan-summary-strip { grid-template-columns: repeat(2, 1fr); } }

.scan-metric-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  box-shadow: var(--shadow-xs), var(--shadow-highlight);
  transition: box-shadow var(--dur-med) var(--ease-out), transform var(--dur-med) var(--ease-out);
}

.scan-metric-card:hover {
  box-shadow: var(--shadow-sm), var(--shadow-highlight);
  transform: translateY(-1px);
}

.scan-metric-card .scan-metric-val {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  letter-spacing: -0.025em;
  line-height: 1;
  font-feature-settings: "lnum" 1, "tnum" 1;
}

.scan-metric-card .scan-metric-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.scan-metric-card.stat-matched       .scan-metric-val { color: var(--success-text); }
.scan-metric-card.stat-continuation  .scan-metric-val { color: var(--info-text); }
.scan-metric-card.stat-pending       .scan-metric-val { color: var(--warning-text); }
.scan-metric-card.stat-unidentified  .scan-metric-val { color: var(--danger-text); }

/* Scan-results table fixed widths via classes, not inline */
.scan-results-table th.col-page  { width: 80px; text-align: center; }
.scan-results-table th.col-type  { width: 80px; }
.scan-results-table th.col-conf  { width: 120px; text-align: center; }
.scan-results-table th.col-action{ width: 160px; text-align: center; }
.scan-results-table td.td-center { text-align: center; }
.scan-results-table tr.clickable { cursor: pointer; }
.scan-results-table td.page-num {
  text-align: center;
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Scrollable inner table wrapper */
.table-scroll { max-height: 600px; overflow-y: auto; }
.table-scroll thead { position: sticky; top: 0; z-index: 10; background: var(--surface-subtle); }

/* Type-unknown badge (replaces inline-styled ? badge) */
.type-badge.type-unknown {
  background: var(--surface-muted);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* Image overlay (zoom) — uses class instead of inline */
.zoom-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: var(--space-8);
}

.zoom-overlay.active { display: flex; }

.zoom-overlay img {
  max-height: 90vh;
  max-width: 90vw;
  background: white;
  padding: 10px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xl);
}

/* Done + Error cards in scanner_progress */
.scanner-end-card {
  text-align: center;
  padding: var(--space-10);
}

.scanner-end-card .end-icon { margin-bottom: var(--space-5); }
.scanner-end-card .end-icon.success { color: var(--success); }
.scanner-end-card .end-icon.danger  { color: var(--danger); }

.scanner-end-card h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-3);
}

.scanner-end-card h3.danger { color: var(--danger-text); }

.scanner-end-card p {
  color: var(--text-muted);
  margin-bottom: var(--space-7);
}

.scanner-end-card .end-actions {
  display: flex;
  gap: var(--space-5);
  justify-content: center;
  flex-wrap: wrap;
}

/* Progress bar — used in scanner + documents */
.progress-bar-lg {
  height: 12px;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-lg > .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 100%);
  border-radius: inherit;
  transition: width 400ms var(--ease-out);
}

/* Progress status line */
.progress-status {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  margin-bottom: var(--space-6);
  letter-spacing: -0.005em;
}

.progress-meta {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-4);
}

.progress-meta .eta { color: var(--primary); font-weight: var(--weight-medium); }

/* Status badges — refined to use .status-pill internally */
.status-badge.status-green  { background: var(--success-bg); color: var(--success-text); }
.status-badge.status-red    { background: var(--danger-bg); color: var(--danger-text); }
.status-badge.status-yellow { background: var(--warning-bg); color: var(--warning-text); }
.status-badge.status-grey   { background: var(--neutral-bg); color: var(--neutral-text); }

/* ═══════════════════════════════════════════════════════════════
   Sprint 5 / spec 006 — Odoo credentials UI
   ═══════════════════════════════════════════════════════════════ */

.odoo-company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-6);
}

.odoo-company-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-6);
  transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}

.odoo-company-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), var(--shadow-highlight);
}

.odoo-company-card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.odoo-company-code {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.odoo-company-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  line-height: 1.25;
}

.odoo-company-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neutral-border, #cbd5e1);
  flex-shrink: 0;
}

.status-dot--ok      { background: var(--success-text, #16a34a); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.14); }
.status-dot--pending { background: var(--warning-text, #d97706); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.14); }
.status-dot--idle    { background: #94a3b8; }

.odoo-company-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
}

.meta-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--space-3);
  align-items: baseline;
  font-size: var(--text-sm);
}

.meta-label {
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: var(--weight-medium);
}

.meta-value {
  color: var(--text-strong);
  word-break: break-all;
}

.meta-value--mono {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--text-xs);
  color: var(--text-body);
}

.odoo-company-actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.odoo-company-actions .btn {
  flex: 1;
  justify-content: center;
}

/* ── Credentials form ── */

.odoo-cred-form .form-group + .form-group {
  margin-top: var(--space-5);
}

.odoo-cred-form .form-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.4;
}

.odoo-cred-form .form-help svg {
  flex-shrink: 0;
}

.api-key-field {
  position: relative;
}

.api-key-field input {
  padding-right: 44px;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  letter-spacing: 0.02em;
}

.api-key-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 6px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms var(--ease-out), color 120ms var(--ease-out);
}

.api-key-toggle:hover {
  background: var(--surface-muted);
  color: var(--text-strong);
}

.odoo-sync-meta {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding-top: var(--space-5);
}

.o-cp-breadcrumb-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 120ms var(--ease-out);
}

.o-cp-breadcrumb-link:hover { color: var(--text-strong); }

.o-cp-breadcrumb-sep {
  margin: 0 8px;
  color: var(--text-muted);
  opacity: 0.5;
}

.badge-muted {
  background: var(--surface-muted);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
}

/* ── Phase 7.1 — track_from diagnostic banner on /documents ── */
.track-from-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 0 0 12px 0;
  background: var(--surface-muted);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--color-primary, #4a90e2);
  border-radius: 6px;
  font-size: var(--text-sm);
  color: var(--text-default);
}
.track-from-banner .banner-icon {
  display: inline-flex;
  color: var(--color-primary, #4a90e2);
  flex-shrink: 0;
}
.track-from-banner .banner-text { flex: 1; }
.track-from-banner .banner-action { margin: 0; }
.track-from-banner strong { color: var(--text-strong); font-weight: var(--weight-semibold); }
