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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222536;
  --border: #2e3248;
  --text: #e8eaf0;
  --text-muted: #8890aa;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #a855f7;
  --accent: #6366f1;
  --radius: 12px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 28px; }
.logo h1 { font-size: 18px; font-weight: 700; }
.logo p { font-size: 12px; color: var(--text-muted); }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-range { display: flex; align-items: center; gap: 6px; }
.date-range input[type=date] { width: 138px; }
.date-sep { color: var(--text-muted); font-size: 13px; }

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }

/* Select / Input */
.select-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.select-input:focus { border-color: var(--accent); }
.full-width { width: 100%; }

/* Main */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.card-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.card-value { font-size: 26px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.card-green .card-value { color: var(--green); }
.card-red .card-value { color: var(--red); }
.card-blue .card-value { color: var(--blue); }
.card-poolhouse { border-color: #d97706; grid-column: 1 / -1; }
.card-poolhouse .card-value { color: #f59e0b; font-size: 28px; }
.card-gray .card-value { color: var(--text); }

/* Charts */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.chart-box h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; color: var(--text-muted); }
.chart-wide { } /* default */
.chart-full { grid-column: 1 / -1; }
.chart-box canvas { max-height: 280px; }

/* Transactions */
.transactions-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.transactions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.transactions-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.badge {
  background: var(--surface2);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
}
.tx-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.tx-filters input { min-width: 160px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:hover { background: var(--surface2); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 10px 16px; font-size: 13px; vertical-align: middle; }
.text-right { text-align: right; }
td.text-right { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount-debit { color: var(--red); }
.amount-credit { color: var(--green); }

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s;
}
.cat-chip:hover { border-color: var(--accent); }
.cat-chip.manual { border-color: var(--purple); color: var(--purple); }
.cat-chip.uncategorized { border-color: #555; color: #888; }
.source-file { font-size: 11px; color: var(--text-muted); }
.tx-label { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-sm { width: 360px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
h4 { font-size: 13px; font-weight: 600; color: var(--text-muted); }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  position: relative;
  transition: border-color 0.15s;
}
.upload-zone:hover { border-color: var(--accent); }
.upload-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* Files list */
.files-list { display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 12px;
  gap: 8px;
}
.file-item .file-name { flex: 1; }
.file-item .file-status { color: var(--green); font-size: 11px; }
.file-item .file-status.pending { color: var(--text-muted); }
.btn-reset { background: none; border: none; color: #f87171; cursor: pointer; font-size: 11px; padding: 2px 6px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
  max-width: 380px;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

/* Loading spinner */
.spin {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .chart-wide, .chart-full { grid-column: auto; }
}
@media (max-width: 600px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .header-inner { flex-wrap: wrap; height: auto; padding: 12px 0; }
  main { padding: 16px; }
}
