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

:root {
  --bg: #070b14;
  --surface: #0d1117;
  --surface-2: #161b22;
  --border: #21262d;
  --text: #e6edf3;
  --text-muted: #7d8590;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --blue: #58a6ff;
  --purple: #bc8cff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Outfit', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

.upload-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
}

.upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px;
  max-width: 520px;
  width: 100%;
}

.upload-card h1 { font-size: 24px; font-weight: 600; margin-bottom: 8px; }
.upload-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }

.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500; color: var(--text-muted);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.form-group input[type="text"] {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; color: var(--text);
  font-family: inherit; font-size: 14px; outline: none;
}
.form-group input[type="text"]:focus { border-color: var(--accent); }

.dropzone {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: rgba(88, 166, 255, 0.05); }
.dropzone .icon { font-size: 36px; margin-bottom: 12px; }
.dropzone .label { font-size: 14px; color: var(--text-muted); }
.dropzone .filename { font-size: 14px; color: var(--green); margin-top: 8px; font-family: 'JetBrains Mono', monospace; }

.btn {
  display: inline-block; padding: 12px 28px; border: none; border-radius: 8px;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #000; width: 100%; margin-top: 8px; }
.btn-green { background: var(--green); color: #000; }
.btn-red { background: var(--red); color: #fff; }
.btn-orange { background: var(--orange); color: #000; }
.btn-small { padding: 6px 14px; font-size: 12px; }

.error-msg { color: var(--red); font-size: 13px; margin-top: 12px; }
.loading { color: var(--text-muted); font-size: 13px; margin-top: 12px; }

.recent-reports { max-width: 520px; width: 100%; margin-top: 32px; }
.recent-reports h3 {
  font-size: 14px; color: var(--text-muted); margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.report-link {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 8px; text-decoration: none; color: var(--text);
  transition: border-color 0.2s;
}
.report-link:hover { border-color: var(--accent); }
.report-link.vim-cursor { border-color: var(--accent); }
.report-link .meta { font-size: 12px; color: var(--text-muted); }

.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 0;
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.nav h1 { font-size: 16px; font-weight: 600; }
.stats { display: flex; gap: 20px; font-size: 13px; }
.stat-value { font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.stat-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; }

.progress-bar { width: 100%; height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width 0.3s; }

.filter-bar { display: flex; gap: 8px; padding: 16px 0; flex-wrap: wrap; }
.filter-pill {
  padding: 6px 16px; border: 1px solid var(--border); border-radius: 20px;
  background: transparent; color: var(--text-muted); font-family: inherit;
  font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.filter-pill:hover { border-color: var(--text-muted); }
.filter-pill.active { background: var(--accent); color: #000; border-color: var(--accent); }

.legend { display: flex; gap: 20px; padding: 8px 0 16px; font-size: 12px; color: var(--text-muted); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.group-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0 8px; border-bottom: 1px solid var(--border); margin-top: 24px;
}
.group-header h2 { font-size: 18px; font-weight: 600; }
.group-header .total { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 600; }

.txn-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  margin: 8px 0; overflow: hidden; transition: border-color 0.2s;
  border-left: 4px solid transparent;
}
.txn-card.approved { border-left-color: var(--green); background: rgba(63, 185, 80, 0.04); }
.txn-card.rejected { border-left-color: var(--red); background: rgba(248, 81, 73, 0.04); }
.txn-card.investigating { border-left-color: var(--orange); background: rgba(210, 153, 34, 0.04); }

.txn-main {
  display: grid; grid-template-columns: 28px 120px minmax(0, 1fr) 170px 90px 80px auto;
  align-items: center; padding: 14px 16px; gap: 14px; font-size: 13px;
}
.txn-date { color: var(--text-muted); font-size: 12px; line-height: 1.4; }
.txn-weekday { color: var(--text-muted); font-size: 11px; line-height: 1.4; opacity: 0.75; }
.txn-time { color: var(--text-muted); font-size: 10px; line-height: 1.4; opacity: 0.75; }
.txn-id { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-muted); line-height: 1.4; }
.txn-merchant { font-weight: 500; }
.txn-amount { font-family: 'JetBrains Mono', monospace; font-weight: 600; text-align: right; }
.txn-receipt { text-align: center; font-size: 12px; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 4px; }

.flag-pill { display: inline-block; font-size: 10px; padding: 2px 6px; border-radius: 3px; margin-left: 4px; font-weight: 500; }
.flag-no_receipt { background: var(--red); color: #fff; }
.flag-unreviewed_merchant { background: var(--purple); color: #fff; }
.flag-high_value { background: var(--blue); color: #000; }
.flag-date_mismatch { background: var(--red); color: #fff; }

.tier-label { font-size: 10px; padding: 2px 6px; border-radius: 3px; margin-left: 6px; }
.tier-elevated { background: rgba(210, 153, 34, 0.2); color: var(--orange); }
.tier-high { background: rgba(88, 166, 255, 0.2); color: var(--blue); }

.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.actions .btn { white-space: nowrap; }

.txn-expand { border-top: 1px solid var(--border); padding: 16px; display: none; }
.txn-card.expanded .txn-expand { display: block; }

.notes-thread { margin-bottom: 12px; }
.note-item { padding: 8px 12px; background: var(--surface-2); border-left: 3px solid var(--border); border-radius: 4px; margin-bottom: 8px; }
.note-item .note-time { font-size: 11px; color: var(--text-muted); }
.note-item .note-text { margin-top: 4px; font-size: 13px; }

.note-input { display: flex; gap: 8px; margin-bottom: 12px; }
.note-input textarea {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; color: var(--text); font-family: inherit;
  font-size: 13px; resize: vertical; min-height: 60px; outline: none;
}
.note-input textarea:focus { border-color: var(--accent); }

.sent-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--green); margin-left: 8px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px 20px;
  font-size: 13px; z-index: 1000; transform: translateY(100px); opacity: 0;
  transition: all 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: var(--red); }

/* Receipt thumbnails */
.receipt-thumb {
  width: 40px; height: 40px; object-fit: cover; border-radius: 4px;
  border: 1px solid var(--border); cursor: pointer; transition: border-color 0.2s;
  background: var(--surface-2);
}
.receipt-thumb:hover { border-color: var(--accent); }


/* Lightbox modal */
.receipt-modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0, 0, 0, 0.85); display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.receipt-modal-overlay.visible { opacity: 1; pointer-events: auto; }
/* Lightbox image: always transform-driven from the top-left origin so the
   JS pan/zoom math has one consistent coordinate system. */
.receipt-modal-overlay img {
  position: fixed; top: 0; left: 0;
  max-width: none; max-height: none;
  transform-origin: 0 0; transition: none; will-change: transform;
  border-radius: 8px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  user-select: none; -webkit-user-select: none;
}
.receipt-modal-overlay img.zoomable { cursor: grab; }
.receipt-modal-overlay img.zoomable.dragging { cursor: grabbing; }
.receipt-modal-close {
  position: absolute; top: 16px; right: 24px;
  background: none; border: none; color: #fff; font-size: 28px;
  cursor: pointer; opacity: 0.7; transition: opacity 0.2s;
}
.receipt-modal-close:hover { opacity: 1; }

/* Receipt file upload dropzone */
.receipt-dropzone {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 40px 24px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-top: 16px;
}
.receipt-dropzone:hover, .receipt-dropzone.dragover {
  border-color: var(--accent); background: rgba(88, 166, 255, 0.05);
}
.receipt-dropzone .icon { font-size: 32px; margin-bottom: 10px; }
.receipt-dropzone .label { font-size: 13px; color: var(--text-muted); }
.receipt-dropzone .file-count {
  font-size: 13px; color: var(--green); margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
}

.view-toggle { display: inline-flex; gap: 0; margin: 12px 0 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle-btn { background: transparent; color: var(--text-muted); border: none; padding: 6px 16px; font-family: inherit; font-size: 13px; cursor: pointer; }
.view-toggle-btn.active { background: var(--accent); color: #000; }
.table-empty { padding: 40px; text-align: center; color: var(--text-muted); }
.search-box { display: block; margin: 10px 0 0; width: 280px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; color: var(--text); font-family: inherit; font-size: 13px; outline: none; }
.search-box:focus { border-color: var(--accent); }

.txn-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.txn-table thead th {
  text-align: left; padding: 10px 12px; color: var(--text-muted);
  font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.txn-table th.sortable { cursor: pointer; }
.txn-table th.sortable:hover { color: var(--text); }
.txn-table th.sorted { color: var(--accent); }
.txn-table th.col-actions { width: 1%; }
.txn-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.txn-row { border-left: 3px solid transparent; }
.txn-row td:first-child { border-left: 3px solid transparent; }
.txn-row.approved { background: rgba(63, 185, 80, 0.04); }
.txn-row.rejected { background: rgba(248, 81, 73, 0.04); }
.txn-row.investigating { background: rgba(210, 153, 34, 0.04); }
.txn-row.approved td:first-child { border-left-color: var(--green); }
.txn-row.rejected td:first-child { border-left-color: var(--red); }
.txn-row.investigating td:first-child { border-left-color: var(--orange); }
.txn-table .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.txn-detail-row { display: none; }
.txn-row.expanded + .txn-detail-row { display: table-row; }
.txn-row.expanded + .txn-detail-row .txn-expand { display: block; }

/* Aggregate report modal */
.aggregate-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 2000;
  display: none; justify-content: center; align-items: center;
}
.aggregate-modal-overlay.visible { display: flex; }
.aggregate-modal {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; max-width: 700px; width: 90vw;
  max-height: 90vh; overflow-y: auto;
}

/* ── Vim cursor ─────────────────────────────────────── */
.vim-cursor { outline: 2px solid var(--accent); outline-offset: -2px; }
.txn-row.vim-cursor td { background: rgba(88, 166, 255, 0.10); }
.txn-table th.col-cursor { box-shadow: inset 0 -2px 0 var(--accent); color: var(--text); }

/* ── Vim help overlay ───────────────────────────────── */
.vim-help-overlay { position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; }
.vim-help-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 24px 28px; min-width: 320px; }
.vim-help-card h3 { margin: 0 0 14px; font-size: 16px; }
.vim-help-row { display: flex; justify-content: space-between; gap: 24px; padding: 4px 0; font-size: 13px; }
.vim-help-row kbd { font-family: 'JetBrains Mono', monospace; color: var(--accent); }
.vim-help-foot { margin-top: 14px; font-size: 11px; color: var(--text-muted); text-align: center; }

/* ── Receipt OCR mini-details panel ────────────────── */
.rx-panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 12px; font-size: 13px; }
.rx-muted { color: var(--text-muted); }
.rx-error { color: var(--red); border-color: rgba(248, 81, 73, 0.4); background: rgba(248, 81, 73, 0.08); }
.rx-summary { font-weight: 500; margin-bottom: 8px; }
.rx-table { width: 100%; border-collapse: collapse; }
.rx-table td { padding: 3px 8px 3px 0; vertical-align: top; }
.rx-table td:first-child { color: var(--text-muted); width: 90px; white-space: nowrap; }
.rx-ok { color: var(--green); font-size: 11px; }
.rx-warn { color: var(--orange); font-size: 11px; }
.amt-warn { color: var(--orange); font-size: 12px; cursor: help; }
.ocr-warn { color: var(--red); font-size: 12px; cursor: help; }
.rx-maplink { color: var(--accent); text-decoration: none; font-size: 11px; white-space: nowrap; }
.rx-maplink:hover { text-decoration: underline; }
.rx-address-link { color: var(--accent); text-decoration: underline; }
.rx-address-link:hover { text-decoration: none; }
.rx-raw { margin-top: 8px; }
.rx-raw pre { white-space: pre-wrap; font-size: 11px; color: var(--text-muted); max-height: 160px; overflow:auto; }

/* ── Multi-select ───────────────────────────────────── */
.txn-select { display: flex; align-items: center; justify-content: center; }
.txn-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.col-select { width: 28px; text-align: center; }
.bulk-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; gap: 12px; align-items: center; justify-content: center;
  padding: 12px 16px; background: var(--surface);
  border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
}
