/* Bonnio App Shell — Mobile-first CSS for all logged-in pages
   Dashboard, invoices, settings, trusted senders, blacklist.
   Viewport: 375px (iPhone SE) → 430px (iPhone 15 Pro Max) → desktop.
   Touch targets: 44×44px minimum. Card-based layout throughout. */

@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500&display=swap');

@font-face {
  font-family: 'Geist Sans';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/npm/geist@1.3.0/dist/fonts/geist-sans/Geist-Variable.woff2') format('woff2');
}

/* ─── DESIGN TOKENS ──────────────────────────────────────────── */
:root {
  --color-bone:         #F2F4EF;
  --color-bone-dark:    #E4E8DE;
  --color-surface:      #FFFFFF;
  --color-forest-900:   #0E3B2E;
  --color-forest-800:   #164D3C;
  --color-forest-700:   #1E6048;
  --color-forest-500:   #2D8A62;
  --color-mint-300:     #6EE7B7;
  --color-mint-200:     #A7F3D0;
  --color-mint-100:     #D1FAE5;
  --color-emerald-500:  #10B981;
  --color-emerald-600:  #059669;

  --color-success:      #16A34A;
  --color-success-bg:   #DCFCE7;
  --color-warning:      #D97706;
  --color-warning-bg:   #FEF3C7;
  --color-danger:       #DC2626;
  --color-danger-bg:    #FEE2E2;
  --color-info:         #2563EB;
  --color-info-bg:      #DBEAFE;

  --color-ink:          #0F1912;
  --color-ink-secondary:#3D4A3E;
  --color-ink-muted:    #6B7C6D;
  --color-ink-ghost:    #9CAD9E;
  --color-divider:      #D4DACE;
  --color-divider-light:#E8EDE4;

  --font-sans:  'Geist Sans', system-ui, sans-serif;
  --font-mono:  'Geist Mono', 'SF Mono', monospace;

  --text-xs:    0.75rem;
  --text-sm:    0.8125rem;
  --text-base:  0.9375rem;
  --text-md:    1.0625rem;
  --text-lg:    1.25rem;
  --text-xl:    1.5rem;
  --text-2xl:   2rem;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full:9999px;

  --shadow-sm:  0 1px 3px rgba(14,59,46,0.06), 0 1px 2px rgba(14,59,46,0.03);
  --shadow-md:  0 4px 12px rgba(14,59,46,0.08), 0 2px 4px rgba(14,59,46,0.04);
  --shadow-lg:  0 8px 24px rgba(14,59,46,0.10), 0 4px 8px rgba(14,59,46,0.05);
  --shadow-xl:  0 16px 40px rgba(14,59,46,0.12), 0 6px 16px rgba(14,59,46,0.06);
  --shadow-focus: 0 0 0 3px rgba(110,231,183,0.4);

  --motion-fast:    100ms ease;
  --motion-default: 180ms ease;

  /* Safe area for bottom bars */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  background: var(--color-bone);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  /* Reserve space for sticky bottom bar */
  padding-bottom: 0;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.15;
  color: var(--color-forest-900);
  letter-spacing: -0.02em;
}

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

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

/* ─── APP NAV (HEADER) ───────────────────────────────────────── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--color-forest-900);
  height: 56px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  gap: 8px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.app-logo-icon {
  width: 30px;
  height: 30px;
  background: var(--color-mint-300);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: var(--color-forest-900);
  font-family: var(--font-mono);
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.app-logo-img {
  height: 28px;
  width: auto;
  display: block;
}

.app-logo-text {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-mint-200);
  letter-spacing: -0.02em;
  display: none;
}

.app-nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 1;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app-nav-right::-webkit-scrollbar { display: none; }

.nav-user-label {
  font-size: var(--text-xs);
  color: rgba(167,243,208,0.5);
  display: none;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 11px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  min-height: 36px;
  min-width: 36px;
  white-space: nowrap;
  transition: all var(--motion-fast);
  user-select: none;
  flex-shrink: 0;
}

.btn:active { transform: scale(0.97); }

.btn-forest {
  background: rgba(255,255,255,0.08);
  color: var(--color-mint-200);
  border-color: rgba(255,255,255,0.10);
  font-size: 11px;
  padding: 6px 10px;
}

.btn-forest:hover { background: rgba(255,255,255,0.16); }

.btn-primary {
  background: var(--color-forest-900);
  color: var(--color-mint-300);
  border-color: var(--color-forest-900);
}

.btn-primary:hover {
  background: var(--color-forest-800);
  border-color: var(--color-forest-800);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-forest-900);
  border-color: var(--color-divider);
}

.btn-secondary:hover { border-color: var(--color-forest-900); }

.btn-ghost {
  background: transparent;
  color: var(--color-ink-muted);
  border-color: var(--color-divider-light);
  min-height: 44px;
  min-width: 44px;
}

.btn-ghost:hover {
  color: var(--color-danger);
  border-color: rgba(220,38,38,0.3);
  background: var(--color-danger-bg);
}

/* ─── PAGE LAYOUT ────────────────────────────────────────────── */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 14px 80px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: var(--text-lg);
  color: var(--color-forest-900);
}

.page-header .subtitle {
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
  margin-bottom: 20px;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  transition: color var(--motion-fast);
  min-height: 44px;
  min-width: 44px;
}

.back-link:hover {
  color: var(--color-forest-900);
  background: var(--color-bone-dark);
}

.page-title {
  font-size: var(--text-lg);
  margin-bottom: 6px;
  line-height: 1.2;
}

.page-subtitle {
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  margin-bottom: 20px;
  line-height: 1.55;
}

/* ─── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-divider-light);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-header {
  padding: 14px 14px;
  border-bottom: 1px solid var(--color-divider-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.card-header-left {
  flex: 1;
  min-width: 0;
}

.card-header h2 {
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: 2px;
}

.card-header p {
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  line-height: 1.5;
}

.card-count {
  font-size: 11px;
  color: var(--color-ink-ghost);
  background: var(--color-bone);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-body {
  padding: 14px 14px;
}

/* ─── STATS ROW ──────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-divider-light);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--motion-fast);
}

.stat-card:last-child {
  /* If odd number, span full width */
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-ink-ghost);
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-forest-900);
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.stat-sub {
  font-size: 10px;
  color: var(--color-ink-ghost);
  letter-spacing: 0.01em;
}

/* 5th stat card spans full width on mobile 2-col grid */
.stats-row .stat-card:nth-child(5) {
  grid-column: 1 / -1;
}

/* ─── TWO-COLUMN LAYOUT ──────────────────────────────────────── */
.two-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── SIDEBAR ────────────────────────────────────────────────── */
.sidebar-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-divider-light);
  overflow: hidden;
}

.sidebar-section {
  padding: 16px 14px;
  border-bottom: 1px solid var(--color-divider-light);
}

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

.sidebar-title {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-forest-900);
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

/* ─── EMAIL ACCOUNT ITEMS ────────────────────────────────────── */
.account-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-divider-light);
}

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

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.account-label {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-forest-900);
}

.account-email-small {
  font-size: 11px;
  color: var(--color-ink-muted);
  font-family: var(--font-mono);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.account-status-line {
  font-size: 11px;
  margin-top: 2px;
}

.status-idle    { color: var(--color-ink-ghost); }
.status-scanning{ color: var(--color-emerald-500); }
.status-error   { color: var(--color-danger); }

.account-actions { display: flex; gap: 6px; flex-shrink: 0; }

.account-error {
  padding: 10px 12px;
  background: var(--color-danger-bg);
  border: 1px solid rgba(220,38,38,0.15);
  border-radius: var(--radius-md);
  font-size: 11px;
  color: var(--color-danger);
  line-height: 1.55;
}

.account-error a { color: var(--color-info); text-decoration: underline; }

/* ─── DATE RANGE PILLS ───────────────────────────────────────── */
.date-range-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.date-range-btn {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  background: var(--color-bone);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-full);
  color: var(--color-ink-muted);
  cursor: pointer;
  transition: all var(--motion-fast);
  min-height: 32px;
}

.date-range-btn:hover {
  border-color: var(--color-forest-500);
  color: var(--color-forest-900);
}

.date-range-btn.active {
  background: var(--color-forest-900);
  border-color: var(--color-forest-900);
  color: var(--color-mint-300);
}

/* ─── HEALTH BADGES ──────────────────────────────────────────── */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.health-badge-green  { background: var(--color-success-bg); color: var(--color-success); }
.health-badge-orange { background: var(--color-warning-bg); color: var(--color-warning); }
.health-badge-red    { background: var(--color-danger-bg); color: var(--color-danger); }
.health-badge-grey   { background: var(--color-bone-dark); color: var(--color-ink-ghost); }

.health-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.health-dot-green  { background: var(--color-success); }
.health-dot-orange { background: var(--color-warning); }
.health-dot-red    { background: var(--color-danger); }
.health-dot-grey   { background: var(--color-ink-ghost); }

/* ─── SCAN BUTTONS ───────────────────────────────────────────── */
.btn-scan {
  padding: 6px 14px;
  background: var(--color-forest-900);
  color: var(--color-mint-300);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--motion-fast);
  min-height: 34px;
  font-family: var(--font-sans);
}

.btn-scan:hover { background: var(--color-forest-800); }
.btn-scan:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-delete-acct {
  background: transparent;
  border: 1px solid var(--color-divider-light);
  border-radius: var(--radius-sm);
  color: var(--color-ink-ghost);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 13px;
  min-height: 34px;
  min-width: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--motion-fast);
}

.btn-delete-acct:hover {
  color: var(--color-danger);
  border-color: rgba(220,38,38,0.3);
  background: var(--color-danger-bg);
}

.btn-add {
  width: 100%;
  padding: 12px;
  background: var(--color-forest-900);
  color: var(--color-mint-300);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  transition: background var(--motion-fast);
  min-height: 44px;
  font-family: var(--font-sans);
}

.btn-add:hover { background: var(--color-forest-800); }
.btn-add:disabled { opacity: 0.5; cursor: not-allowed; }

.toggle-form-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--color-forest-900);
  border: 1.5px dashed var(--color-divider);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--motion-fast), background var(--motion-fast);
  min-height: 44px;
  font-family: var(--font-sans);
}

.toggle-form-btn:hover {
  border-color: var(--color-forest-500);
  background: var(--color-bone);
}

/* ─── ADD ACCOUNT FORM ───────────────────────────────────────── */
.add-form .input { margin-bottom: 10px; width: 100%; }
.add-form select.input { cursor: pointer; }

/* ─── SCAN FEEDBACK ──────────────────────────────────────────── */
.scan-summary {
  padding: 10px 12px;
  background: var(--color-bone);
  border: 1px solid var(--color-divider-light);
  border-radius: var(--radius-md);
  font-size: 11px;
  color: var(--color-ink-muted);
  line-height: 1.7;
}

.scan-stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.scan-stat-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-forest-900);
}

.scan-summary-zero { border-color: rgba(217,119,6,0.2); }

.scanning-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(16,185,129,0.06);
  border: 1px solid rgba(16,185,129,0.15);
  border-radius: var(--radius-md);
  font-size: 11px;
  color: var(--color-emerald-600);
}

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

.scanning-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-emerald-500);
  animation: pulse-dot 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

/* ─── SCAN OVERVIEW (sidebar) ────────────────────────────────── */
.scan-overview-time {
  font-size: 11px;
  color: var(--color-ink-muted);
  margin-bottom: 10px;
}

.scan-overview-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-ink-secondary);
  margin-bottom: 4px;
}

.scan-overview-num {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-forest-900);
}

/* ─── HOW-IT-WORKS SIDEBAR ───────────────────────────────────── */
.how-steps {
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  line-height: 1.7;
}

.how-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.how-step:last-child { margin-bottom: 0; }

.how-step-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: var(--color-forest-900);
  color: var(--color-mint-300);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  margin-top: 1px;
}

/* ─── SETUP GUIDE ────────────────────────────────────────────── */
.setup-guide {
  padding: 12px;
  background: rgba(16,185,129,0.05);
  border: 1px solid rgba(16,185,129,0.12);
  border-radius: var(--radius-md);
  font-size: 11px;
  color: var(--color-ink-secondary);
  line-height: 1.7;
  margin-top: 8px;
}

.setup-guide strong { color: var(--color-ink); }
.setup-guide a { color: var(--color-forest-500); text-decoration: underline; }
.setup-guide ol { padding-left: 18px; margin: 6px 0 0; }

.setup-guide-title {
  font-weight: 700;
  font-size: 11px;
  color: var(--color-forest-900);
  margin-bottom: 6px;
}

/* ─── INVOICE TABLE HEADER ───────────────────────────────────── */
.invoice-table-head {
  display: none; /* Hide complex table header on mobile — use card layout */
}

.sort-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-ghost);
  padding: 0;
  transition: color var(--motion-fast);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sort-btn.active { color: var(--color-forest-900); }
.sort-btn:hover { color: var(--color-forest-700); }

.sort-indicator {
  font-size: 10px;
  display: inline;
}

/* ─── INVOICE ROWS (card-style on mobile) ────────────────────── */
.invoice-list {
  /* Scrollable list container */
}

.invoice-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 14px 14px;
  border-bottom: 1px solid var(--color-divider-light);
  cursor: pointer;
  transition: background var(--motion-fast);
}

.invoice-row:last-child { border-bottom: none; }
.invoice-row:active { background: var(--color-bone); }

.invoice-row-check-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.invoice-row-check {
  width: 18px;
  height: 18px;
  accent-color: var(--color-forest-700);
  cursor: pointer;
}

.invoice-sender {
  min-width: 0;
  overflow: hidden;
}

.invoice-sender-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-forest-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.invoice-sender-email {
  font-size: 11px;
  color: var(--color-ink-ghost);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.invoice-subject {
  font-size: 11px;
  color: var(--color-ink-ghost);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  display: none; /* Hide on mobile to save space */
}

.invoice-amount {
  text-align: right;
  flex-shrink: 0;
}

.invoice-amount-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-forest-900);
  letter-spacing: -0.02em;
}

.invoice-currency {
  font-size: 10px;
  color: var(--color-ink-ghost);
  text-align: right;
}

.invoice-meta {
  display: none; /* Hide date column on mobile — shown in detail modal */
}

.invoice-date {
  font-size: var(--text-xs);
  color: var(--color-ink-secondary);
}

.invoice-due {
  font-size: 10px;
  color: var(--color-warning);
  margin-top: 2px;
}

/* ─── INVOICE BADGES ─────────────────────────────────────────── */
.badge-forwarded {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-success);
  background: var(--color-success-bg);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-workflow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-auto-sent {
  background: var(--color-success-bg);
  color: var(--color-success);
}

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

.badge-failed {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge-manually-sent {
  background: rgba(45,138,98,0.1);
  color: var(--color-forest-700);
}

/* Status select (dropdown badge) */
.status-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: inherit;
  font-family: var(--font-sans);
  padding: 3px 6px;
  border-radius: var(--radius-full);
  min-height: 28px;
}

.badge { padding: 3px 8px; border-radius: var(--radius-full); font-size: 10px; font-weight: 600; }
.badge-detected  { background: var(--color-info-bg); color: var(--color-info); }
.badge-reviewed  { background: var(--color-bone-dark); color: var(--color-ink-secondary); }
.badge-paid      { background: var(--color-success-bg); color: var(--color-success); }
.badge-ignored   { background: var(--color-bone); color: var(--color-ink-ghost); }

/* ─── FILTER BAR ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-divider-light);
  background: var(--color-bone);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-ink-ghost);
  flex-shrink: 0;
}

.filter-sep {
  font-size: 11px;
  color: var(--color-ink-ghost);
}

.filter-input {
  height: 34px;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 12px;
  font-family: var(--font-sans);
  color: var(--color-ink);
  transition: border-color var(--motion-fast);
  min-width: 0;
  flex: 1;
}

.filter-input:focus {
  outline: none;
  border-color: var(--color-forest-500);
}

.filter-input::placeholder { color: var(--color-ink-ghost); }

.filter-input-vendor { min-width: 100%; }
.filter-input-amount { max-width: 70px; flex: 0 1 70px; }
.filter-input-date   { max-width: 130px; flex: 0 1 130px; }

.filter-select {
  height: 34px;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 12px;
  font-family: var(--font-sans);
  color: var(--color-ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  min-width: 0;
}

.filter-select:focus {
  outline: none;
  border-color: var(--color-forest-500);
}

.filter-clear-btn {
  background: transparent;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  color: var(--color-ink-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--motion-fast);
  min-height: 34px;
  font-family: var(--font-sans);
}

.filter-clear-btn:hover {
  border-color: var(--color-forest-500);
  color: var(--color-forest-900);
}

.filter-empty-state {
  padding: 32px 16px;
  text-align: center;
}

.filter-empty-state .empty-icon { font-size: 28px; margin-bottom: 10px; opacity: 0.5; }
.filter-empty-state p { font-size: var(--text-xs); color: var(--color-ink-muted); }
.filter-empty-state a { color: var(--color-forest-500); text-decoration: underline; cursor: pointer; }

/* ─── BULK ACTION BAR (inline) ───────────────────────────────── */
.bulk-bar {
  display: none;
  padding: 10px 14px;
  background: var(--color-forest-900);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.bulk-bar.visible {
  display: flex;
}

.bulk-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.bulk-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-mint-200);
}

.bulk-bar-right {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-bulk {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: var(--color-mint-200);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--motion-fast);
  min-height: 32px;
  font-family: var(--font-sans);
}

.btn-bulk:hover { background: rgba(255,255,255,0.15); }

.btn-bulk-deselect {
  background: transparent;
  border-color: rgba(255,255,255,0.12);
  color: rgba(167,243,208,0.6);
}

.btn-bulk-send {
  background: var(--color-mint-300) !important;
  color: var(--color-forest-900) !important;
  border-color: transparent !important;
  font-weight: 700;
}

/* ─── STICKY FORWARD TOOLBAR (bottom) ────────────────────────── */
.bulk-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--color-forest-900);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -4px 20px rgba(14,59,46,0.2);
}

.bulk-toolbar.visible {
  transform: translateY(0);
}

.bulk-toolbar-count {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-mint-300);
  flex-shrink: 0;
  min-width: 24px;
  text-align: center;
}

.bulk-toolbar-label {
  font-size: 12px;
  color: rgba(167,243,208,0.6);
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-deselect {
  font-size: 11px;
  color: rgba(167,243,208,0.5);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  min-height: 36px;
  font-family: var(--font-sans);
}

.btn-deselect:hover { color: var(--color-mint-200); }

.btn-forward {
  margin-left: auto;
  background: var(--color-mint-300);
  color: var(--color-forest-900);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--motion-fast);
  min-height: 44px;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn-forward:hover { background: var(--color-mint-200); }
.btn-forward:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── TABLE (trusted senders) ────────────────────────────────── */
.sender-table {
  width: 100%;
  border-collapse: collapse;
}

.sender-thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-ghost);
  border-bottom: 1px solid var(--color-divider-light);
  background: var(--color-bone);
  white-space: nowrap;
}

.sender-thead th:last-child { text-align: right; }

.sender-row {
  border-bottom: 1px solid var(--color-divider-light);
  transition: background var(--motion-fast);
}

.sender-row:last-child { border-bottom: none; }
.sender-row:hover { background: var(--color-bone); }

.sender-row td {
  padding: 14px 12px;
  vertical-align: middle;
}

.sender-row td:last-child { text-align: right; }

.sender-domain-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sender-domain-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(45,138,98,0.08);
  border: 1px solid rgba(45,138,98,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-forest-700);
}

.sender-domain {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-forest-900);
}

.sender-display-name {
  font-size: 11px;
  color: var(--color-ink-muted);
  margin-top: 1px;
}

/* Status toggle */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-label {
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  white-space: nowrap;
}

.toggle {
  position: relative;
  width: 40px;
  height: 24px;
  background: var(--color-divider);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--motion-fast);
  border: none;
  outline: none;
  flex-shrink: 0;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
}

.toggle.on { background: var(--color-forest-700); }

.toggle::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--motion-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle.on::after { transform: translateX(16px); }
.toggle:focus-visible { box-shadow: var(--shadow-focus); }

/* Badges */
.badge-active {
  background: var(--color-success-bg);
  color: var(--color-success);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-paused {
  background: var(--color-bone-dark);
  color: var(--color-ink-muted);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

/* Stats cells */
.stat-cell {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-forest-900);
}

.stat-cell-sub {
  font-size: 10px;
  color: var(--color-ink-ghost);
  margin-top: 1px;
}

/* Actions */
.action-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.btn-remove {
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--color-ink-ghost);
  cursor: pointer;
  transition: all var(--motion-fast);
  display: flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}

.btn-remove:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  padding: 40px 16px;
  text-align: center;
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.45;
}

.empty-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(45,138,98,0.07);
  border: 1px solid rgba(45,138,98,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--color-forest-700);
}

.empty-state h3 {
  font-size: var(--text-base);
  color: var(--color-forest-900);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--color-ink-muted);
  font-size: var(--text-xs);
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.65;
}

/* ─── FORMS ──────────────────────────────────────────────────── */
.add-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 140px;
  margin-bottom: 14px;
}

.field:last-child { margin-bottom: 0; }

.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-ink-ghost);
}

.input {
  height: 44px;
  background: var(--color-bone);
  border: 1.5px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: 0 12px;
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
  appearance: none;
  -webkit-appearance: none;
}

.input:focus {
  outline: none;
  border-color: var(--color-forest-500);
  box-shadow: var(--shadow-focus);
  background: var(--color-surface);
}

.input::placeholder { color: var(--color-ink-ghost); }

/* ─── INFO BOX ───────────────────────────────────────────────── */
.info-box {
  background: rgba(45,138,98,0.05);
  border: 1px solid rgba(45,138,98,0.12);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 11px;
  color: var(--color-ink-secondary);
  line-height: 1.7;
}

.info-box strong { color: var(--color-forest-900); }

/* ─── MODAL (Invoice detail) ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(14,59,46,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -8px 40px rgba(14,59,46,0.15);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--color-divider-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}

.modal-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-forest-900);
}

.modal-subtitle {
  font-size: 11px;
  color: var(--color-ink-muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.modal-close {
  background: var(--color-bone);
  border: none;
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--color-ink-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--motion-fast);
}

.modal-close:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.modal-body {
  padding: 16px;
}

.modal-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-field-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-ink-ghost);
  margin-bottom: 4px;
}

.modal-field-value {
  font-size: var(--text-sm);
  color: var(--color-ink);
  font-weight: 500;
}

.modal-field-value.mono {
  font-family: var(--font-mono);
  font-weight: 600;
}

.modal-export-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.btn-export {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  background: var(--color-bone);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  color: var(--color-ink-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--motion-fast);
}

.btn-export:hover {
  border-color: var(--color-forest-500);
  color: var(--color-forest-900);
}

.btn-ignore-sender {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  color: var(--color-ink-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--motion-fast);
  font-family: var(--font-sans);
}

.btn-ignore-sender:hover {
  border-color: rgba(220,38,38,0.3);
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

.btn-ignore-sender:disabled { opacity: 0.4; cursor: not-allowed; }

.modal-raw-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-ink-ghost);
  margin: 20px 0 8px;
}

.modal-raw-text {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--color-bone);
  border: 1px solid var(--color-divider-light);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--color-ink-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.6;
}

/* ─── CONFIRM DIALOG ─────────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(14,59,46,0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.confirm-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.confirm-box {
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -8px 40px rgba(14,59,46,0.15);
  width: 100%;
  max-width: 440px;
  padding: 24px 20px calc(20px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1);
}

.confirm-overlay.open .confirm-box {
  transform: translateY(0);
}

.confirm-box h3 {
  font-size: var(--text-base);
  margin-bottom: 10px;
  color: var(--color-forest-900);
}

.confirm-box p {
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  flex-direction: column-reverse;
}

.confirm-actions .btn {
  width: 100%;
  justify-content: center;
  min-height: 44px;
}

/* ─── TOAST ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--color-forest-900);
  color: var(--color-mint-200);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16,1,0.3,1);
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* Support both class names used across pages */
.toast.visible,
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--color-danger);
  color: #fff;
}

/* ─── TRUST PROMPT ───────────────────────────────────────────── */
.trust-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 250;
  background: var(--color-surface);
  border-top: 2px solid var(--color-forest-500);
  padding: 16px 16px calc(16px + var(--safe-bottom));
  box-shadow: 0 -4px 20px rgba(14,59,46,0.12);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.trust-prompt.visible {
  transform: translateY(0);
}

.trust-prompt-icon {
  width: 36px;
  height: 36px;
  background: rgba(45,138,98,0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-forest-700);
  flex-shrink: 0;
}

.trust-prompt-body { flex: 1; min-width: 0; }

.trust-prompt-text {
  font-size: var(--text-sm);
  color: var(--color-ink);
  margin-bottom: 10px;
  line-height: 1.5;
}

.trust-prompt-actions {
  display: flex;
  gap: 8px;
}

.btn-trust-yes {
  background: var(--color-forest-900);
  color: var(--color-mint-300);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  min-height: 36px;
  font-family: var(--font-sans);
  transition: background var(--motion-fast);
}

.btn-trust-yes:hover { background: var(--color-forest-800); }

.btn-trust-no {
  background: transparent;
  color: var(--color-ink-muted);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
  font-family: var(--font-sans);
  transition: all var(--motion-fast);
}

.btn-trust-no:hover {
  border-color: var(--color-ink-muted);
  color: var(--color-ink);
}

/* ─── ONBOARDING OVERLAY ─────────────────────────────────────── */
.aha-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(14,59,46,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.aha-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.aha-inner {
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.aha-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-mint-300);
  margin-bottom: 20px;
}

.aha-headline {
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  color: var(--color-surface);
  margin-bottom: 28px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.aha-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 32px;
}

.aha-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.aha-stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-mint-300);
  line-height: 1;
  letter-spacing: -0.03em;
}

.aha-stat-value.counting {
  animation: counter-pop 0.3s ease;
}

@keyframes counter-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.aha-stat-label {
  font-size: 11px;
  color: rgba(167,243,208,0.5);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.aha-cta {
  background: var(--color-mint-300);
  color: var(--color-forest-900);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 28px;
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--motion-fast);
  min-height: 48px;
  font-family: var(--font-sans);
}

.aha-cta:hover { background: var(--color-mint-200); }

.aha-cta-arrow {
  display: inline-block;
  margin-left: 4px;
  transition: transform var(--motion-fast);
}

.aha-cta:hover .aha-cta-arrow { transform: translateX(3px); }

/* Zero-result state */
.aha-zero { display: none; }

.aha-inner.aha-zero-active .aha-headline,
.aha-inner.aha-zero-active .aha-stats,
.aha-inner.aha-zero-active .aha-cta {
  display: none;
}

.aha-inner.aha-zero-active .aha-zero {
  display: block;
}

.aha-zero-headline {
  font-size: var(--text-lg);
  color: var(--color-surface);
  margin-bottom: 12px;
}

.aha-zero-body {
  font-size: var(--text-sm);
  color: rgba(167,243,208,0.6);
  line-height: 1.7;
  margin-bottom: 24px;
}

.aha-zero-cta {
  background: rgba(255,255,255,0.12);
  color: var(--color-mint-200);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--motion-fast);
  min-height: 44px;
  font-family: var(--font-sans);
}

.aha-zero-cta:hover {
  background: rgba(255,255,255,0.18);
}

/* ─── UTILITIES ──────────────────────────────────────────────── */
.hidden { display: none !important; }

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

/* Small phones — tighter spacing */
@media (max-width: 375px) {
  .page {
    padding: 12px 10px 80px;
  }

  .app-nav {
    padding: 0 10px;
    height: 52px;
  }

  .stats-row {
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-value {
    font-size: var(--text-lg);
  }

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

  .card-header {
    padding: 12px;
  }

  .card-body {
    padding: 12px;
  }

  .invoice-row {
    padding: 12px 10px;
    gap: 8px;
  }

  .modal-fields {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .page-title {
    font-size: var(--text-base);
  }

  .back-link {
    font-size: var(--text-xs);
    margin-bottom: 16px;
  }
}

/* Mid-size phones (376–430px) — standard mobile */
@media (min-width: 376px) and (max-width: 640px) {
  .page {
    padding: 16px 14px 80px;
  }
}

/* Hide columns on mobile */
@media (max-width: 640px) {
  .sender-thead th.hide-mobile { display: none; }
  .sender-row td.hide-mobile { display: none; }

  .add-form {
    flex-direction: column;
  }

  .field {
    min-width: unset;
    width: 100%;
  }

  .input { width: 100%; }

  .filter-bar {
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
  }

  .filter-group {
    width: 100%;
  }

  .filter-input-vendor {
    min-width: unset;
    width: 100%;
  }

  .filter-input-amount { max-width: none; flex: 1; }
  .filter-input-date { max-width: none; flex: 1; }
  .filter-select { width: 100%; }

  .bulk-bar-right {
    width: 100%;
  }

  .btn-bulk {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  /* Sticky bottom toolbar — mobile adjustments */
  .bulk-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px calc(10px + var(--safe-bottom));
    align-items: flex-end;
  }
  .bulk-toolbar-count {
    font-size: var(--text-base);
    flex-shrink: 0;
  }
  .bulk-toolbar-label {
    font-size: 11px;
    white-space: normal;
    min-width: 30px;
    flex-shrink: 1;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.2;
    align-self: flex-end;
    padding-bottom: 1px;
  }
  .btn-forward {
    font-size: 12px;
    padding: 9px 14px;
    flex-shrink: 0;
    margin-left: 0;
    order: 1;
  }

  /* Toast — centered and wider on mobile */
  .toast {
    left: 16px;
    right: 16px;
    transform: translateY(80px);
    max-width: none;
  }

  .toast.visible,
  .toast.show {
    transform: translateY(0);
  }
}

/* Tablet and up — switch to desktop layout */
@media (min-width: 768px) {
  .page {
    padding: 28px 24px 72px;
  }

  .app-nav {
    height: 60px;
    padding: 0 20px;
    gap: 12px;
  }

  .app-logo-text { display: block; }
  .nav-user-label { display: block; }

  .btn {
    font-size: var(--text-xs);
    padding: 8px 16px;
    min-height: 40px;
  }

  .btn-forest {
    font-size: var(--text-xs);
    padding: 7px 14px;
  }

  .page-title { font-size: var(--text-xl); }
  .page-subtitle { font-size: var(--text-sm); margin-bottom: 28px; }

  .card { margin-bottom: 20px; }
  .card-header { padding: 18px 20px; }
  .card-header h2 { font-size: var(--text-base); }
  .card-body { padding: 20px; }

  .stats-row {
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 24px;
  }

  .stats-row .stat-card:nth-child(5) {
    grid-column: auto;
  }

  .stat-card { padding: 16px; }

  .two-col {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
  }

  .sidebar-section { padding: 18px 16px; }

  .invoice-table-head {
    display: grid;
    grid-template-columns: 36px 1fr auto auto auto;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--color-divider-light);
    background: var(--color-bone);
    align-items: center;
  }

  .invoice-row {
    grid-template-columns: 36px 1fr auto auto auto;
    padding: 14px 20px;
    gap: 12px;
  }

  .invoice-meta { display: block; text-align: right; }
  .invoice-subject { display: block; }

  .sender-row td { padding: 14px 14px; }
  .sender-thead th { padding: 10px 14px; }

  .confirm-overlay {
    align-items: center;
    padding: 20px;
  }

  .confirm-box {
    border-radius: var(--radius-lg);
    max-width: 420px;
    padding: 28px 24px 24px;
  }

  .confirm-actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .confirm-actions .btn {
    width: auto;
  }

  .modal-overlay {
    align-items: center;
  }

  .modal {
    border-radius: var(--radius-xl);
    max-height: 80vh;
  }

  .modal-fields {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .modal-subtitle {
    max-width: none;
  }

  .toast {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(80px);
    max-width: 320px;
  }

  .toast.visible,
  .toast.show {
    transform: translateX(-50%) translateY(0);
  }
}

/* Large desktop */
@media (min-width: 1024px) {
  .app-nav {
    padding: 0 24px;
  }

  .app-nav-right { gap: 10px; }

  .stats-row { gap: 14px; }
  .stat-card { padding: 18px 16px; }
  .stat-value { font-size: var(--text-xl); }
}

/* ─── ONBOARDING TOUR ─────────────────────────────────────────── */
/* Dimmed overlay that covers the entire viewport */
.tour-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  /* The cutout is applied via clip-path on the highlight element */
}

/* Dark overlay — four rectangles masking everything outside the spotlight */
.tour-mask-top,
.tour-mask-bottom,
.tour-mask-left,
.tour-mask-right {
  position: fixed;
  z-index: 9000;
  background: rgba(14, 59, 46, 0.72);
  pointer-events: all;
  transition: all 240ms ease;
}

/* Spotlight border ring */
.tour-highlight-ring {
  position: fixed;
  z-index: 9001;
  border: 2px solid var(--color-mint-300);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.18);
  pointer-events: none;
  transition: all 240ms ease;
}

/* Tooltip bubble */
.tour-tooltip {
  position: fixed;
  z-index: 9100;
  background: var(--color-forest-900);
  color: #fff;
  border-radius: 12px;
  padding: 18px 20px 16px;
  max-width: min(340px, calc(100vw - 32px));
  box-shadow: var(--shadow-xl);
  font-family: var(--font-sans);
  transition: all 240ms ease;
  pointer-events: all;
}

.tour-tooltip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

.tour-step-indicator {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-mint-300);
  opacity: 0.8;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tour-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  min-width: 28px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--motion-fast), background var(--motion-fast);
}
.tour-close-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

.tour-tooltip-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.35;
}

.tour-tooltip-body {
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.8);
  line-height: 1.6;
  margin-bottom: 14px;
}

.tour-tooltip-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tour-btn-next {
  background: var(--color-mint-300);
  color: var(--color-forest-900);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: background var(--motion-fast), transform var(--motion-fast);
  white-space: nowrap;
}
.tour-btn-next:hover { background: var(--color-mint-200); transform: translateY(-1px); }
.tour-btn-next:active { transform: none; }

.tour-btn-skip {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  cursor: pointer;
  padding: 8px 4px;
  min-height: 44px;
  transition: color var(--motion-fast);
}
.tour-btn-skip:hover { color: rgba(255,255,255,0.7); }

/* Step dots */
.tour-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}
.tour-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transition: background var(--motion-fast), width var(--motion-fast);
}
.tour-dot.active {
  background: var(--color-mint-300);
  width: 16px;
  border-radius: 3px;
}

/* Welcome modal (step 1) — centered, mascot style */
.tour-welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 9200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.tour-welcome-box {
  background: var(--color-forest-900);
  border-radius: 20px;
  padding: 32px 28px 28px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  position: relative;
  animation: tour-welcome-in 320ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes tour-welcome-in {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.tour-welcome-mascot {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  background: var(--color-forest-800);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  /* If mascot image available, it's set via inline style */
}

.tour-welcome-mascot img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.tour-welcome-title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: #fff;
  margin-bottom: 10px;
  line-height: 1.25;
}

.tour-welcome-sub {
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.72);
  line-height: 1.65;
  margin-bottom: 24px;
}

.tour-welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tour-welcome-start {
  background: var(--color-mint-300);
  color: var(--color-forest-900);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-size: var(--text-base);
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  min-height: 52px;
  transition: background var(--motion-fast), transform var(--motion-fast);
}
.tour-welcome-start:hover { background: var(--color-mint-200); transform: translateY(-1px); }

.tour-welcome-skip {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  cursor: pointer;
  padding: 8px;
  min-height: 44px;
  transition: color var(--motion-fast);
}
.tour-welcome-skip:hover { color: rgba(255,255,255,0.65); }

/* Finish step */
.tour-finish-modal {
  position: fixed;
  inset: 0;
  z-index: 9200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.tour-finish-box {
  background: var(--color-forest-900);
  border-radius: 20px;
  padding: 32px 28px 28px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: tour-welcome-in 320ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.tour-finish-emoji {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

.tour-finish-title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: #fff;
  margin-bottom: 10px;
}

.tour-finish-sub {
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.72);
  line-height: 1.65;
  margin-bottom: 24px;
}

.tour-finish-cta {
  display: block;
  background: var(--color-mint-300);
  color: var(--color-forest-900);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-size: var(--text-base);
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  min-height: 52px;
  width: 100%;
  text-decoration: none;
  text-align: center;
  transition: background var(--motion-fast);
  margin-bottom: 10px;
}
.tour-finish-cta:hover { background: var(--color-mint-200); }

.tour-finish-later {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  cursor: pointer;
  padding: 8px;
  min-height: 44px;
  transition: color var(--motion-fast);
}
.tour-finish-later:hover { color: rgba(255,255,255,0.65); }

/* Arrow caret on tooltips */
.tour-tooltip::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--color-forest-900);
  transform: rotate(45deg);
}
.tour-tooltip.arrow-top::before    { top: -5px; left: 20px; }
.tour-tooltip.arrow-bottom::before { bottom: -5px; left: 20px; }
.tour-tooltip.arrow-left::before   { left: -5px; top: 20px; }
.tour-tooltip.arrow-right::before  { right: -5px; top: 20px; }

/* Mobile overrides */
@media (max-width: 640px) {
  .tour-tooltip {
    max-width: calc(100vw - 24px);
    padding: 16px 16px 14px;
  }
  .tour-welcome-box,
  .tour-finish-box {
    padding: 28px 20px 22px;
  }
  .tour-welcome-title,
  .tour-finish-title { font-size: var(--text-lg); }
}

/* ====================================================
   MULTI-INBOX: TABS + BADGE
   ==================================================== */

/* Inbox tab strip — shown only when user has >1 inbox */
.inbox-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--color-divider);
}
.inbox-tabs::-webkit-scrollbar { display: none; }

.inbox-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-ink-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
  transition: color 120ms, border-color 120ms;
  margin-bottom: -1px;
}
.inbox-tab:hover { color: var(--color-ink); }
.inbox-tab.active {
  color: var(--color-forest-900);
  border-bottom-color: var(--color-forest-700);
}

/* Inbox source badge on each invoice row */
.inbox-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--color-bone);
  color: var(--color-ink-muted);
  border: 1px solid var(--color-divider);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

@media (max-width: 640px) {
  .inbox-tab { font-size: 11px; padding: 6px 10px; }
  .inbox-badge { max-width: 100px; }
}
