:root {
  --bg: #0f1117; --surface: #1a1b23; --surface2: #23242e; --border: #2a2b35;
  --text: #e4e4e7; --muted: #71717a; --orange: #f97316; --orange-dim: rgba(249,115,22,0.15);
  --green: #22c55e; --red: #ef4444; --blue: #3b82f6; --yellow: #eab308;
  --radius: 12px;
}
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:'Segoe UI',system-ui,-apple-system,sans-serif; background:var(--bg); color:var(--text); line-height:1.5; }
.header { background:var(--surface); border-bottom:1px solid var(--border); padding:12px 24px; display:flex; align-items:center; justify-content:space-between; }
.header h1 { font-size:20px; font-weight:700; display:flex; align-items:center; gap:10px; }
.header h1 span { color:var(--orange); }
.header-links { display:flex; gap:16px; }
.header-links a { color:var(--muted); text-decoration:none; font-size:13px; transition:color .2s; }
.header-links a:hover { color:var(--orange); }
.container { max-width:1100px; margin:0 auto; padding:24px; }

/* Steps indicator */
.steps { display:flex; gap:0; margin-bottom:32px; }
.step-item { flex:1; text-align:center; padding:12px 8px; background:var(--surface); border:1px solid var(--border); font-size:13px; color:var(--muted); cursor:default; position:relative; transition:all .2s; }
.step-item:first-child { border-radius:var(--radius) 0 0 var(--radius); }
.step-item:last-child { border-radius:0 var(--radius) var(--radius) 0; }
.step-item.active { background:var(--orange-dim); border-color:var(--orange); color:var(--orange); font-weight:600; }
.step-item.done { background:rgba(34,197,94,0.1); border-color:var(--green); color:var(--green); }
.step-num { font-weight:700; margin-right:6px; }

/* Panels */
.panel { display:none; }
.panel.active { display:block; }

/* Upload panel */
.drop-zone {
  border:2px dashed var(--border); border-radius:var(--radius); padding:48px 24px; text-align:center;
  cursor:pointer; transition:all .2s; background:var(--surface);
}
.drop-zone.dragover { border-color:var(--orange); background:var(--orange-dim); }
.drop-zone-icon { font-size:48px; margin-bottom:12px; }
.drop-zone-text { font-size:15px; margin-bottom:4px; }
.drop-zone-sub { font-size:12px; color:var(--muted); }
.file-input { display:none; }

.thumb-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:12px; margin-top:20px; }
.thumb-card { background:var(--surface); border:1px solid var(--border); border-radius:8px; overflow:hidden; position:relative; }
.thumb-card img { width:100%; height:100px; object-fit:cover; }
.thumb-name { padding:6px 8px; font-size:11px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.thumb-remove { position:absolute; top:4px; right:4px; background:rgba(0,0,0,0.7); color:#fff; border:none; border-radius:50%; width:22px; height:22px; cursor:pointer; font-size:12px; display:flex; align-items:center; justify-content:center; }
.thumb-remove:hover { background:var(--red); }
.thumb-badge { position:absolute; top:4px; left:4px; background:var(--accent, #3b82f6); color:#fff; font-size:10px; padding:1px 5px; border-radius:4px; font-weight:600; }

.upload-actions { margin-top:20px; display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.upload-count { font-size:13px; color:var(--muted); }

/* Settings row */
/* Mode selector */
.mode-selector { margin-top:20px; display:flex; gap:12px; }
.mode-card {
  flex:1; background:var(--surface); border:2px solid var(--border); border-radius:var(--radius);
  padding:16px 20px; cursor:pointer; transition:all .2s; position:relative;
}
.mode-card:hover { border-color:var(--muted); }
.mode-card.selected { border-color:var(--orange); background:var(--orange-dim); }
.mode-card .mode-icon { font-size:24px; margin-bottom:6px; }
.mode-card .mode-title { font-size:14px; font-weight:700; margin-bottom:2px; }
.mode-card .mode-desc { font-size:11px; color:var(--muted); line-height:1.4; }
.mode-card .mode-badge {
  position:absolute; top:10px; right:12px; font-size:10px; font-weight:700; padding:2px 8px;
  border-radius:10px; text-transform:uppercase;
}
.mode-card.selected .mode-badge { background:var(--orange); color:#fff; }
.mode-card:not(.selected) .mode-badge { background:var(--surface2); color:var(--muted); }
.settings-row { margin-top:12px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px 20px; display:flex; flex-wrap:wrap; gap:16px; align-items:center; }
.settings-row label { font-size:13px; display:flex; align-items:center; gap:6px; color:var(--muted); cursor:pointer; }
.settings-row input[type="checkbox"] { accent-color:var(--orange); }
.gemini-section { margin-top:12px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px 20px; display:none; }
.gemini-section.visible { display:block; }
.gemini-section label { font-size:13px; color:var(--muted); display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.gemini-input { background:var(--surface2); border:1px solid var(--border); border-radius:6px; padding:8px 12px; color:var(--text); font-size:13px; width:320px; }
.gemini-input::placeholder { color:var(--muted); }
.gemini-input:focus { outline:none; border-color:var(--orange); }

/* Buttons */
.btn { padding:10px 24px; border:none; border-radius:8px; font-size:14px; font-weight:600; cursor:pointer; transition:all .2s; display:inline-flex; align-items:center; gap:6px; }
.btn-primary { background:var(--orange); color:#fff; }
.btn-primary:hover { filter:brightness(1.1); }
.btn-primary:disabled { opacity:0.4; cursor:not-allowed; }
.btn-secondary { background:var(--surface2); color:var(--text); border:1px solid var(--border); }
.btn-secondary:hover { border-color:var(--orange); }
.btn-danger { background:rgba(239,68,68,0.15); color:var(--red); border:1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background:rgba(239,68,68,0.25); }
.btn-green { background:var(--green); color:#fff; }
.btn-green:hover { filter:brightness(1.1); }
.btn-sm { padding:6px 14px; font-size:12px; }

/* Processing panel */
.progress-section { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:24px; }
.progress-overall { margin-bottom:20px; }
.progress-label { font-size:13px; color:var(--muted); margin-bottom:6px; display:flex; justify-content:space-between; }
.progress-bar { height:8px; background:var(--surface2); border-radius:4px; overflow:hidden; }
.progress-fill { height:100%; background:var(--orange); border-radius:4px; transition:width .3s; width:0%; }
.progress-fill.done { background:var(--green); }
.log-box { background:var(--bg); border:1px solid var(--border); border-radius:8px; padding:12px; max-height:300px; overflow-y:auto; margin-top:16px; font-family:'Cascadia Code','Fira Code',monospace; font-size:12px; line-height:1.8; }
.log-line { color:var(--muted); }
.log-line.success { color:var(--green); }
.log-line.error { color:var(--red); }
.log-line.info { color:var(--orange); }

/* Review panel */
.review-summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:12px; margin-bottom:20px; }
.review-stat { background:var(--surface); border:1px solid var(--border); border-radius:8px; padding:14px 16px; text-align:center; }
.review-stat .val { font-size:22px; font-weight:700; color:var(--orange); }
.review-stat .lbl { font-size:11px; color:var(--muted); margin-top:2px; }

/* Scan results summary */
.scan-results-summary { margin-bottom:20px; }
.scan-results-badges { display:flex; gap:8px; margin-bottom:12px; }
.scan-badge { padding:6px 14px; border-radius:20px; font-size:13px; font-weight:600; display:flex; align-items:center; gap:6px; cursor:pointer; transition:all .2s; border:1px solid transparent; }
.scan-badge:hover { filter:brightness(1.1); }
.scan-badge.success { background:rgba(34,197,94,0.15); color:var(--green); border-color:rgba(34,197,94,0.3); }
.scan-badge.failed { background:rgba(239,68,68,0.15); color:var(--red); border-color:rgba(239,68,68,0.3); }
.scan-badge.removed { background:rgba(113,113,122,0.15); color:var(--muted); border-color:rgba(113,113,122,0.3); }
.scan-badge .badge-count { font-weight:700; }

.scan-section { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); margin-bottom:10px; overflow:hidden; }
.scan-section-header { padding:10px 16px; background:var(--surface2); cursor:pointer; display:flex; align-items:center; justify-content:space-between; font-size:13px; font-weight:600; }
.scan-section-header .sec-chevron { transition:transform .2s; color:var(--muted); font-size:10px; }
.scan-section-header.collapsed .sec-chevron { transform:rotate(-90deg); }
.scan-section-body { padding:0; }
.scan-section-body.collapsed { display:none; }

.scan-file-entry { display:flex; align-items:center; justify-content:space-between; padding:8px 16px; border-bottom:1px solid var(--border); font-size:13px; transition:background .2s; }
.scan-file-entry:last-child { border-bottom:none; }
.scan-file-entry:hover { background:rgba(249,115,22,0.05); }
.scan-file-info { display:flex; flex-direction:column; gap:2px; min-width:0; flex:1; }
.scan-file-name { font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.scan-file-detail { font-size:11px; color:var(--muted); }
.scan-file-actions { display:flex; gap:6px; align-items:center; flex-shrink:0; margin-left:8px; }

.scan-btn-remove { background:rgba(239,68,68,0.15); border:1px solid rgba(239,68,68,0.3); color:var(--red); border-radius:6px; padding:4px 8px; cursor:pointer; font-size:12px; transition:all .2s; line-height:1; }
.scan-btn-remove:hover { background:rgba(239,68,68,0.3); }
.scan-btn-retry { background:rgba(59,130,246,0.15); border:1px solid rgba(59,130,246,0.3); color:var(--blue); border-radius:6px; padding:4px 8px; cursor:pointer; font-size:12px; transition:all .2s; line-height:1; }
.scan-btn-retry:hover { background:rgba(59,130,246,0.3); }

.scan-confirm-row { display:flex; align-items:center; gap:8px; padding:8px 16px; background:rgba(239,68,68,0.08); border-bottom:1px solid var(--border); font-size:12px; color:var(--red); }
.scan-confirm-row button { padding:4px 10px; border-radius:4px; border:none; cursor:pointer; font-size:11px; font-weight:600; }
.scan-confirm-yes { background:var(--red); color:#fff; }
.scan-confirm-yes:hover { filter:brightness(1.1); }
.scan-confirm-no { background:var(--surface2); color:var(--text); border:1px solid var(--border) !important; }
.scan-confirm-no:hover { background:var(--surface); }

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

.receipt-group { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); margin-bottom:16px; overflow:hidden; }
.receipt-header { padding:14px 20px; background:var(--surface2); cursor:pointer; display:flex; align-items:center; justify-content:space-between; transition:background .2s; }
.receipt-header:hover { background:rgba(249,115,22,0.1); }
.receipt-header .file-name { font-weight:600; font-size:14px; display:flex; align-items:center; gap:8px; }
.receipt-header .file-meta { font-size:12px; color:var(--muted); display:flex; gap:12px; }
.receipt-header .chevron { transition:transform .2s; color:var(--muted); }
.receipt-header.collapsed .chevron { transform:rotate(-90deg); }
.receipt-body { padding:0; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.receipt-body.collapsed { display:none; }

.review-table { width:100%; border-collapse:collapse; font-size:12px; }
.review-table th { background:var(--surface2); padding:8px 10px; text-align:left; font-weight:600; font-size:11px; text-transform:uppercase; color:var(--muted); letter-spacing:0.5px; border-bottom:1px solid var(--border); position:sticky; top:0; }
.review-table td { padding:6px 10px; border-bottom:1px solid var(--border); vertical-align:middle; }
.review-table tr:hover { background:rgba(249,115,22,0.05); }
.review-table input, .review-table select { background:var(--bg); border:1px solid var(--border); border-radius:4px; padding:4px 6px; color:var(--text); font-size:12px; width:100%; }
.review-table input:focus, .review-table select:focus { outline:none; border-color:var(--orange); }
.review-table input[type="checkbox"] { width:auto; accent-color:var(--orange); }
.review-table .num-input { width:70px; text-align:right; }
.review-table td:nth-child(1) input, .review-table td:nth-child(2) input { min-width:140px; }
.review-table td:nth-child(3) select { min-width:130px; }
.low-confidence { color:var(--yellow); cursor:help; }

.line-item-remove { background:rgba(239,68,68,0.12); border:1px solid rgba(239,68,68,0.3); color:var(--red); border-radius:50%; width:22px; height:22px; display:inline-flex; align-items:center; justify-content:center; cursor:pointer; font-size:10px; line-height:1; padding:0; transition:all .2s; }
.line-item-remove:hover { background:rgba(239,68,68,0.3); transform:scale(1.1); }
.voided-price { color:var(--red) !important; }

.store-date-row { padding:10px 20px; display:flex; gap:16px; align-items:center; flex-wrap:wrap; border-bottom:1px solid var(--border); background:var(--surface); }
.store-date-row label { font-size:12px; color:var(--muted); display:flex; align-items:center; gap:6px; }
.store-date-row input, .store-date-row select { background:var(--bg); border:1px solid var(--border); border-radius:4px; padding:4px 8px; color:var(--text); font-size:12px; }
.date-select { min-width:60px; cursor:pointer; }
.date-slash { color:var(--muted); font-weight:600; margin:0 2px; }

.store-date-row.validation-error { background:rgba(239,68,68,0.08); border-bottom-color:var(--red); }
.validation-error-field { border-color:var(--red) !important; box-shadow:0 0 0 2px rgba(239,68,68,0.2); }

.store-autocomplete { position:relative; display:inline-block; }
.store-suggestions { position:absolute; top:100%; left:0; right:0; min-width:180px; background:var(--surface); border:1px solid var(--border); border-radius:6px; box-shadow:0 4px 12px rgba(0,0,0,0.3); z-index:100; max-height:180px; overflow-y:auto; margin-top:2px; }
.store-suggestion { padding:8px 12px; font-size:12px; cursor:pointer; transition:background .15s; }
.store-suggestion:hover { background:var(--orange-dim); color:var(--orange); }
.store-suggestion:first-child { border-radius:6px 6px 0 0; }
.store-suggestion:last-child { border-radius:0 0 6px 6px; }
body.light .store-suggestions { background:#fff; box-shadow:0 4px 12px rgba(0,0,0,0.1); }

/* Export panel */
.export-cards { display:grid; grid-template-columns:1fr 1fr; gap:20px; margin-bottom:24px; }
.export-card { background:var(--surface); border:2px solid var(--border); border-radius:var(--radius); padding:28px 24px; text-align:center; cursor:pointer; transition:all .2s; }
.export-card:hover { border-color:var(--orange); transform:translateY(-2px); }
.export-card.selected { border-color:var(--orange); background:var(--orange-dim); }
.export-card .icon { font-size:40px; margin-bottom:12px; }
.export-card .title { font-size:18px; font-weight:700; margin-bottom:6px; }
.export-card .desc { font-size:12px; color:var(--muted); line-height:1.6; }

.export-options { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:20px; margin-bottom:20px; }
.export-options h3 { font-size:14px; margin-bottom:12px; }
.month-picker { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.month-picker label { font-size:13px; color:var(--muted); }
.month-picker select, .month-picker input { background:var(--bg); border:1px solid var(--border); border-radius:6px; padding:8px 12px; color:var(--text); font-size:13px; }
.month-year-select { display:flex; gap:8px; }
.month-year-select select { min-width:90px; cursor:pointer; }
.merge-warning { margin-top:12px; padding:10px 14px; background:rgba(234,179,8,0.1); border:1px solid rgba(234,179,8,0.3); border-radius:8px; font-size:12px; color:var(--yellow); display:none; }
.merge-options { margin-top:8px; display:flex; gap:12px; }
.merge-options label { font-size:12px; display:flex; align-items:center; gap:4px; cursor:pointer; }

.export-result { text-align:center; padding:32px; }
.export-result .check { font-size:48px; margin-bottom:12px; }
.export-result .msg { font-size:16px; font-weight:600; margin-bottom:8px; }
.export-result .sub { font-size:13px; color:var(--muted); margin-bottom:20px; }

/* Light theme */
body.light {
  --bg: #f5f5f7; --surface: #ffffff; --surface2: #eeeef0; --border: #d4d4d8;
  --text: #1a1a2e; --muted: #6b6b80;
}
body.light .log-box { background: #eeeef0; }
body.light .review-table input, body.light .review-table select,
body.light .store-date-row input, body.light .store-date-row select,
body.light .month-picker select, body.light .month-picker input { background: #fff; }
body.light .thumb-remove { background: rgba(0,0,0,0.5); }
.theme-toggle { background:rgba(255,255,255,0.06); border:1px solid var(--border); border-radius:8px; padding:5px 10px; cursor:pointer; font-size:16px; line-height:1; transition:all 0.2s; color:var(--text); vertical-align:middle; }
.theme-toggle:hover { background:rgba(255,255,255,0.1); transform:translateY(-1px); }
body.light .theme-toggle { background:rgba(0,0,0,0.04); }
body.light .theme-toggle:hover { background:rgba(0,0,0,0.08); }
body.light .scan-section { background:#fff; }
body.light .scan-file-entry:hover { background:rgba(249,115,22,0.06); }
body.light .scan-confirm-row { background:rgba(239,68,68,0.06); }

/* Responsive */
@media(max-width:700px){
  .header { padding:10px 14px; flex-wrap:wrap; gap:8px; }
  .header h1 { font-size:17px; }
  .header-links { width:100%; justify-content:center; gap:10px; flex-wrap:wrap; }
  .header-links a { font-size:11px; }
  .container { padding:16px; }
  .steps { flex-wrap:wrap; }
  .step-item { flex:1 1 45%; border-radius:8px !important; margin:2px; }
  .export-cards { grid-template-columns:1fr; }
  .thumb-grid { grid-template-columns:repeat(auto-fill,minmax(100px,1fr)); }
  .review-table { font-size:11px; min-width:700px; }
  .store-date-row { padding:10px 12px; gap:8px; flex-direction:column; align-items:stretch; }
  .store-date-row label { flex-wrap:wrap; gap:6px; }
  .date-select { min-width:50px; flex:1; }
  .month-picker { flex-direction:column; align-items:stretch; gap:8px; }
  .month-year-select select { min-width:70px; flex:1; }
  .mode-selector { flex-direction:column; }
  .settings-row { flex-direction:column; align-items:flex-start; }
  .gemini-input { width:100%; }
  .scan-results-badges { flex-wrap:wrap; }
  .scan-badge { font-size:12px; padding:5px 10px; }
  .scan-file-entry { padding:8px 12px; }
  .scan-file-name { font-size:12px; }
  .store-autocomplete { display:block; width:100%; }
  .store-autocomplete input { width:100%; }
}
