/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Brand — Reimbursements green */
  --navy:       #064e3b;
  --navy-dark:  #053b2d;
  --primary:    #059669;
  --primary-dk: #047857;
  --success:    #059669;
  --success-bg: #ecfdf5;
  --warn:       #d97706;
  --warn-bg:    #fffbeb;
  --danger:     #dc2626;
  --danger-dk:  #b91c1c;
  --danger-bg:  #fef2f2;

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

  /* Surfaces */
  --bg:         #f0f1f3;
  --surface:    #ffffff;
  --surface-alt: #f9fafb;
  --surface-hover: #e8ecf1;
  --overlay-bg: rgba(17,24,39,.35);
  --text:       #111827;
  --text-muted: #6b7280;
  --radius:     8px;
  --radius-sm:  5px;
  --radius-lg:  10px;
  --shadow:     0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg:  0 4px 16px rgba(0,0,0,.10), 0 12px 40px rgba(0,0,0,.06);

  /* Typography */
  --font:       'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Font-size scale — anchored on 13px body, matches every size in this file */
  --fs-xs:  10px;
  --fs-sm:  11px;
  --fs-md:  12px;
  --fs-base:13px;
  --fs-lg:  14px;
  --fs-xl:  15px;
  --fs-2xl: 16px;
  --fs-3xl: 18px;
  --fs-4xl: 20px;
  --fs-5xl: 24px;
  --fs-6xl: 26px;

  /* Spacing scale — every gap/padding/margin in this file fits one of these steps */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Motion */
  --ease:         cubic-bezier(.4, 0, .2, 1);
  --motion-fast:  .1s;
  --motion-med:   .15s;
  --motion-slow:  .25s;

  /* Focus ring — one glow colour, reused via --focus-color per variant */
  --focus-color:      var(--primary);
  --focus-ring-rgba:  rgba(5,150,105,.15);
  --danger-ring-rgba: rgba(220,38,38,.15);
}

/* ── Dark mode ────────────────────────────────────────────── */
.dark {
  --bg: #111827;
  --surface: #1f2937;
  --surface-alt: #1a2332;
  --surface-hover: #2a3544;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --border: #374151;
  --gray-100: #1f2937;
  --gray-200: #374151;
  --gray-300: #4b5563;
  --gray-400: #6b7280;
  --gray-50: #1a2332;
  --gray-500: #9ca3af;
  --success-bg: rgba(5,150,105,.15);
  --danger-bg: rgba(220,38,38,.15);
  --warn-bg: rgba(217,119,6,.15);
  --overlay-bg: rgba(0,0,0,.55);
  --shadow: 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.15);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.3), 0 12px 40px rgba(0,0,0,.2);
  --gray-600: #9ca3af;
  --gray-700: #d1d5db;
}
.dark a { color: #6ee7b7; }
.dark .badge-draft { background: var(--gray-200); color: var(--gray-700); border-color: var(--gray-300); }
.dark .badge-closed { background: var(--gray-200); color: var(--gray-600); }

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

body {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ── Header ────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 48px;
  background: var(--navy);
  color: #fff;
  flex-shrink: 0;
  gap: 12px;
  z-index: 20;
}
.header-left  { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* Auth chip */
.auth-wrap { position: relative; }
.auth-chip {
  display: inline-flex; align-items: center; padding: 4px 10px;
  border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.07); color: #fff; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 500;
  transition: background .12s;
}
.auth-chip:hover { background: rgba(255,255,255,.14); }
.auth-user-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-popover {
  display: none; position: absolute; top: calc(100% + 4px); right: 0;
  min-width: 200px; background: var(--surface); color: var(--gray-900);
  border-radius: var(--radius); border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-lg); padding: 10px 12px; z-index: 100;
}
.auth-popover.open { display: block; }
.auth-popover-name { font-size: 13px; font-weight: 600; }
.auth-popover-email { font-size: 11px; color: var(--gray-500); word-break: break-all; }
.auth-popover-action {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 5px 4px; font-size: 12px; color: var(--gray-700); cursor: pointer;
  border-radius: 4px; text-decoration: none; transition: background .1s;
}
.auth-popover-action:hover { background: var(--gray-100); color: var(--danger); }
.app-logo  { height: 38px; width: auto; display: block; }
.app-title { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.7); letter-spacing: .04em; text-transform: uppercase; }

/* ── Button System ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 32px; padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius);
  font-family: var(--font); font-size: var(--fs-md); font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  transition: all var(--motion-med) var(--ease);
  /* --btn-ring is overridden by danger variants; see .btn:focus-visible below */
  --btn-ring: var(--primary);
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--btn-ring); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--gray-300); }
.btn-outline:hover { background: var(--gray-100); border-color: var(--gray-400); }
.btn-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn:disabled, .btn.btn-loading { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-ghost { background: transparent; color: var(--text-muted); border: none; box-shadow: none; }
.btn-ghost:hover { background: var(--gray-100); color: var(--text); }
.btn-ghost-danger { background: transparent; color: var(--danger); border: none; box-shadow: none; --btn-ring: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-bg); color: var(--danger-dk); }
.btn-danger { background: var(--danger); color: #fff; --btn-ring: var(--danger); }
.btn-danger:hover { background: var(--danger-dk); }
.btn-sm { height: 26px; padding: 0 var(--space-3); font-size: var(--fs-sm); }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  background: rgba(255,255,255,.07); color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm); font-size: var(--fs-xl);
}
.btn-icon:hover { background: rgba(255,255,255,.14); }

/* Dark-mode toggle icon swap — moon in light mode, sun in dark mode. */
.dm-icon-sun { display: none; }
.dark .dm-icon-moon { display: none; }
.dark .dm-icon-sun { display: inline-block; }

/* ── Nav Bar ──────────────────────────────────────────────── */
.nav-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 12px;
  height: 38px;
  background: var(--navy-dark);
  flex-shrink: 0;
  overflow-x: auto;
  z-index: 15;
}
.nav-section {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-right: 1px solid rgba(255,255,255,.08);
  height: 100%;
}
.nav-section:last-child { border-right: none; }
.nav-section-label {
  font-size: 9px; font-weight: 700; color: rgba(255,255,255,.3);
  text-transform: uppercase; letter-spacing: .08em;
  margin-right: 6px; white-space: nowrap;
}
.nav-segment { display: flex; gap: 1px; }
.nav-btn {
  background: transparent; border: none; color: rgba(255,255,255,.55);
  font: inherit; font-size: 12px; font-weight: 500;
  padding: 6px 10px; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
  transition: all .12s var(--ease);
}
.nav-btn:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.85); }
.nav-btn.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }

/* ── Filter Bar ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-icon {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--gray-400); pointer-events: none;
}
.search-input {
  width: 100%; height: 30px; padding: 0 28px 0 30px;
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  font: inherit; font-size: 12px; background: var(--bg); color: var(--text);
  transition: border-color .15s;
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--focus-ring-rgba); }
.search-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; background: none; border: none;
  color: var(--gray-400); font-size: 14px; cursor: pointer;
  display: none;
}
.search-input:not(:placeholder-shown) + .search-clear,
.search-wrap:focus-within .search-clear { display: block; }
.filter-summary { font-size: 11px; color: var(--text-muted); white-space: nowrap; margin-left: auto; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}
.view { display: none; }
.view.active { display: block; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: var(--space-3);
  overflow: hidden;
}
.card.card-visible { overflow: visible; }
.card-header {
  padding: 10px var(--space-4);
  font-size: var(--fs-sm); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: var(--space-4); }

/* ── Stat Tiles ────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.stat-tile::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-tile.green::before { background: var(--success); }
.stat-tile.amber::before { background: var(--warn); }
.stat-tile.red::before   { background: var(--danger); }
.stat-tile.blue::before  { background: #3b82f6; }
.stat-label { font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: .04em; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); margin-top: 4px; font-family: var(--font-mono); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }

/* ── Tables ────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 2;
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--surface-hover); }
.data-table tr { cursor: pointer; transition: background .1s; }
.data-table td.mono { font-family: var(--font-mono); font-size: 11px; }
.data-table td.right, .data-table th.right { text-align: right; }

/* ── Status Badges ────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap;
}
.badge-draft       { background: var(--gray-100); color: var(--text-muted); border: 1px solid var(--gray-200); }
.badge-submitted,
.badge-pending_approval { background: #dbeafe; color: #1e40af; }
.badge-approved     { background: #d1fae5; color: #065f46; }
.badge-rejected     { background: #fecaca; color: #991b1b; }
.badge-sent_to_payroll { background: #e0e7ff; color: #3730a3; }
.badge-paid         { background: #d1fae5; color: #065f46; }
.badge-finance_review { background: #fef3c7; color: #92400e; }
.badge-closed       { background: var(--gray-200); color: var(--gray-600); }

.dark .badge-submitted,
.dark .badge-pending_approval { background: #1e3a5f; color: #93c5fd; }
.dark .badge-approved { background: #064e3b; color: #6ee7b7; }
.dark .badge-rejected { background: #7f1d1d; color: #fca5a5; }
.dark .badge-sent_to_payroll { background: #312e81; color: #a5b4fc; }
.dark .badge-paid { background: #064e3b; color: #6ee7b7; }
.dark .badge-finance_review { background: #78350f; color: #fcd34d; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-3);
}
.form-label {
  display: block;
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .03em;
  margin-bottom: var(--space-1);
}
.form-control {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font: inherit; font-size: var(--fs-base);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--motion-med);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--focus-ring-rgba); }
textarea.form-control { height: auto; padding: 8px 10px; resize: vertical; min-height: 60px; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ca3af'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
input[type="date"].form-control { color-scheme: light; }
.dark input[type="date"].form-control { color-scheme: dark; }

/* Modern toggle checkbox */
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; flex-shrink: 0;
  border: 2px solid var(--gray-300); border-radius: 4px;
  background: var(--surface); cursor: pointer;
  position: relative; vertical-align: middle;
  transition: background .15s, border-color .15s;
}
input[type="checkbox"]:checked {
  background: var(--primary); border-color: var(--primary);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute; left: 4px; top: 1px;
  width: 6px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible {
  outline: none; box-shadow: 0 0 0 2px var(--focus-ring-rgba);
}

/* SearchableSelect: context overrides */
.filter-bar .ss-wrap { min-width: 160px; }
.filter-bar .ss-trigger { height: 30px; }
.data-table .ss-wrap { min-width: 100px; width: auto; }
.data-table .ss-trigger { height: 26px; font-size: 11px; }

/* Drop zone upload */
.drop-zone {
  position: relative;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  transition: border-color .25s var(--ease), background .25s var(--ease), box-shadow .25s var(--ease);
  cursor: pointer;
  overflow: hidden;
}
.drop-zone::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(5,150,105,.03) 0%, transparent 60%);
  opacity: 0;
  transition: opacity .25s var(--ease);
  pointer-events: none;
}
.drop-zone:hover { border-color: var(--primary); }
.drop-zone:hover::before { opacity: 1; }
.drop-zone.drag-over {
  border-color: var(--primary);
  border-style: solid;
  background: rgba(5,150,105,.06);
  box-shadow: 0 0 0 3px rgba(5,150,105,.12);
}
.drop-zone.drag-over .drop-zone-prompt { opacity: 0; transform: scale(.96); }
.drop-zone.drag-over .drop-zone-active-text { opacity: 1; transform: translateY(0); }
.drop-zone.has-files { cursor: default; border-style: solid; border-color: var(--gray-200); padding: 12px; }
.drop-zone.has-files::before { display: none; }
.drop-zone-input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }

/* Prompt state */
.drop-zone-prompt {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.drop-zone.has-files .drop-zone-prompt { display: none; }
.drop-zone-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--success-bg); color: var(--primary);
  border-radius: 50%;
  transition: transform .2s var(--ease);
}
.drop-zone:hover .drop-zone-icon { transform: translateY(-2px); }
.drop-zone-text { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; color: var(--gray-500); }
.drop-zone-hint { font-size: 11px; color: var(--gray-400); }
.drop-zone-link {
  background: none; border: none; padding: 0;
  color: var(--primary); font-weight: 600; font-size: inherit;
  cursor: pointer; text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.drop-zone-link:hover { border-bottom-color: var(--primary); }

/* Drag-over state overlay text */
.drop-zone-active-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; color: var(--primary);
  opacity: 0; transform: translateY(4px);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  pointer-events: none;
}
.drop-zone.has-files .drop-zone-active-text { display: none; }

/* Camera button (mobile only) */
.drop-zone-camera-btn {
  display: none; align-items: center; gap: 6px;
  padding: 6px 14px; margin-top: 2px;
  font-size: 12px; font-weight: 500; color: var(--gray-600);
  background: var(--surface); border: 1px solid var(--gray-200); border-radius: 20px;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.drop-zone-camera-btn:hover { background: var(--gray-50); border-color: var(--gray-300); }
.drop-zone-camera-btn svg { color: var(--gray-500); }
@media (max-width: 600px) { .drop-zone-camera-btn { display: inline-flex; } }

/* File cards */
.drop-zone-files { display: flex; flex-direction: column; gap: 6px; }
@keyframes dropFileIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.drop-zone-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--gray-50); border: 1px solid var(--gray-100);
  border-radius: var(--radius); position: relative;
  animation: dropFileIn .25s var(--ease) both;
  transition: background .15s;
}
.drop-zone-card:hover { background: var(--gray-100); }
.drop-zone-thumb {
  width: 42px; height: 42px; border-radius: 6px; overflow: hidden; flex-shrink: 0;
  background: var(--gray-200);
}
.drop-zone-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drop-zone-badge {
  width: 42px; height: 42px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #fecaca, #fde8e8); color: #b91c1c;
  border-radius: 6px; font-size: 10px; font-weight: 700; letter-spacing: .5px;
}
.drop-zone-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.drop-zone-name {
  font-size: 12px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drop-zone-size { font-size: 11px; color: var(--gray-400); }
.drop-zone-remove {
  width: 24px; height: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 50%;
  font-size: 16px; line-height: 1; color: var(--gray-400); cursor: pointer;
  transition: background .15s, color .15s;
}
.drop-zone-remove:hover { background: var(--danger-bg); color: var(--danger); }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.form-help { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ── Dialog ────────────────────────────────────────────────── */
.dialog-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: var(--overlay-bg);
  align-items: center; justify-content: center;
}
.dialog-overlay.open { display: flex; }
.dialog-box {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 24px; width: min(420px, 90vw);
  box-shadow: var(--shadow-lg);
}
.dialog-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.dialog-message { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.dialog-input, .dialog-textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  font: inherit; font-size: 13px; margin-bottom: 12px;
  background: var(--surface); color: var(--text);
}
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Detail Panel ─────────────────────────────────────────── */
.detail-overlay {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: var(--overlay-bg);
}
.detail-overlay.open { display: flex; justify-content: flex-end; }
.detail-panel {
  width: min(600px, 90vw); height: 100%;
  background: var(--surface); display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slide-in .2s var(--ease);
}
@keyframes slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
.detail-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.detail-panel-header h3 { font-size: 15px; font-weight: 700; }
.detail-close {
  width: 28px; height: 28px; border: none; background: transparent;
  color: var(--gray-500); font-size: 16px; cursor: pointer;
  border-radius: var(--radius-sm);
}
.detail-close:hover { background: var(--gray-100); color: var(--danger); }
.detail-panel-body { flex: 1; overflow-y: auto; padding: 16px 20px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 600;
  background: var(--overlay-bg);
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px; border: none; background: transparent;
  color: var(--gray-500); font-size: 16px; cursor: pointer;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--gray-100); color: var(--danger); }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }

/* Settings tabs */
.settings-tab-bar { display: flex; gap: 2px; margin-bottom: 16px; }
.settings-tab-btn {
  background: transparent; border: none; padding: 6px 14px;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--text-muted);
  border-radius: var(--radius-sm); cursor: pointer;
}
.settings-tab-btn:hover { background: var(--gray-100); }
.settings-tab-btn.active { background: var(--primary); color: #fff; font-weight: 600; }

/* ── Toast ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s var(--ease);
  max-width: 360px;
}
.toast-success { background: #059669; color: #fff; }
.toast-error   { background: #dc2626; color: #fff; }
.toast-info    { background: #3b82f6; color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ── Progress Bar (claim detail) ──────────────────────────── */
.progress-bar {
  display: flex; align-items: flex-start; padding: 12px 0 20px; margin-bottom: 8px;
}
.step-node {
  display: flex; flex-direction: column; align-items: center; flex-shrink: 0;
}
.step-circle {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; transition: all .2s;
}
.step-done {
  background: var(--primary); color: #fff;
}
.step-current {
  background: transparent; color: var(--primary);
  border: 3px solid var(--primary);
  box-shadow: 0 0 0 4px var(--focus-ring-rgba);
}
.step-rejected {
  background: var(--danger); color: #fff;
  box-shadow: 0 0 0 4px var(--danger-ring-rgba);
}
.step-future {
  background: transparent; color: var(--gray-400);
  border: 2px solid var(--gray-300);
}
.step-label {
  font-size: 10px; font-weight: 600; text-align: center;
  margin-top: 6px; white-space: nowrap;
}
.step-label-done, .step-label-current { color: var(--primary); }
.step-label-rejected { color: var(--danger); }
.step-label-future { color: var(--gray-400); }
.step-line {
  flex: 1; height: 3px; min-width: 16px; margin-top: 15px; border-radius: 2px;
}
.step-line-done { background: var(--primary); }
.step-line-future { background: var(--gray-200); }

/* ── Notifications ────────────────────────────────────────── */
.notif-wrap { position: relative; }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px; font-size: 10px; font-weight: 700;
  background: var(--danger); color: #fff;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; line-height: 1;
}
.notif-panel {
  position: absolute; right: 0; top: 100%; margin-top: 4px;
  width: 320px; max-height: 400px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: 200;
}
.notif-header {
  padding: 10px 14px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.notif-item {
  padding: 10px 14px; border-bottom: 1px solid var(--gray-100);
  cursor: pointer; transition: background .1s;
}
.notif-item:hover { background: var(--surface-hover); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--success-bg); }
.notif-action { font-size: 12px; font-weight: 600; color: var(--text); }
.notif-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.notif-bucket-label {
  padding: 6px 14px; font-size: 10px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
  background: var(--surface-alt); border-bottom: 1px solid var(--border);
}

/* ── Tick / Cross icons ──────────────────────────────────────── */
.icon-tick { color: var(--primary); font-weight: 700; font-size: 14px; }
.icon-cross { color: var(--gray-400); font-size: 14px; }

/* ── Pre-registered badge ────────────────────────────────────── */
.badge-prereg { background: #dbeafe; color: #1e40af; }
.dark .badge-prereg { background: #1e3a5f; color: #93c5fd; }

/* ── Timeline ──────────────────────────────────────────────── */
.timeline { padding: 0; list-style: none; }
.timeline-item {
  position: relative;
  padding: 0 0 16px 24px;
}
.timeline-item::before {
  content: '';
  position: absolute; left: 7px; top: 6px; bottom: 0;
  width: 2px; background: var(--gray-200);
}
.timeline-item:last-child::before { display: none; }
.timeline-item::after {
  content: '';
  position: absolute; left: 2px; top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
}
.timeline-item .timeline-date { font-size: 10px; color: var(--text-muted); }
.timeline-item .timeline-text { font-size: 12px; color: var(--text); margin-top: 2px; }

/* ── Claim Form ────────────────────────────────────────────── */
.line-item-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
}
.line-item-card .line-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.line-item-card .line-number {
  font-size: 11px; font-weight: 700; color: var(--primary);
}
.attachment-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; background: var(--gray-100); border-radius: var(--radius-sm);
  font-size: 11px; color: var(--text-muted); margin: 2px;
}
.attachment-chip .remove-att {
  cursor: pointer; color: var(--danger); font-weight: 700; margin-left: 2px;
}

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 13px; max-width: 400px; margin: 0 auto; }

/* ── Misc utilities ──────────────────────────────────────────
   Utility class values align with the --space-* scale so future
   refactors can drop these in favour of inline token usage.      */
.amount { font-family: var(--font-mono); font-weight: 500; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: var(--fs-sm); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

/* ── Hamburger button ──────────────────────────────────────── */
.hamburger-btn { display: none; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Header */
  .app-header {
    padding: 0 10px;
    gap: 8px;
  }
  .app-title {
    font-size: 11px;
  }
  .app-logo {
    height: 30px;
  }
  .auth-chip {
    padding: 4px 8px;
    font-size: 11px;
  }
  .auth-user-name {
    max-width: 80px;
  }

  /* Hamburger */
  .hamburger-btn { display: inline-flex; }

  /* Nav */
  .nav-bar {
    display: none;
    flex-direction: column;
    height: auto;
    padding: 8px;
    gap: 4px;
    overflow-x: unset;
    -webkit-overflow-scrolling: unset;
  }
  .nav-bar.open {
    display: flex;
  }
  .nav-section {
    flex-direction: column;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,.08);
    padding: 6px 0;
    height: auto;
  }
  .nav-section:last-child { border-bottom: none; }
  .nav-segment {
    flex-wrap: wrap;
    gap: 4px;
  }
  .nav-btn {
    padding: 8px 12px;
  }

  /* Filter bar */
  .filter-bar {
    flex-wrap: wrap;
    padding: 6px 10px;
    gap: 6px;
  }
  .search-wrap {
    max-width: 100%;
    flex: 1 1 100%;
  }
  .filter-bar .ss-wrap {
    flex: 1 1 45%;
    min-width: 0;
  }

  /* Touch-friendly form controls */
  .form-control {
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom */
  }
  select.form-control {
    min-height: 44px;
  }
  textarea.form-control {
    min-height: 80px;
  }

  /* Buttons */
  .btn {
    min-height: 44px;
    padding: 0 16px;
  }
  .btn-sm {
    min-height: 36px;
  }

  /* Full-screen edit/detail panels */
  .detail-panel {
    width: 100vw !important;
  }

  /* Edit overlay full-screen with sticky footer */
  .detail-overlay.open .detail-panel {
    width: 100vw !important;
    height: 100vh;
    border-radius: 0;
  }
  .detail-panel-body {
    padding: 12px 16px;
  }

  /* Dialog full-width */
  .dialog-box {
    width: 95vw;
    max-width: 95vw;
  }

  /* Modal full-width */
  .modal {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 95vh;
  }

  /* Tables */
  .data-table {
    font-size: 11px;
  }
  .data-table th,
  .data-table td {
    padding: 6px 8px;
  }

  /* Toast full-width */
  .toast-container {
    left: 12px;
    right: 12px;
  }
  .toast {
    max-width: 100%;
  }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr; }
}

/* ── Comments ───────────────────────────────────────────────── */
.comment-item { padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.comment-item:last-child { border-bottom: none; }
.comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment-initials {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.comment-author { font-size: 13px; font-weight: 600; color: var(--text); }
.comment-time { font-size: 11px; color: var(--text-muted); }
.comment-body { font-size: 13px; color: var(--text); line-height: 1.5; padding-left: 36px; }
.comment-input-wrap { display: flex; flex-direction: column; gap: 0; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-100); }

/* ── Analytics ──────────────────────────────────────────────── */
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { font-size: 12px; color: var(--text); min-width: 120px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 20px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s ease; min-width: 2px; }
.bar-value { font-size: 12px; font-weight: 500; color: var(--text); min-width: 80px; text-align: right; font-family: 'JetBrains Mono', monospace; }

.dark .bar-track { background: var(--gray-700); }
.dark .comment-item { border-bottom-color: var(--gray-700); }
.dark .comment-input-wrap { border-top-color: var(--gray-700); }

/* ── Help Page ──────────────────────────────────────────────── */
.help-layout { display: grid; grid-template-columns: 220px 1fr; gap: var(--space-5); max-width: 1080px; margin: 0 auto; padding: 0 var(--space-4); }
.help-toc { position: sticky; top: var(--space-4); align-self: start; padding: var(--space-3); border-right: 1px solid var(--border); max-height: calc(100vh - 160px); overflow-y: auto; }
.help-toc-title { font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: var(--space-2); }
.help-toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.help-toc a { display: block; padding: 6px 8px; font-size: var(--fs-md); color: var(--text); border-radius: var(--radius-sm); text-decoration: none; transition: background var(--motion-fast); }
.help-toc a:hover { background: var(--gray-100); color: var(--primary); }
@media (max-width: 768px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-toc { position: static; border-right: none; border-bottom: 1px solid var(--border); max-height: none; }
  .help-toc ul { flex-direction: row; flex-wrap: wrap; }
}
.help-page { max-width: 800px; margin: 0; padding: 0 0 var(--space-10); }
.help-header { margin-bottom: 32px; }
.help-header h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.help-section { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--gray-200); }
.help-section:last-child { border-bottom: none; }
.help-section h2 { font-size: 18px; font-weight: 700; margin: 0 0 16px; color: var(--primary); }
.help-section h3 { font-size: 14px; font-weight: 600; margin: 20px 0 8px; color: var(--text); }
.help-section p { font-size: 13px; line-height: 1.7; margin: 0 0 10px; color: var(--text); }
.help-section ul { font-size: 13px; line-height: 1.7; margin: 0 0 10px; padding-left: 20px; color: var(--text); }
.help-section li { margin-bottom: 4px; }
.help-section .data-table { font-size: 13px; margin: 12px 0; }
.help-section .data-table th { font-size: 12px; }
.dark .help-section { border-bottom-color: var(--gray-700); }

/* ── Skeleton loaders ──────────────────────────────────────── */
.skel {
  background: linear-gradient(90deg, var(--gray-100) 0%, var(--gray-200) 50%, var(--gray-100) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skel-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); }
.skel-card-stack { display: flex; flex-direction: column; gap: var(--space-2); }
.skel-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); }
.dark .skel { background: linear-gradient(90deg, var(--gray-200) 0%, var(--gray-300) 50%, var(--gray-200) 100%); }

/* ── Inline field errors ───────────────────────────────────── */
.form-control.has-error,
input[type=checkbox].has-error { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger-ring-rgba); }
.field-error {
  font-size: var(--fs-sm); color: var(--danger); margin-top: var(--space-1);
  display: flex; align-items: center; gap: var(--space-1); font-weight: 500;
}
.field-error::before { content: '!'; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; flex-shrink: 0; }

/* ── Empty states (rich variant) ───────────────────────────── */
.empty-state-rich {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-8) var(--space-5); text-align: center; gap: var(--space-2);
}
.empty-state-icon { color: var(--gray-300); margin-bottom: var(--space-2); }
.empty-state-rich h3 { font-size: var(--fs-2xl); font-weight: 600; color: var(--text); }
.empty-state-rich p { font-size: var(--fs-base); color: var(--text-muted); max-width: 360px; margin: 0; line-height: 1.5; }
.empty-state-rich .btn { margin-top: var(--space-3); }

/* ── Toast — dismissible + action slot ──────────────────────── */
.toast {
  display: flex; align-items: center; gap: var(--space-2);
}
.toast-body { flex: 1; }
.toast-close, .toast-action {
  background: transparent; border: none; color: inherit; cursor: pointer;
  font: inherit; font-weight: 600; padding: 4px 8px; border-radius: var(--radius-sm);
  transition: background var(--motion-med);
}
.toast-close { padding: 2px 6px; font-size: var(--fs-2xl); line-height: 1; opacity: .7; }
.toast-close:hover,
.toast-action:hover { background: rgba(255,255,255,.15); opacity: 1; }

/* ── Status badge with icon ─────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
}
.badge svg { width: 9px; height: 9px; display: block; }
.badge-label { display: inline-block; }

/* ── Keyboard shortcut help overlay ─────────────────────────── */
.shortcut-help {
  position: fixed; inset: 0; z-index: 3000;
  background: var(--overlay-bg);
  display: flex; align-items: center; justify-content: center;
}
.shortcut-help-card {
  background: var(--surface); color: var(--text);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  min-width: 340px; max-width: 420px; padding: var(--space-5);
}
.shortcut-help-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: var(--fs-xl); font-weight: 700; margin-bottom: var(--space-3);
}
.shortcut-help-header button {
  background: transparent; border: none; color: var(--text-muted);
  font-size: var(--fs-2xl); cursor: pointer; border-radius: var(--radius-sm);
  width: 28px; height: 28px;
}
.shortcut-help-card dl {
  display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-4); margin: 0;
}
.shortcut-help-card dt { font-size: var(--fs-sm); display: flex; gap: 4px; align-items: center; }
.shortcut-help-card dd { font-size: var(--fs-base); margin: 0; color: var(--text-muted); }
.shortcut-help-card kbd {
  display: inline-block; padding: 2px 6px;
  background: var(--gray-100); color: var(--text);
  border: 1px solid var(--gray-300); border-bottom-width: 2px;
  border-radius: 4px; font-family: var(--font-mono); font-size: var(--fs-xs);
}

/* ── Row navigation highlight (keyboard J/K) ────────────────── */
.data-table tr.row-focus td { background: var(--success-bg); box-shadow: inset 2px 0 0 var(--primary); }

/* ── Claim cards (approval inbox) ───────────────────────────── */
.claim-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3);
  transition: border-color var(--motion-med), box-shadow var(--motion-med);
}
.claim-card:hover { border-color: var(--gray-300); box-shadow: var(--shadow-md); }
.claim-card.row-focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--focus-ring-rgba); }
.claim-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  flex-wrap: wrap;
}
.claim-card-title { font-family: var(--font-mono); font-weight: 600; font-size: var(--fs-base); }
.claim-card-meta { font-size: var(--fs-sm); color: var(--text-muted); }
.claim-card-total { font-family: var(--font-mono); font-size: var(--fs-3xl); font-weight: 600; }
.claim-card-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.claim-card-summary { font-size: var(--fs-sm); color: var(--text-muted); display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* ── Action menu (⋯ overflow) ───────────────────────────────── */
.action-menu-wrap { position: relative; }
.action-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 180px; padding: var(--space-1); z-index: 50; display: none;
}
.action-menu.open { display: block; }
.action-menu button {
  display: block; width: 100%; text-align: left;
  background: transparent; border: none; font: inherit; font-size: var(--fs-md);
  padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text); cursor: pointer;
}
.action-menu button:hover { background: var(--gray-100); }
.action-menu button.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ── Table row-hover feedback (stronger) ────────────────────── */
.data-table tr[data-id]:hover td { background: var(--surface-hover); }

/* ── Section grouping (dashboard) ───────────────────────────── */
.section-group { margin-bottom: var(--space-4); }
.section-group-header {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) 0; font-size: var(--fs-sm); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
  cursor: pointer; user-select: none;
}
.section-group-header .chev {
  transition: transform var(--motion-med); display: inline-block;
}
.section-group.collapsed .chev { transform: rotate(-90deg); }
.section-group.collapsed .section-group-body { display: none; }
.section-group-count { color: var(--text-muted); font-weight: 500; }

/* ── Amount input with $ prefix ─────────────────────────────── */
.amount-input-wrap { position: relative; }
.amount-input-wrap::before {
  content: '$'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-weight: 500; pointer-events: none;
}
.amount-input-wrap .form-control { padding-left: 22px; }
