:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --danger: #b91c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
body.modal-open { overflow: hidden; }
.page { max-width: 1500px; margin: 0 auto; padding: 24px; }
.hero {
  display: flex; gap: 20px; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.compact-hero { margin-bottom: 10px; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; color: var(--accent); font-size: 12px; font-weight: 700; }
h1 { margin: 6px 0 8px; font-size: 34px; }
h2, h3 { margin-top: 0; }
.hero-subtitle, .muted { color: var(--muted); }
.small { font-size: 12px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 20px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, .05);
}
.full-width { grid-column: 1 / -1; }
.nav-panel {
  display: flex;
  gap: 12px;
  padding: 14px;
  margin-bottom: 20px;
}
.nav-tab {
  position: relative;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 12px 18px;
  border-radius: 14px;
}
.review-tab { padding-right: 42px; }
.review-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #dc2626;
  color: white;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(220, 38, 38, .25);
}
.nav-tab:hover { background: #dbeafe; }
.form-grid, .filters-grid, .pending-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.filters-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.filters-grid > label { flex: 1 1 200px; min-width: 150px; }
.filters-grid > .filter-buttons { flex-shrink: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline-form { display: flex; gap: 10px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
input, select, textarea, button {
  font: inherit; border-radius: 12px; border: 1px solid var(--line); padding: 11px 12px; background: white;
}
textarea { resize: vertical; }
button { cursor: pointer; background: #0f172a; color: white; border: none; font-weight: 600; }
button:hover { opacity: .94; }
.primary-btn { background: var(--accent); }
.secondary-btn { background: #e2e8f0; color: #0f172a; }
.delete-btn { background: #fee2e2; color: var(--danger); }
.mini-panel { border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: #fff; }
.table-header { margin-bottom: 14px; }
.split-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.results-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.result-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
}
.result-chip span { color: var(--muted); font-size: 13px; }
.result-chip strong { font-size: 15px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; font-size: 13px; }
th[data-sort-col] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort-col]:hover { background: #f1f5f9; }
.sort-icon { color: #94a3b8; font-size: 11px; margin-left: 2px; }
.sort-icon-active { color: #0f172a; }
.checkbox-col { width: 36px; text-align: center; }
.checkbox-col input[type="checkbox"] { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.amount-cell { font-variant-numeric: tabular-nums; }
.category-list { display: flex; flex-direction: column; gap: 12px; }
.category-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.category-row, .sub-row, .pending-head, .pending-actions { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.sub-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.category-name { font-weight: 700; }
.cat-actions { display: flex; gap: 4px; flex-shrink: 0; }
.cat-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border-radius: 8px;
  font-size: 15px; background: #f1f5f9; color: #475569; border: 1px solid var(--line);
}
.cat-icon-btn:hover { background: #e2e8f0; color: #0f172a; }
.cat-icon-delete { background: #fff1f2; color: #e11d48; border-color: #fecdd3; }
.cat-icon-delete:hover { background: #ffe4e6; color: #be123c; }
.tag, .pill {
  display: inline-flex; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: #eff6ff; color: #1d4ed8;
}
.pending-list { display: flex; flex-direction: column; gap: 14px; }
.pending-card { border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.pending-actions { margin-top: 12px; justify-content: flex-end; }
.full-span { grid-column: 1 / -1; }
.filter-buttons { display: flex; gap: 8px; align-items: end; }
.toast {
  position: fixed; right: 24px; bottom: 24px; color: white; padding: 14px 18px; border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.15);
  z-index: 2000;
}
.hidden { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}
.modal-card {
  position: relative;
  width: min(1100px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--panel);
  border-radius: 24px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .25);
}
.large-modal { padding: 0; }
.large-modal > .modal-header {
  padding: 22px 22px 14px;
}
.large-modal > .modal-body {
  padding: 0 22px 22px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 0;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 10;
  border-bottom: 1px solid var(--line);
}
.modal-body { display: flex; flex-direction: column; gap: 16px; }
.two-column-modal {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #0f172a;
  font-size: 26px;
  line-height: 1;
  padding: 0;
}
@media (max-width: 1100px) {
  .split-header { flex-direction: column; }
  .two-column-modal { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .page { padding: 12px; }
  h1 { font-size: 24px; }
  .panel { padding: 14px; border-radius: 14px; }
  .nav-panel { flex-direction: row; flex-wrap: wrap; width: 100%; gap: 8px; padding: 10px; }
  .nav-tab { flex: 1 1 auto; text-align: center; padding: 10px 12px; font-size: 13px; }
  .filters-grid > label { flex: 1 1 100%; min-width: 0; }
  .form-grid, .pending-grid { grid-template-columns: 1fr; }
  .modal { padding: 8px; }
  .modal-card { border-radius: 16px; max-height: calc(100vh - 16px); }
  .large-modal > .modal-header { padding: 14px 14px 10px; }
  .large-modal > .modal-body { padding: 0 14px 14px; }
  th, td { padding: 10px 8px; font-size: 13px; }
  .result-chip { padding: 8px 10px; gap: 6px; }
  .result-chip span { font-size: 12px; }
  .result-chip strong { font-size: 13px; }
  .monthly-bar-row {
    display: flex !important;
    flex-wrap: wrap;
    gap: 2px 8px;
  }
  .monthly-bar-row.clickable-bar { padding: 6px 4px; }
  .monthly-bar-label { font-size: 13px; flex: 1 1 auto; min-width: 0; }
  .monthly-bar-value { font-size: 13px; text-align: right; flex-shrink: 0; }
  .monthly-bar-track { width: 100% !important; height: 18px; flex: 0 0 100%; }
  .monthly-sub-detail .monthly-bar-row { padding: 2px 0; }
  .two-column-modal { grid-template-columns: 1fr; }
  .monthly-view-toolbar { flex-wrap: wrap; }
  .monthly-view-toolbar select { max-width: 100%; }
  .monthly-view-total { margin-left: 0; }
  .graph-toolbar label { flex: 1 1 100%; }
  .graph-chart { min-height: 200px; }
  .graph-bar-col { min-width: 36px; }
  .graph-bar-value { font-size: 10px; }
  .graph-bar-label { font-size: 10px; }
  .pending-card { padding: 12px; }
  .pending-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .pending-actions { flex-direction: column; gap: 8px; }
  .pending-actions button { width: 100%; }
  .category-row { flex-wrap: wrap; }
  .sub-row { flex-wrap: wrap; gap: 6px; }
  .icon-btn { width: 36px; height: 36px; font-size: 22px; }
  .clickable-bar { padding: 4px 4px; }
  .monthly-sub-detail { padding-left: 16px; margin-left: 6px; }
  .split-header { gap: 10px; }
}


tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover { background: #f8fafc; }
.table-hint { margin-top: 10px; }


.pending-card .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pending-card .field > label {
  font-size: 0.92rem;
  font-weight: 600;
  color: #334155;
}

.pending-card .pending-category,
.pending-card .pending-sub-category,
.pending-card .pending-notes {
  position: relative;
  z-index: 2;
}


.monthly-view-toolbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.monthly-view-toolbar label {
  font-weight: 600;
}

.monthly-view-toolbar select {
  max-width: 260px;
}

.monthly-view-total {
  margin-left: auto;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.monthly-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.monthly-chart.hidden {
  display: none;
}

.monthly-bar-row {
  display: grid;
  grid-template-columns: minmax(140px, 180px) 1fr minmax(90px, 110px);
  gap: 12px;
  align-items: center;
}

.monthly-bar-label {
  font-weight: 500;
  color: #0f172a;
  word-break: break-word;
}

.monthly-bar-track {
  position: relative;
  width: 100%;
  height: 28px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.monthly-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #3b82f6;
}

.monthly-bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #334155;
  font-weight: 600;
}

.clickable-bar {
  cursor: pointer;
  border-radius: 10px;
  padding: 6px 8px;
  transition: background 0.15s;
}

.clickable-bar:hover {
  background: #f1f5f9;
}

.monthly-bar-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.monthly-sub-detail {
  padding: 8px 0 4px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 3px solid #93c5fd;
  margin-left: 12px;
}

.monthly-sub-detail.hidden {
  display: none;
}

.monthly-sub-row .monthly-bar-label {
  font-size: 13px;
  color: var(--muted);
}

.monthly-sub-row .monthly-bar-value {
  font-size: 13px;
}

.monthly-sub-fill {
  background: #93c5fd;
}

.graph-toolbar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.graph-toolbar label {
  flex: 1 1 160px;
  min-width: 0;
}
.graph-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-height: 260px;
  padding: 16px 0 0;
  border-bottom: 2px solid var(--line);
  overflow-x: auto;
}
.graph-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 0;
  min-width: 44px;
  gap: 4px;
}
.graph-bar-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.graph-bar {
  width: 100%;
  max-width: 48px;
  border-radius: 6px 6px 0 0;
  background: #3b82f6;
  min-height: 2px;
  transition: height .25s ease;
}
.graph-bar:hover {
  background: #2563eb;
}
.graph-bar-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 6px;
  border-top: 2px solid transparent;
}
.settings-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid var(--line);
  font-size: 22px;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}
.settings-btn:hover { background: #e2e8f0; color: #0f172a; }
.settings-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  background: #f8fafc;
  list-style: none;
  user-select: none;
}
.accordion-header::-webkit-details-marker { display: none; }
.accordion-header h3 { margin: 0; }
.accordion-icon {
  font-size: 18px;
  color: var(--muted);
  transition: transform .2s ease;
}
details.settings-section[open] > .accordion-header .accordion-icon {
  transform: rotate(180deg);
}
.accordion-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ignored-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.ignored-name-row:last-child { border-bottom: none; }
.mapping-defaults {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-weight: 400;
}
.mapping-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  white-space: nowrap;
}
