/* ============================================================
   BASE — Gambit.tax theme
   --bg:    #191818  (near-black background)
   --gold:  #baa356  (primary accent — headings, highlights)
   --cta:   #ff4646  (action buttons)
   --text:  #F1EDE3  (cream body text)
   --line:  #424242  (borders / separators)
============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #191818;
  --bg-raised:   #201f1f;
  --bg-card:     #242323;
  --gold:        #baa356;
  --gold-dim:    #8c7a3e;
  --gold-light:  rgba(186,163,86,.12);
  --cta:         #ff4646;
  --cta-hover:   #e63030;
  --text:        #F1EDE3;
  --text-dim:    #9b9488;
  --line:        #333232;
  --line-light:  #2a2929;
  --green:       #4caf7d;
  --green-bg:    rgba(76,175,125,.1);
  --yellow:      #baa356;
  --yellow-bg:   rgba(186,163,86,.1);
  --red:         #ff4646;
  --radius:      10px;
  --shadow:      0 4px 24px rgba(0,0,0,.45);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* ============================================================
   SCREEN TRANSITIONS
============================================================ */
.screen { display: none; }
.screen.active { display: block; }
.screen.hidden  { display: none; }

/* ============================================================
   SHARED COMPONENTS
============================================================ */
.btn-primary {
  background: var(--cta);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--cta-hover); }

.btn-outline {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-outline:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.hidden { display: none !important; }

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.logo img {
  height: 36px;
  width: auto;
  display: block;
}
.logo.small img { height: 26px; }

/* ============================================================
   SCREEN 1: UPLOAD
============================================================ */
#screen-upload {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--bg);
}

.upload-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 44px 52px;
  max-width: 560px;
  width: 100%;
}

.upload-card .logo {
  margin-bottom: 32px;
}

.upload-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
  color: var(--gold);
  letter-spacing: -.01em;
}

.subtitle {
  color: var(--text-dim);
  line-height: 1.65;
  margin-bottom: 32px;
  font-size: 14px;
}
.subtitle strong {
  color: var(--text);
  font-weight: 500;
}

.drop-zone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 38px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--gold);
  background: var(--gold-light);
}
.drop-zone svg path { stroke: var(--gold); }

.drop-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
.drop-sub {
  color: var(--text-dim);
  font-size: 13px;
}
.file-types {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.upload-error {
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(255,70,70,.12);
  color: var(--cta);
  border: 1px solid rgba(255,70,70,.3);
  border-radius: 6px;
  font-size: 13px;
}

.faq {
  margin-top: 28px;
  font-size: 13px;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.faq summary {
  cursor: pointer;
  color: var(--gold);
  font-weight: 500;
  user-select: none;
  padding: 4px 0;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: '▶  ';
  font-size: 10px;
  opacity: .7;
}
details[open] .faq summary::before,
.faq details[open] > summary::before { content: '▼  '; }
.faq ul {
  margin-top: 12px;
  padding-left: 16px;
  line-height: 2.1;
  color: var(--text-dim);
}
.faq li strong {
  color: var(--text);
  font-weight: 500;
}

/* ============================================================
   SCREEN 2: REVIEW
============================================================ */
#screen-review {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.review-header {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.review-header-left  { flex: 1; }
.review-header-right { display: flex; gap: 8px; align-items: center; }

.review-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}
.stat-sep { color: var(--line); }

.needs-review-badge {
  background: var(--yellow-bg);
  color: var(--gold);
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 12px;
  border: 1px solid rgba(186,163,86,.25);
}

.filter-bar {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex;
}

.filter-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.table-wrapper {
  flex: 1;
  overflow-x: auto;
  padding: 0 0 40px;
}

.transactions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.transactions-table thead tr {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
}
.transactions-table th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.transactions-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-light);
  vertical-align: middle;
  color: var(--text);
}

.transactions-table tbody tr:hover {
  background: var(--bg-raised);
}

.col-check   { width: 36px; }
.col-date    { width: 100px; white-space: nowrap; color: var(--text-dim); }
.col-desc    { min-width: 200px; }
.col-amount  { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.col-category{ width: 270px; }
.col-include { width: 64px; text-align: center; }

.amount-expense { color: var(--text); }
.amount-credit  { color: var(--text-dim); font-style: italic; }

.category-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 13px;
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
}
.category-select:focus {
  outline: 1.5px solid var(--gold);
  border-color: transparent;
}

/* Row states */
tr.row-review {
  background: rgba(186,163,86,.05);
}
tr.row-review td.col-category .category-select {
  border-color: var(--gold-dim);
  color: var(--gold);
}
tr.row-review:hover { background: rgba(186,163,86,.09); }
tr.row-excluded { opacity: .35; }
tr.row-excluded td { text-decoration: line-through; }

/* Checkboxes — accent gold */
input[type="checkbox"] {
  accent-color: var(--gold);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: 60px;
  color: var(--text-dim);
}

/* ============================================================
   SCREEN 3: SUMMARY
============================================================ */
#screen-summary {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.summary-content {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 24px 72px;
  width: 100%;
}

.summary-hero {
  text-align: center;
  margin-bottom: 28px;
  padding: 36px 24px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.summary-hero-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 10px;
}
.summary-hero-amount {
  font-size: 52px;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -.02em;
}
.summary-hero-sub {
  font-size: 13px;
  color: var(--text-dim);
}

.summary-disclaimer {
  background: rgba(186,163,86,.07);
  border: 1px solid rgba(186,163,86,.2);
  border-radius: 6px;
  padding: 13px 16px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 28px;
  line-height: 1.65;
}
.summary-disclaimer strong {
  color: var(--gold);
  font-weight: 600;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color .15s;
}
.summary-card:hover { border-color: var(--gold-dim); }

.summary-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.summary-card-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
.summary-card-line {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: .03em;
}
.summary-card-amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.summary-card-count {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}
.summary-card-note {
  font-size: 11px;
  color: var(--cta);
  margin-top: 8px;
  font-weight: 500;
}

/* ============================================================
   LOADING OVERLAY
============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 48px;
  text-align: center;
  box-shadow: var(--shadow);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-card p {
  font-size: 14px;
  color: var(--text-dim);
}

/* ============================================================
   AI CLASSIFICATION OVERLAY
============================================================ */
.ai-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.ai-overlay.hidden { display: none; }

.ai-overlay-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 52px;
  box-shadow: var(--shadow);
  max-width: 400px;
  width: calc(100% - 48px);
  text-align: center;
}

.ai-overlay-icon {
  font-size: 28px;
  color: var(--gold);
  margin-bottom: 14px;
  animation: ai-pulse 1.6s ease-in-out infinite;
}
@keyframes ai-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .45; transform: scale(.88); }
}

.ai-overlay-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
  margin-bottom: 6px;
}

.ai-overlay-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 28px;
}

.ai-overlay-progress {
  margin-bottom: 20px;
}

.ai-progress-bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.ai-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  border-radius: 3px;
  transition: width .35s ease;
}

.ai-progress-label {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.ai-overlay-note {
  font-size: 11px;
  color: var(--text-dim);
  opacity: .6;
}

/* ============================================================
   SETTINGS PANEL (API key — mirrors .faq styling)
============================================================ */
.settings-panel {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.settings-panel summary {
  cursor: pointer;
  color: var(--gold);
  font-weight: 500;
  user-select: none;
  padding: 4px 0;
  list-style: none;
}
.settings-panel summary::-webkit-details-marker { display: none; }
.settings-panel summary::before {
  content: '▶  ';
  font-size: 10px;
  opacity: .7;
}
details[open].settings-panel > summary::before { content: '▼  '; }

.settings-desc {
  margin: 12px 0 12px;
  line-height: 1.6;
  font-size: 13px;
  color: var(--text-dim);
}

.api-key-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.api-key-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  font-family: monospace;
  outline: none;
  transition: border-color .15s;
}
.api-key-row input:focus { border-color: var(--gold); }
.api-key-row input::placeholder { color: var(--text-dim); font-family: inherit; }

.btn-save-key {
  white-space: nowrap;
  padding: 7px 14px;
}

.api-key-status {
  display: block;
  font-size: 12px;
  height: 16px;
  color: var(--green);
  margin-bottom: 6px;
  transition: opacity .3s;
}
.api-key-note {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}

.memory-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-light);
}
.memory-count {
  font-size: 12px;
  color: var(--text-dim);
}
.btn-clear-memory {
  font-size: 11px;
  padding: 4px 10px;
  color: var(--cta);
  border-color: rgba(255,70,70,.3);
}
.btn-clear-memory:hover {
  color: var(--cta);
  border-color: var(--cta);
  background: rgba(255,70,70,.08);
}

/* ============================================================
   AI INDICATOR (review header)
============================================================ */
.ai-indicator {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
  cursor: default;
  letter-spacing: .03em;
}
.ai-indicator.on {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(76,175,125,.25);
}
.ai-indicator.off {
  background: var(--bg);
  color: var(--text-dim);
  border: 1px solid var(--line);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ai-indicator:empty { display: none; }

/* ============================================================
   CLAUDE BANNER (below review header)
============================================================ */
.claude-banner {
  padding: 9px 24px;
  font-size: 12px;
  font-weight: 500;
  background: var(--yellow-bg);
  color: var(--gold);
  border-bottom: 1px solid rgba(186,163,86,.2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.claude-banner.success {
  background: var(--green-bg);
  color: var(--green);
  border-bottom-color: rgba(76,175,125,.2);
}
.claude-banner::before {
  content: '✦';
  flex-shrink: 0;
  font-size: 11px;
}

/* ============================================================
   AI BADGE (inline in description cell)
============================================================ */
.ai-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(76,175,125,.25);
  vertical-align: middle;
  margin-left: 6px;
  text-transform: uppercase;
}

/* ============================================================
   APPLY-TO-ALL TOAST
============================================================ */
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

.apply-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  z-index: 50;
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
}
.apply-toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
  animation: slideUp .2s ease forwards;
}

.apply-toast-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 600px) {
  .upload-card { padding: 28px 22px; }
  .review-header { padding: 10px 12px; flex-wrap: wrap; }
  .review-stats { font-size: 12px; order: 3; width: 100%; padding-top: 4px; }
  .filter-tab { padding: 10px 10px; font-size: 12px; }
  .transactions-table th,
  .transactions-table td { padding: 9px 10px; }
  .col-category { width: 180px; }
  .summary-hero-amount { font-size: 38px; }
}
