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

:root {
  --teal-900: #134e4a;
  --teal-700: #0f766e;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --teal-100: #ccfbf1;
  --teal-50:  #f0fdf4;
  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;
  --white:    #ffffff;
  --danger:   #dc2626;
  --danger-light: #fee2e2;
  --success:  #16a34a;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow:    0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
  --topbar-h: 64px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--teal-700);
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--shadow);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-h);
  gap: 12px;
  position: relative;
  z-index: 102;
}

/* Logo — right side, reversed order */
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 24px; }
.logo-title { color: var(--white); font-weight: 700; font-size: 17px; line-height: 1.1; text-align: right; }
.logo-sub   { color: var(--teal-100); font-size: 11px; font-weight: 500; text-align: right; }

/* Hamburger button */
.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.12); }
.hamburger-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.2s;
  transform-origin: center;
}
.hamburger-btn.open .hamburger-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open .hamburger-bar:nth-child(2) { opacity: 0; }
.hamburger-btn.open .hamburger-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Dropdown menu panel */
.hamburger-menu {
  position: absolute;
  top: calc(var(--topbar-h) + env(safe-area-inset-top));
  left: 0;
  right: 0;
  background: var(--teal-900);
  z-index: 101;
  padding: 8px 0 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1), opacity 0.18s ease;
}
.hamburger-menu.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Nav links inside dropdown */
.hamburger-nav {
  display: flex;
  flex-direction: column;
  padding: 0 12px;
  gap: 2px;
}
.hamburger-tab-btn {
  background: transparent;
  border: none;
  color: var(--teal-100);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.01em;
}
.hamburger-tab-btn:hover  { background: rgba(255,255,255,0.08); color: var(--white); }
.hamburger-tab-btn.active { background: rgba(255,255,255,0.15); color: var(--white); }

/* User row at bottom of menu */
.hamburger-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px 4px;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 8px;
  gap: 12px;
}
.hamburger-user-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Backdrop */
.hamburger-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: transparent;
}
.hamburger-backdrop.open { display: block; }

/* Keep old tab-nav classes for JS compatibility — hide visually */
.tab-nav { display: none; }
.tab-btn { display: none; }

/* ── Date confirmation banner ── */
.date-confirm-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.date-confirm-banner.hidden { display: none; }
.date-confirm-icon { font-size: 22px; flex-shrink: 0; }
.date-confirm-body { flex: 1; }
.date-confirm-msg {
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  margin: 0 0 8px;
}
.date-confirm-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.date-confirm-btn {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid #f59e0b;
  background: var(--white);
  color: #92400e;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.date-confirm-btn.active {
  background: #f59e0b;
  color: var(--white);
  border-color: #f59e0b;
}
.date-confirm-btn:hover:not(.active) { background: #fef3c7; }
/* ── Analytics Dashboard ── */
.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
  gap: 12px;
}
.analytics-user-filter {
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  background: var(--white);
  color: var(--gray-700);
  cursor: pointer;
  max-width: 160px;
}
.analytics-period-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.analytics-period-btn {
  flex: 1;
  padding: 9px 6px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  background: var(--white);
  color: var(--gray-600);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.analytics-period-btn.active {
  background: var(--teal-700);
  color: var(--white);
  border-color: var(--teal-700);
}
.analytics-period-btn:hover:not(.active) {
  background: var(--teal-50);
  border-color: var(--teal-300);
}
.analytics-loading {
  text-align: center;
  color: var(--gray-500);
  font-size: 14px;
  padding: 32px 0;
}
.analytics-error {
  background: #fef2f2;
  color: #dc2626;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 12px;
}
.analytics-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.summary-card {
  background: var(--white);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid var(--gray-100);
}
.summary-card-wide { grid-column: 1 / -1; }
.summary-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.summary-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--teal-700);
  line-height: 1.1;
}
.summary-sub { font-size: 12px; color: var(--gray-500); margin-top: 3px; }
.analytics-charts-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}
.analytics-chart-card { padding: 16px; }
.analytics-full-width { margin-bottom: 14px; }
.analytics-chart-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.analytics-donut-wrap { max-width: 280px; margin: 0 auto 16px; }
.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  justify-content: center;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--gray-600);
}
.donut-legend-clickable {
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: background 0.12s;
}
.donut-legend-clickable:hover {
  background: var(--teal-50);
  color: var(--teal-700);
}
.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.top-spenders-list { display: flex; flex-direction: column; gap: 8px; }
.spender-row { display: flex; align-items: center; gap: 10px; }
.spender-rank {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-400);
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.spender-bar-wrap {
  flex: 1;
  background: var(--gray-100);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
}
.spender-bar {
  height: 100%;
  background: var(--teal-600);
  border-radius: 6px;
}
.spender-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}
.spender-total {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal-700);
  white-space: nowrap;
  flex-shrink: 0;
}
.cat-month-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cat-month-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
.cat-month-table th {
  background: var(--teal-700);
  color: var(--white);
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
}
.cat-month-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}
.cat-month-table tr:nth-child(even) td { background: var(--teal-50); }
.cat-month-table td:not(:first-child) { text-align: right; font-weight: 600; color: var(--teal-700); }
.cat-month-total td { background: var(--teal-50) !important; font-weight: 700; border-top: 2px solid var(--teal-300); }

.cat-month-cell-btn {
  background: none; border: none;
  color: var(--teal-700); font-family: var(--font);
  font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 2px 4px; border-radius: 4px;
  text-decoration: underline; text-decoration-style: dotted;
  transition: background 0.12s;
}
.cat-month-cell-btn:hover { background: var(--teal-100); }

/* ── Image Viewer ── */
.img-viewer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.img-viewer {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 680px;
  max-height: 95vh;
  cursor: default;
  pointer-events: auto;
}
.img-viewer-header,
.img-viewer-body,
.img-viewer-footer {
  pointer-events: auto;
}
.img-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  background: rgba(0,0,0,0.7);
  flex-shrink: 0;
}
.img-viewer-title {
  font-size: 15px;
  font-weight: 700;
  color: white;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.img-viewer-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.img-viewer-close:hover { background: rgba(255,255,255,0.3); }
.img-viewer-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0,0,0,0.5);
}
.img-viewer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}
.img-viewer-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0,0,0,0.7);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.img-viewer-rotate-btn {
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.3);
  color: white;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.img-viewer-rotate-btn:hover { background: rgba(255,255,255,0.25); }
.img-viewer-rotate-btn:disabled { opacity: 0.4; cursor: wait; }
.img-viewer-download {
  color: white;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  padding: 8px 18px;
  border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.1);
}
.img-viewer-download:hover { background: rgba(255,255,255,0.2); }

/* ── Category drill-down drawer ── */
.cat-drill-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.35); z-index: 200;
}
.cat-drill-backdrop.open { display: block; }
.cat-drill-drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-height: 75vh; background: var(--white);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.15);
  z-index: 201; display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}
.cat-drill-drawer.open { transform: translateY(0); }
.cat-drill-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--gray-100); flex-shrink: 0;
}
.cat-drill-title { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.cat-drill-close {
  background: var(--gray-100); border: none; border-radius: 50%;
  width: 30px; height: 30px; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600); flex-shrink: 0;
}
.cat-drill-close:hover { background: var(--gray-200); }
.cat-drill-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 0;
}
.cat-drill-loading {
  text-align: center; color: var(--gray-500); font-size: 14px; padding: 24px;
}
.cat-drill-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid var(--gray-50); gap: 12px;
}
.cat-drill-row:last-child { border-bottom: none; }
.cat-drill-row-main { flex: 1; min-width: 0; }
.cat-drill-vendor {
  font-size: 14px; font-weight: 600; color: var(--gray-900);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-drill-meta {
  font-size: 12px; color: var(--gray-500); margin-top: 2px;
  display: flex; gap: 4px;
}
.cat-drill-row-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.cat-drill-total { font-size: 14px; font-weight: 700; color: var(--teal-700); }
.cat-drill-edit-btn {
  background: var(--gray-100); border: none; border-radius: 8px;
  padding: 5px 8px; font-size: 13px; cursor: pointer; transition: background 0.12s;
}
.cat-drill-edit-btn:hover { background: var(--teal-100); }
.cat-drill-footer {
  padding: 12px 20px; border-top: 1px solid var(--gray-100);
  font-size: 13px; font-weight: 600; color: var(--gray-600);
  text-align: center; flex-shrink: 0;
}
@media (min-width: 700px) {
  .cat-drill-drawer {
    left: 50%; right: auto; width: 540px;
    transform: translateX(-50%) translateY(100%);
    border-radius: 20px 20px 0 0;
  }
  .cat-drill-drawer.open { transform: translateX(-50%) translateY(0); }
}
@media (min-width: 700px) {
  .analytics-summary { grid-template-columns: 1fr 1fr 1.5fr; }
  .summary-card-wide { grid-column: auto; }
  .analytics-charts-row { flex-direction: row; }
  .analytics-chart-card { flex: 1; min-width: 0; }
  .analytics-donut-wrap { max-width: 320px; }
}

.main-content {
  max-width: 540px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* ── Tabs ── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Upload Area ── */
/* ── Scan Tab ── */
.scan-hero {
  text-align: center;
  padding: 24px 0 16px;
}
.scan-hero-icon { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.scan-hero-title {
  font-size: 22px; font-weight: 700; color: var(--gray-900);
  margin: 0 0 6px;
}
.scan-hero-sub {
  font-size: 13px; color: var(--gray-500); margin: 0;
  max-width: 280px; margin: 0 auto;
  line-height: 1.5;
}

.scan-upload-card {
  background: var(--white);
  border: 2px dashed var(--teal-400);
  border-radius: 20px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
  transition: border-color 0.2s, background 0.2s;
}
.scan-upload-card.drag-over {
  border-color: var(--teal-700);
  background: var(--teal-50);
}

.scan-upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px 24px;
  text-align: center;
}
.scan-upload-icon { font-size: 44px; line-height: 1; margin-bottom: 4px; }
.scan-upload-label { font-size: 16px; font-weight: 700; color: var(--gray-800); margin: 0; }
.scan-upload-hint  { font-size: 13px; color: var(--gray-400); margin: 0; }

.scan-upload-buttons {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.scan-btn-camera,
.scan-btn-gallery {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: 50px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  position: relative;
}
.scan-btn-camera:active, .scan-btn-gallery:active { transform: scale(0.97); }
.scan-btn-camera {
  background: var(--teal-700);
  color: var(--white);
}
.scan-btn-camera:hover { background: var(--teal-900); }
.scan-btn-gallery {
  background: var(--teal-50);
  color: var(--teal-700);
  border: 2px solid var(--teal-200);
}
.scan-btn-gallery:hover { background: var(--teal-100); }

.scan-purpose-wrap {
  margin-bottom: 14px;
}
.scan-purpose-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}
.scan-purpose-optional { font-weight: 400; color: var(--gray-400); }
.scan-purpose-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-900);
  background: var(--white);
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.scan-purpose-input:focus {
  outline: none;
  border-color: var(--teal-500);
}
.scan-purpose-input::placeholder { color: var(--gray-400); }
.scan-purpose-required { color: #d97706; font-weight: 600; }
.purpose-warning {
  font-size: 12px;
  color: #d97706;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 7px 10px;
  margin-top: 6px;
}

/* Duplicate banner */
.duplicate-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fef3c7;
  border: 1.5px solid #f59e0b;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}
.duplicate-icon { font-size: 22px; flex-shrink: 0; }
.duplicate-body { flex: 1; }
.duplicate-title { font-size: 14px; font-weight: 700; color: #92400e; margin-bottom: 4px; }
.duplicate-detail { font-size: 13px; color: #78350f; margin-bottom: 10px; line-height: 1.4; }
.duplicate-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.duplicate-btn-keep {
  padding: 7px 14px; border-radius: 20px; border: 1.5px solid #f59e0b;
  background: white; color: #92400e; font-family: var(--font);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.duplicate-btn-keep:hover { background: #fef9c3; }
.duplicate-btn-delete {
  padding: 7px 14px; border-radius: 20px; border: none;
  background: #f59e0b; color: white; font-family: var(--font);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.duplicate-btn-delete:hover { background: #d97706; }

.scan-submit-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: var(--teal-700);
  color: var(--white);
  border: none;
  border-radius: 14px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 16px;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  letter-spacing: 0.01em;
}
.scan-submit-btn:hover:not(:disabled) { background: var(--teal-900); }
.scan-submit-btn:active:not(:disabled) { transform: scale(0.99); }
.scan-submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* keep old classes working for drag-over JS */
.upload-area { display: none; }
.upload-icon, .upload-title, .upload-hint, .upload-buttons { display: none; }
.purpose-wrap { display: none; }
.purpose-label, .purpose-input { display: none; }

#preview-wrap {
  width: 100%; height: 100%;
  position: relative;
  min-height: 240px;
}
#preview-img {
  width: 100%; height: 100%;
  object-fit: contain;
  max-height: 320px;
  display: block;
}
.clear-btn {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(0,0,0,0.55);
  color: var(--white);
  border: none;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, opacity 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-primary  { background: var(--teal-700); color: var(--white); border-color: var(--teal-700); }
.btn-primary:hover { background: var(--teal-900); border-color: var(--teal-900); }
.btn-outline  { background: var(--white); color: var(--teal-700); border-color: var(--teal-700); }
.btn-outline:hover { background: var(--teal-50); }
.btn-danger   { background: var(--danger); color: #ffffff; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.85; }
.btn-full { width: 100%; }
.btn-large { padding: 14px 20px; font-size: 16px; border-radius: var(--radius); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* Filled-red button — used for destructive admin actions (Deactivate, Delete).
   Avoids the .btn-danger / .btn-outline combo whose downstream !important rule
   forces red text on a red background. */
.btn-solid-danger {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}
.btn-solid-danger:hover {
  filter: brightness(0.92);
}

.hidden-input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0; overflow: hidden;
}

/* ── Spinner ── */
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

/* ── Result card ── */
.result-card { border-left: 4px solid var(--teal-600); }
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 12px;
}
.result-vendor { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.result-date   { font-size: 13px; color: var(--gray-500); margin-top: 2px; }
.result-total  {
  font-size: 22px; font-weight: 700;
  color: var(--teal-700);
  white-space: nowrap;
}
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.result-item { display: flex; flex-direction: column; gap: 2px; }
.result-label { font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; }
.result-value { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.result-summary {
  font-size: 13px; color: var(--gray-700);
  background: var(--teal-50);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.result-notes-wrap { font-size: 13px; color: var(--gray-500); margin-bottom: 10px; }
.result-image-link { font-size: 13px; color: var(--teal-600); font-weight: 600; text-decoration: none; }
.result-image-link:hover { text-decoration: underline; }
.result-rotate-btn {
  background: none; border: none; color: var(--teal-600);
  font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 0;
  text-decoration: underline; text-decoration-style: dotted;
}
.result-rotate-btn:hover { color: var(--teal-900); }
.result-rotate-btn:disabled { opacity: 0.5; cursor: wait; }
.receipt-row-rotate-btn {
  background: none; border: none; color: var(--teal-600);
  font-family: var(--font); font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 0;
  text-decoration: underline; text-decoration-style: dotted;
}
.receipt-row-rotate-btn:hover { color: var(--teal-900); }
.receipt-row-rotate-btn:disabled { opacity: 0.5; cursor: wait; }

/* ── Error card ── */
.error-card {
  border-left: 4px solid var(--danger);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.error-icon { font-size: 20px; }
#error-message { font-size: 14px; color: var(--danger); font-weight: 500; padding-top: 2px; }

/* ── History ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.section-title { font-size: 20px; font-weight: 700; }
.section-desc  { font-size: 14px; color: var(--gray-500); margin-bottom: 20px; line-height: 1.5; }

.status-msg {
  font-size: 13px;
  color: var(--gray-500);
  text-align: center;
  padding: 8px;
  margin-bottom: 8px;
}

.receipt-list { display: flex; flex-direction: column; gap: 10px; }

.receipt-row {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.receipt-row-left { flex: 1; min-width: 0; }
.receipt-row-vendor { font-size: 15px; font-weight: 700; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.receipt-row-meta { display: flex; gap: 8px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.receipt-row-date { font-size: 12px; color: var(--gray-500); }
.receipt-row-cat {
  font-size: 11px; font-weight: 600;
  background: var(--teal-100);
  color: var(--teal-900);
  border-radius: 20px;
  padding: 2px 8px;
}
.receipt-row-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.receipt-row-total { font-size: 16px; font-weight: 700; color: var(--teal-700); }
.delete-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s;
  padding: 4px;
  line-height: 1;
}
.delete-btn:hover { opacity: 1; }
.receipt-row-tip {
  font-size: 11px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  border-radius: 20px;
  padding: 2px 8px;
}
.conf-badge {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--gray-500);
}
.receipt-row-imglink {
  display: inline-block;
  margin-top: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--teal-600);
  text-decoration: none;
}
.receipt-row-imglink:hover { text-decoration: underline; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-500);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Reports ── */
.report-cards { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.report-card { display: flex; flex-direction: column; gap: 12px; }
.report-icon { font-size: 32px; }
.report-name { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.report-desc { font-size: 13px; color: var(--gray-500); margin-top: 3px; line-height: 1.5; }

.stats-card { }
.stats-loading { color: var(--gray-500); font-size: 14px; text-align: center; padding: 16px; }
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.stat-item { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 20px; font-weight: 700; color: var(--teal-700); }
.stat-divider {
  grid-column: 1/-1;
  border: none;
  border-top: 1px solid var(--gray-100);
  margin: 2px 0;
}
.stats-title { font-size: 13px; font-weight: 700; color: var(--gray-700); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.modal-body  { font-size: 14px; color: var(--gray-500); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

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

/* ── Responsive ── */
@media (min-width: 480px) {
  .result-grid { grid-template-columns: repeat(4, 1fr); }
  .stats-grid  { grid-template-columns: repeat(4, 1fr); }
}

/* ── Purpose field ── */
.purpose-wrap {
  margin-bottom: 12px;
}
.purpose-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.purpose-optional {
  font-weight: 400;
  color: var(--gray-500);
}
.purpose-input {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
}
.purpose-input:focus {
  border-color: var(--teal-500);
}
.purpose-input::placeholder {
  color: var(--gray-500);
}
.result-purpose {
  font-size: 14px;
  font-weight: 600;
  color: var(--teal-700);
  background: var(--teal-50);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 8px;
}
.receipt-row-purpose {
  font-size: 12px;
  color: var(--teal-700);
  font-weight: 500;
  margin-top: 2px;
}

/* ── PDF Preview ── */
.pdf-preview-label {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 24px;
  width: 100%;
  min-height: 200px;
}
.pdf-icon { font-size: 56px; line-height: 1; }
.pdf-name { font-size: 14px; font-weight: 600; color: var(--gray-900); text-align: center; word-break: break-all; }
.pdf-size { font-size: 12px; color: var(--gray-500); }

/* ── Receipt file links ── */
.receipt-row-links {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}
.receipt-row-link-sep {
  color: var(--gray-300);
  font-size: 12px;
}
.result-file-links {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

/* ── History filter bar ── */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-search {
  position: relative;
}

.filter-search-input {
  width: 100%;
  padding-right: 36px;
}

.filter-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--gray-500);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  font-family: var(--font);
}
.filter-clear:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.filter-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
}

.filter-input {
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 12px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-900);
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  transition: border-color 0.15s;
  outline: none;
}

.filter-input:focus {
  border-color: var(--teal-500);
}

select.filter-input {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3e%3cpath fill='%236b7280' d='M6 8L0 0h12z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

input[type="date"].filter-input {
  font-family: var(--font);
  color: var(--gray-900);
}

.filter-reset {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--teal-700);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: underline;
}
.filter-reset:hover {
  color: var(--teal-900);
}

@media (max-width: 480px) {
  .filter-row {
    grid-template-columns: 1fr 1fr;
  }
  .filter-row select.filter-input {
    grid-column: 1 / -1;
  }
}

/* ── Edit receipt button ── */
.edit-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s;
  padding: 4px;
  line-height: 1;
}
.edit-btn:hover { opacity: 1; }

/* ── Edit modal ── */
.modal-edit {
  max-width: 480px;
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.edit-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.edit-input {
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 12px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-900);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

.edit-input:focus {
  border-color: var(--teal-500);
}

textarea.edit-input {
  resize: vertical;
  min-height: 60px;
  font-family: var(--font);
}

select.edit-input {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3e%3cpath fill='%236b7280' d='M6 8L0 0h12z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.edit-amounts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (min-width: 480px) {
  .edit-amounts {
    grid-template-columns: repeat(4, 1fr);
  }
}

.edit-warning {
  background: #fef3c7;
  border-left: 3px solid #d97706;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  gap: 10px;
  font-size: 13px;
  color: #92400e;
  line-height: 1.4;
}
.edit-warning-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.edit-error {
  background: var(--danger-light);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--danger);
  font-weight: 500;
}

/* ── Report date range bar ── */
.report-range-bar {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.report-range-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.report-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.report-range-inputs .filter-input {
  flex: 1;
  min-width: 130px;
}

.report-range-sep {
  font-size: 13px;
  color: var(--gray-500);
  flex-shrink: 0;
}

.export-range-status {
  font-size: 12px;
  color: var(--teal-700);
  font-weight: 500;
  min-height: 16px;
}

/* ── PIN / Login screen ── */
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
#pin-screen {
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--gray-50);
}
.login-logo  { font-size: 40px; margin-bottom: 8px; line-height: 1; }
.login-title { font-size: 22px; font-weight: 700; color: var(--gray-900); margin-bottom: 4px; }
.login-sub   { font-size: 13px; color: var(--gray-500); margin-bottom: 28px; line-height: 1.5; }
.login-label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.05em;
  text-align: left; margin-bottom: 6px;
}
.login-input {
  width: 100%; padding: 13px 16px;
  border: 2px solid var(--gray-300); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 16px; color: var(--gray-900);
  background: var(--white); outline: none; transition: border-color 0.15s;
  letter-spacing: 0.12em; margin-bottom: 14px; display: block;
}
.login-input:focus { border-color: var(--teal-500); }
.login-input.error { border-color: var(--danger); }
.login-error {
  font-size: 13px; color: var(--danger); font-weight: 500;
  margin-bottom: 12px; min-height: 20px; text-align: left;
}
.login-btn {
  width: 100%; padding: 14px;
  background: var(--teal-700); color: var(--white);
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 16px; font-weight: 700;
  cursor: pointer; transition: background 0.15s;
}
.login-btn:hover    { background: var(--teal-900); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-hint {
  font-size: 12px; color: var(--gray-500); margin-top: 16px; line-height: 1.5;
}

/* ── Remember me checkbox ── */
.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-500);
  cursor: pointer;
  margin-bottom: 14px;
  text-align: left;
  user-select: none;
}
.remember-check {
  width: 16px;
  height: 16px;
  accent-color: var(--teal-700);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── 30-day history toggle ── */
.filter-month-primary {
  font-weight: 600;
  color: var(--teal-700);
  border-color: var(--teal-300);
}
.history-empty-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 24px;
  color: var(--gray-400);
  text-align: center;
}
.history-empty-icon { font-size: 40px; }
.history-empty-text { font-size: 15px; font-weight: 500; color: var(--gray-500); }
.history-search-notice {
  font-size: 12px;
  color: var(--teal-700);
  background: var(--teal-50);
  border-radius: 8px;
  padding: 6px 12px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.history-notice-btn {
  background: none;
  border: none;
  color: var(--teal-700);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* ── Bulk select ── */
.receipt-row-check {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.row-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--teal-700);
  cursor: pointer;
}
.select-all-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--teal-50);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--gray-700);
}
.select-all-bar label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
}

/* ── Bulk action bar (sticky bottom) ── */
.bulk-action-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--teal-700);
  color: var(--white);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 150;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.2);
  transform: translateY(100%);
  transition: transform 0.2s ease;
}
.bulk-action-bar.visible { transform: translateY(0); }
.bulk-count {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.bulk-cat-select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-900);
  background: var(--white);
  outline: none;
}
.bulk-apply-btn {
  background: var(--white);
  color: var(--teal-700);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.bulk-apply-btn:hover { background: var(--teal-100); }
.bulk-clear-btn {
  background: rgba(255,255,255,0.15);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.bulk-clear-btn:hover { background: rgba(255,255,255,0.25); }

/* ── Settings tab ── */
.settings-section {
  margin-bottom: 24px;
}
.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.cat-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  gap: 10px;
}
.cat-row-name { flex: 1; color: var(--gray-900); font-weight: 500; }
.cat-row-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-500);
  border-radius: 20px;
  padding: 2px 8px;
}
.cat-delete-btn {
  background: none;
  border: none;
  color: var(--gray-300);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.cat-delete-btn:hover { color: var(--danger); background: var(--danger-light); }
.cat-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cat-add-input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-900);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
}
.cat-add-input:focus { border-color: var(--teal-500); }
.cat-add-btn {
  padding: 10px 16px;
  background: var(--teal-700);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.cat-add-btn:hover    { background: var(--teal-900); }
.cat-add-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cat-limit-note {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 8px;
}
.cat-error {
  font-size: 13px;
  color: var(--danger);
  font-weight: 500;
  margin-top: 6px;
  min-height: 18px;
}

/* ── Auth modal (forgot PIN / reset flow) ── */
.auth-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.auth-modal-overlay.hidden { display: none; }
.auth-modal {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 28px 24px; width: 100%; max-width: 360px;
  box-shadow: var(--shadow-lg);
}
.auth-modal-title { font-size: 18px; font-weight: 700; color: var(--gray-900); margin-bottom: 6px; }
.auth-modal-sub   { font-size: 13px; color: var(--gray-500); margin-bottom: 20px; line-height: 1.5; }
.auth-modal-label { display:block; font-size:12px; font-weight:700; color:var(--gray-500); text-transform:uppercase; letter-spacing:0.05em; margin-bottom:5px; }
.auth-modal-input {
  width: 100%; padding: 11px 12px; border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm); font-family: var(--font); font-size: 15px;
  color: var(--gray-900); background: var(--white); outline: none;
  transition: border-color 0.15s; margin-bottom: 12px; display: block;
}
.auth-modal-input:focus { border-color: var(--teal-500); }
.auth-modal-input.error { border-color: var(--danger); }
.auth-modal-error { font-size: 13px; color: var(--danger); font-weight: 500; min-height: 18px; margin-bottom: 10px; }
.auth-modal-success { font-size: 13px; color: #16a34a; font-weight: 500; margin-bottom: 10px; }
.auth-modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.auth-modal-actions .btn { flex: 1; }
.forgot-link {
  background: none; border: none; color: var(--teal-700); font-family: var(--font);
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 0;
  text-decoration: underline; margin-top: 10px; display: block; text-align: center;
}
.forgot-link:hover { color: var(--teal-900); }

/* ── Code input (6-digit reset code) ── */
.code-input {
  font-family: var(--font-mono); font-size: 24px; font-weight: 700;
  letter-spacing: 8px; text-align: center;
}

/* ── Settings PIN section ── */
.settings-pin-card {
  margin-bottom: 16px;
}
.settings-pin-row {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px;
}
.settings-pin-label {
  font-size: 12px; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.settings-pin-input {
  padding: 10px 12px; border: 2px solid var(--gray-300); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 15px; color: var(--gray-900);
  background: var(--white); outline: none; transition: border-color 0.15s;
}
.settings-pin-input:focus { border-color: var(--teal-500); }
.settings-divider { border: none; border-top: 1px solid var(--gray-200); margin: 18px 0; }

/* ── Multi-user / Teams additions ── */

/* Topbar user display */
.topbar-user {
  display: none; /* replaced by .hamburger-user */
}
.topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-signout-btn {
  background: rgba(255,255,255,0.15);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 5px 12px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.topbar-signout-btn:hover { background: rgba(255,255,255,0.25); }

/* Scanned by badge in receipt rows */
.receipt-row-scannedby {
  font-size: 11px;
  color: var(--gray-400);
  font-style: italic;
}

/* Team member list */
.team-member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap;
}
.team-member-row:last-child { border-bottom: none; }
.team-member-info {
  flex: 1;
  min-width: 160px;
}
.team-member-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}
.team-member-email {
  display: block;
  font-size: 12px;
  color: var(--gray-500);
}
.team-member-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.team-member-role-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
}
.team-member-role-badge.admin {
  background: var(--teal-50);
  color: var(--teal-700);
}
.team-member-role-badge.bookkeeper {
  background: #eff6ff;
  color: #1d4ed8;
}
.team-member-role-badge.staff {
  background: var(--gray-100);
  color: var(--gray-600);
}
.team-member-pending {
  font-size: 11px;
  color: #d97706;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 20px;
}
.team-member-founder {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #92400e;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 20px;
}
.team-member-role-badge.owner {
  background: #fef3c7;
  color: #92400e;
}
.team-member-inactive {
  font-size: 11px;
  color: #dc2626;
  background: #fee2e2;
  padding: 2px 8px;
  border-radius: 20px;
}
.team-member-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-xs {
  font-size: 11px !important;
  padding: 4px 10px !important;
}
.btn-outline.btn-danger {
  color: #dc2626 !important;
  border-color: #fca5a5 !important;
}
.btn-outline.btn-danger:hover {
  background: #fee2e2 !important;
}

/* Clickable role badge + dropdown */
.role-badge-wrap {
  position: relative;
  display: inline-block;
}
.role-badge-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  background: inherit;
  font-family: inherit;
  transition: filter 0.15s ease, border-color 0.15s ease;
}
.role-badge-btn:hover {
  filter: brightness(0.95);
  border-color: rgba(15, 118, 110, 0.35);
}
.role-badge-btn:focus-visible {
  outline: 2px solid var(--teal-600, #0f766e);
  outline-offset: 1px;
}
.role-badge-chevron {
  font-size: 10px;
  line-height: 1;
  opacity: 0.7;
}
.role-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  min-width: 140px;
  background: #fff;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.role-dropdown-item {
  appearance: none;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-800, #1f2937);
  border-radius: 6px;
  cursor: pointer;
  text-transform: capitalize;
}
.role-dropdown-item:hover,
.role-dropdown-item:focus-visible {
  background: var(--teal-50, #f0fdfa);
  color: var(--teal-700, #0f766e);
  outline: none;
}

/* Role-change confirm modal */
.role-change-confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.role-change-confirm-dialog {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  padding: 20px 22px 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.role-change-confirm-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900, #111827);
  margin-bottom: 8px;
}
.role-change-confirm-body {
  font-size: 14px;
  color: var(--gray-700, #374151);
  line-height: 1.5;
  margin-bottom: 12px;
}
.role-change-confirm-body strong {
  text-transform: capitalize;
  color: var(--gray-900, #111827);
}
.role-change-confirm-error {
  font-size: 12px;
  color: #dc2626;
  min-height: 16px;
  margin-bottom: 8px;
}
.role-change-confirm-error:empty {
  display: none;
}
.role-change-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Team status banner */
.team-status-banner {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  display: none;
}
.team-status-banner.visible {
  display: block;
}
.team-status-banner[data-kind="success"] {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.team-status-banner[data-kind="error"] {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ── Audit Log ── */
.audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 8px;
}
.audit-filters select,
.audit-filters input {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-800);
  flex: 1 1 auto;
  min-width: 120px;
}
.audit-status {
  font-size: 12px;
  color: var(--gray-500);
  padding: 4px 0 8px;
  min-height: 20px;
}
.audit-row {
  display: grid;
  grid-template-columns: 140px 1fr 1fr;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 12px;
  align-items: start;
}
.audit-row:last-child { border-bottom: none; }
.audit-ts {
  color: var(--gray-500);
  white-space: nowrap;
  font-size: 11px;
}
.audit-action {
  font-family: monospace;
  font-size: 11px;
  background: var(--gray-100);
  border-radius: 4px;
  padding: 1px 5px;
  display: inline-block;
  color: var(--gray-700);
  white-space: nowrap;
}
.audit-user {
  font-size: 11px;
  color: var(--gray-600);
  margin-top: 2px;
}
.audit-detail {
  color: var(--gray-700);
  word-break: break-word;
}
.audit-empty {
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
  padding: 32px 0;
}

/* ── Auth switch link (login <-> signup) ── */
.text-center { text-align: center; }
.mt-2 { margin-top: 12px; }
.auth-switch-link {
  font-size: 13px;
  color: var(--gray-500);
  text-decoration: none;
  font-weight: 500;
}
.auth-switch-link:hover {
  color: var(--teal-700);
  text-decoration: underline;
}

/* ── Welcome banner (post-signup) ── */
.welcome-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--teal-50, #f0fdfa);
  border: 1px solid #99f6e4;
  border-left: 4px solid var(--teal-700, #0f766e);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.welcome-banner.hidden { display: none; }
.welcome-banner-icon {
  font-size: 22px;
  line-height: 1;
}
.welcome-banner-body {
  flex: 1;
  min-width: 0;
}
.welcome-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--teal-900, #134e4a);
  margin-bottom: 2px;
}
.welcome-banner-msg {
  font-size: 13px;
  color: var(--gray-700, #374151);
  line-height: 1.4;
}
.welcome-banner-close {
  background: transparent;
  border: 0;
  font-size: 16px;
  color: var(--gray-500, #6b7280);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.welcome-banner-close:hover {
  background: rgba(15, 118, 110, 0.08);
  color: var(--teal-900, #134e4a);
}

/* ── Admin (founder) tab ── */
.admin-status {
  font-size: 13px;
  color: var(--gray-500);
  padding: 8px 0;
  min-height: 22px;
}
.company-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.company-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg, 12px);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
}
.company-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.company-card-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}
.company-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.company-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}
.company-card-meta > * + *::before {
  content: "•";
  color: var(--gray-300);
  margin-right: 10px;
}
.company-card-slug {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--gray-500);
}
.company-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
.company-card-actions-left,
.company-card-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.company-card-actions-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gray-500);
}
.admin-plan-badge,
.admin-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
}
.admin-plan-badge.plan-trial     { background: #fef3c7; color: #92400e; }
.admin-plan-badge.plan-paid      { background: #d1fae5; color: #065f46; }
.admin-plan-badge.plan-suspended { background: #fee2e2; color: #991b1b; }
.admin-status-badge.status-active   { background: #d1fae5; color: #065f46; }
.admin-status-badge.status-inactive { background: var(--gray-100); color: var(--gray-600); }
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.admin-plan-select {
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-800);
}
.admin-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.admin-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--teal-700);
  border-radius: 50%;
  animation: admin-spin 0.7s linear infinite;
  vertical-align: -3px;
  margin-right: 8px;
}
@keyframes admin-spin { to { transform: rotate(360deg); } }
