/* ============================================================
   LEDGER — Expense Tracker
   Dark editorial fintech aesthetic
   Space Mono (monospace data) + DM Sans (UI)
   ============================================================ */

:root {
  --bg:          #0d0f12;
  --surface:     #151820;
  --surface2:    #1c2130;
  --surface3:    #242b3d;
  --border:      #252c3e;
  --border2:     #2f3855;

  --text:        #e8eaf2;
  --text-muted:  #6b758f;
  --text-dim:    #3d4560;

  --green:       #00e87a;
  --green-dim:   rgba(0, 232, 122, 0.12);
  --green-glow:  rgba(0, 232, 122, 0.25);
  --red:         #ff4757;
  --red-dim:     rgba(255, 71, 87, 0.12);
  --blue:        #4fc3f7;
  --yellow:      #ffd740;
  --purple:      #b39ddb;

  --sidebar-w:   240px;
  --radius:      10px;
  --radius-lg:   16px;

  --mono: 'Space Mono', monospace;
  --sans: 'DM Sans', sans-serif;

  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
}

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

html { font-size: 15px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 28px 20px 24px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  width: 34px; height: 34px;
  background: var(--green);
  color: var(--bg);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  flex-shrink: 0;
  box-shadow: 0 0 16px var(--green-glow);
}

.logo-text {
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.2em;
  color: var(--text);
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.nav-item svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(0, 232, 122, 0.2);
}

.sidebar-actions {
  padding: 16px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.btn-import, .btn-export {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-import svg, .btn-export svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.btn-import {
  background: var(--surface2);
  color: var(--blue);
}
.btn-import:hover { background: var(--surface3); border-color: var(--blue); }

.btn-export {
  background: var(--surface2);
  color: var(--green);
}
.btn-export:hover { background: var(--green-dim); border-color: var(--green); }

/* ============================================================
   HAMBURGER & OVERLAY
   ============================================================ */
.hamburger {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
}

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: 0.3s;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ============================================================
   MAIN
   ============================================================ */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}

.topbar-title {
  font-family: var(--mono);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  color: var(--text);
}

.btn-add-tx {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--green);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 20px var(--green-glow);
}

.btn-add-tx:hover {
  background: #1aff8c;
  box-shadow: 0 0 30px var(--green-glow);
  transform: translateY(-1px);
}

.btn-add-tx svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

/* ============================================================
   PAGES
   ============================================================ */
.page {
  display: none;
  padding: 32px;
  flex: 1;
  animation: fadeIn 0.3s ease;
}

.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.stat-card.income::before  { background: var(--green); }
.stat-card.expense::before { background: var(--red); }
.stat-card.balance::before { background: var(--blue); }
.stat-card.transactions::before { background: var(--yellow); }

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-card.income  .stat-value { color: var(--green); }
.stat-card.expense .stat-value { color: var(--red); }
.stat-card.balance .stat-value { color: var(--blue); }
.stat-card.transactions .stat-value { color: var(--yellow); }

.stat-icon {
  position: absolute;
  right: 18px; top: 18px;
  font-size: 1.4rem;
  opacity: 0.15;
  font-family: var(--mono);
}

/* ============================================================
   CARDS
   ============================================================ */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card.full-width {
  grid-column: 1 / -1;
}

.card-header {
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   CATEGORY BREAKDOWN
   ============================================================ */
.category-breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-name {
  font-size: 0.8rem;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-amount {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--red);
}

.cat-bar-wrap {
  width: 80px;
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  overflow: hidden;
}

.cat-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ============================================================
   TRANSACTIONS PAGE
   ============================================================ */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-input, .filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.85rem;
  padding: 9px 14px;
  outline: none;
  transition: border-color 0.2s;
}

.filter-input:focus, .filter-select:focus {
  border-color: var(--green);
}

.filter-input[type="text"] { flex: 1; min-width: 160px; }
.filter-select { min-width: 140px; }
.filter-input[type="date"] { min-width: 140px; }

.filter-select option { background: var(--surface2); }

.filter-sep {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.btn-clear-filters {
  padding: 9px 16px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-clear-filters:hover { border-color: var(--red); color: var(--red); }

/* TABLE */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.tx-table {
  width: 100%;
  border-collapse: collapse;
}

.tx-table th {
  padding: 14px 16px;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.tx-table td {
  padding: 13px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.tx-table tbody tr:last-child td { border-bottom: none; }
.tx-table tbody tr:hover td { background: var(--surface2); }

.td-date {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.td-desc {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface3);
  white-space: nowrap;
}

.td-type {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.td-type.income { color: var(--green); }
.td-type.expense { color: var(--red); }

.td-amount {
  font-family: var(--mono);
  font-weight: 700;
}

.td-amount.income { color: var(--green); }
.td-amount.expense { color: var(--red); }

.td-actions {
  display: flex;
  gap: 6px;
}

.btn-edit, .btn-delete {
  padding: 5px 10px;
  border-radius: 6px;
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-edit {
  background: var(--surface3);
  color: var(--blue);
}
.btn-edit:hover { background: rgba(79,195,247,0.15); }

.btn-delete {
  background: var(--surface3);
  color: var(--red);
}
.btn-delete:hover { background: var(--red-dim); }

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

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.3;
}

/* ============================================================
   BUDGET PAGE
   ============================================================ */
.budget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-title {
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  color: var(--text);
}

.btn-add-budget {
  padding: 9px 18px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--green);
  font-family: var(--sans);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-add-budget:hover { background: var(--green-dim); border-color: var(--green); }

.budget-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.budget-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: border-color 0.2s;
}

.budget-item.exceeded {
  border-color: rgba(255, 71, 87, 0.4);
  background: rgba(255, 71, 87, 0.04);
}

.budget-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.budget-cat-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.budget-amounts {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.budget-amounts span.spent { color: var(--text); }
.budget-amounts span.exceeded { color: var(--red); }

.budget-progress-wrap {
  height: 8px;
  background: var(--surface3);
  border-radius: 4px;
  overflow: hidden;
}

.budget-progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.budget-progress-bar.ok     { background: var(--green); }
.budget-progress-bar.warn   { background: var(--yellow); }
.budget-progress-bar.danger { background: var(--red); }

.budget-pct {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
}

.budget-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.budget-form-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-top: 20px;
  max-width: 420px;
}

.budget-form-card h3 {
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
  color: var(--green);
}

/* ============================================================
   CHARTS PAGE
   ============================================================ */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ============================================================
   SHARED FORM STYLES
   ============================================================ */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-row label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.form-control {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.form-control:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
}

.form-control option { background: var(--surface2); }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-primary {
  padding: 10px 22px;
  background: var(--green);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover { background: #1aff8c; box-shadow: 0 0 16px var(--green-glow); }

.btn-secondary {
  padding: 10px 22px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px 0;
}

.modal-header h2 {
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}

.modal-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}
.modal-close:hover { background: var(--red-dim); color: var(--red); border-color: var(--red); }

.modal-body {
  padding: 24px 28px;
}

.modal-footer {
  padding: 0 28px 24px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* TYPE TOGGLE */
.type-toggle {
  display: flex;
  gap: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
}

.type-btn {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.type-btn.active[data-type="expense"] {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255,71,87,0.3);
}

.type-btn.active[data-type="income"] {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(0,232,122,0.3);
}

/* FORM GRID */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.cat-select-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cat-select-wrap .form-control { flex: 1; }

.btn-new-cat {
  padding: 10px 12px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--green);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.btn-new-cat:hover { background: var(--green-dim); border-color: var(--green); }

.new-cat-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.new-cat-form .form-control { flex: 1; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 0.875rem;
  z-index: 2000;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
  max-width: 300px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }
.toast.info    { border-color: var(--blue);  color: var(--blue); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay.open { display: block; }

  .hamburger { display: flex; }

  .main {
    margin-left: 0;
  }

  .topbar {
    padding: 14px 16px 14px 60px;
  }

  .page { padding: 20px 16px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .stat-value { font-size: 1.2rem; }

  .dash-grid { grid-template-columns: 1fr; }

  .charts-grid { grid-template-columns: 1fr; }

  .form-grid { grid-template-columns: 1fr; }

  .filters-bar {
    flex-wrap: wrap;
  }

  .filter-input[type="text"] { width: 100%; }

  .modal { max-width: calc(100vw - 32px); }

  .table-wrap { overflow-x: auto; }

  .tx-table { min-width: 600px; }

  .btn-add-tx span { display: none; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1rem; }
}

/* ============================================================
   CANVAS FIX
   ============================================================ */
canvas {
  max-width: 100%;
  max-height: 280px;
}

/* ============================================================
   IMPORT WIZARD
   ============================================================ */
.import-wizard {
  max-width: 680px;
  width: 100%;
}

/* Steps indicator */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.wstep {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  transition: color 0.2s;
}

.wstep.active  { color: var(--green); }
.wstep.done    { color: var(--text-muted); }

.wstep-sep { color: var(--text-dim); font-size: 0.7rem; }

/* Wizard body content */
.wizard-body { min-height: 340px; }

.wizard-step { display: none; animation: fadeIn 0.25s ease; }
.wizard-step.active { display: block; }

.wstep-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.wstep-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  line-height: 1.5;
  margin-top: 16px;
}

/* ---- DROP ZONE ---- */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface2);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--green);
  background: var(--green-dim);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-icon {
  color: var(--text-muted);
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
}

.drop-icon svg { width: 100%; height: 100%; }
.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon { color: var(--green); }

.drop-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 6px;
}

.drop-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.drop-formats {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

.drop-zone.file-loaded {
  border-style: solid;
  border-color: var(--green);
  background: var(--green-dim);
}

.file-loaded-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--green);
  font-weight: 500;
}

.file-loaded-info .file-icon { font-size: 1.5rem; }

/* ---- SHEET LIST ---- */
.sheet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.sheet-item:hover { border-color: var(--green); background: var(--green-dim); }
.sheet-item.selected { border-color: var(--green); background: var(--green-dim); }

.sheet-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.sheet-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ---- COLUMN MAPPER ---- */
.mapper-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.mapper-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mapper-field-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.mapper-field-label .req { color: var(--red); }

.mapper-select {
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.85rem;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.mapper-select:focus { border-color: var(--green); }
.mapper-select option { background: var(--surface2); }

.mapper-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.mapper-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.opt-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex: 1;
}

.form-control-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
  width: auto;
  min-width: 140px;
}

/* ---- PREVIEW TABLE ---- */
.preview-summary {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.preview-stat {
  flex: 1;
  min-width: 120px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
}

.preview-stat-value {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--green);
}

.preview-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

.preview-stat.warn .preview-stat-value { color: var(--yellow); }
.preview-stat.error .preview-stat-value { color: var(--red); }

.preview-table-wrap {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.preview-table th {
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.preview-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

.preview-table tr:last-child td { border-bottom: none; }
.preview-table tr:hover td { background: var(--surface2); }

.preview-table td.valid   { color: var(--green); }
.preview-table td.invalid { color: var(--red); }
.preview-table td.warn    { color: var(--yellow); }

.preview-row-ok   { }
.preview-row-skip td { opacity: 0.45; }
.preview-row-skip td:first-child::before { content: '⊘ '; color: var(--text-dim); }

.preview-footer {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---- SUCCESS ---- */
.wizard-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 16px;
}

.success-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--green-dim);
  border: 2px solid var(--green);
  color: var(--green);
  font-size: 1.8rem;
  display: grid;
  place-items: center;
  box-shadow: 0 0 32px var(--green-glow);
  animation: successPop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes successPop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.success-title {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--green);
}

.success-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.success-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 20px;
  text-align: center;
  min-width: 100px;
}

.success-stat-val {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.success-stat-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.wizard-footer {
  display: flex;
  align-items: center;
  gap: 10px;
}

@media (max-width: 600px) {
  .mapper-grid { grid-template-columns: 1fr; }
  .wizard-steps { display: none; }
}
/* ============================================================
   drive.css — styles for the Google Drive sync panel
   Add this <link> to your HTML <head>:
   <link rel="stylesheet" href="drive.css">
   ============================================================ */

/* ── Panel container ── */
.drive-panel {
  background: var(--surface, #1a2035);
  border: 1px solid var(--border, #252c3e);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.drive-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.drive-panel-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text, #e2e8f0);
  flex: 1;
}

/* ── Status badge ── */
.drive-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-idle {
  background: rgba(107, 117, 143, .18);
  color: #6b758f;
}

.badge-syncing {
  background: rgba(79, 195, 247, .15);
  color: #4fc3f7;
  animation: pulse 1.2s infinite;
}

.badge-ok {
  background: rgba(0, 232, 122, .15);
  color: #00e87a;
}

.badge-error {
  background: rgba(255, 71, 87, .15);
  color: #ff4757;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .5
  }
}

/* ── Button row ── */
.drive-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

/* ── Meta row ── */
.drive-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-muted, #6b758f);
  margin-bottom: 10px;
}

.drive-meta strong {
  color: var(--text, #e2e8f0);
}

/* ==============================
   ANALYTICS VISUALIZATION STYLES
   ============================== */

/* Meter visualization (02) */
.meter-wrap {
  display: block;
  width: 100%;
}
.meter {
  position: relative;
  width: 100%;
  height: 16px;
}
.meter-track {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-50%);
  border-radius: 6px;
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  border-radius: 6px;
  transition: width 0.3s ease;
}
.meter-fill.ok { background: var(--green, #00e87a); }
.meter-fill.bad { background: var(--red, #ff4757); }
.meter-target {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 20px;
  border-radius: 2px;
  background: var(--text, #e2e8f0);
  z-index: 2;
}
.meter-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-muted, #6b758f);
  margin-top: 8px;
}
.meter-val { font-weight: 700; font-size: 0.95rem; color: var(--green, #00e87a); }

/* Small multiples sparkline grid (03) */
.spark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.spark-item { text-align: center; }
.spark-title { font-weight: 600; margin-bottom: 4px; color: var(--text, #e2e8f0); }
.spark-canvas {
  width: 100%;
  height: 50px;
  border: 1px solid var(--border, #252c3e);
  border-radius: 4px;
}

/* Heat grid (17) */
.heat-wrap { margin-top: 16px; }
.heat-row { display: flex; align-items: center; margin: 4px 0; }
.heat-cat { font-weight: 600; color: var(--text, #e2e8f0); margin-right: 8px; min-width: 110px; }
.heat-cell {
  flex: 1;
  height: 24px;
  border-radius: 4px;
  margin: 0 2px;
}
.heat-head .heat-h {
  flex: 1;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted, #6b758f);
  margin: 0 2px;
}

/* Calendar heatmap (18) */
.cal-wrap {
  margin-top: 16px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 22px);
  gap: 3px;
}
.cal-wd {
  width: 22px;
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted, #6b758f);
  margin-bottom: 2px;
}
.cal-cell {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.05);
}
.cal-cell.cal-empty {
  background: transparent;
}

/* Data table with inline bars (19) */
.an-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.an-table th, .an-table td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--border, #252c3e);
}
.an-table th { background: var(--bg-light, #1a2030); font-weight: 600; color: var(--text, #e2e8f0); }
.td-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
}
.an-bar {
  height: 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}
.an-bar-fill { height: 100%; border-radius: 2px; }

/* ── Auto-sync row ── */
.drive-autosync {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted, #6b758f);
  margin-bottom: 6px;
}

.drive-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.drive-toggle input[type="checkbox"] {
  accent-color: #00e87a;
  width: 14px;
  height: 14px;
}

.drive-select {
  background: var(--input-bg, #111827);
  border: 1px solid var(--border, #252c3e);
  border-radius: 6px;
  color: var(--text, #e2e8f0);
  font-size: 0.8rem;
  padding: 3px 8px;
}

/* ── Status message ── */
.drive-status-msg {
  font-size: 0.75rem;
  color: var(--text-dim, #4a5568);
  min-height: 1rem;
  margin: 0;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .drive-row {
    flex-direction: column;
  }

  .drive-row button {
    width: 100%;
  }
}
/* ============================================================
   INVESTMENT TOOLS PAGE
   New feature: PEGY Ratio Calculator + Compound Interest Calculator
   Reuses --bg / --surface / --green / --red / --yellow tokens
   and the existing .card / .form-row / .form-control components.
   ============================================================ */
.tools-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tool-card-head {
  margin-bottom: 22px;
}

.tool-header {
  margin-bottom: 8px;
  padding-bottom: 0;
  border-bottom: none;
}

.tool-subtitle {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 640px;
}

.tool-body {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 32px;
  align-items: start;
}

.tool-inputs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool-inputs .form-row { margin-bottom: 14px; }

.tool-output {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- PEGY result panel ---------- */
.pegy-result {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

.pegy-placeholder {
  color: var(--text-dim);
  font-size: 0.85rem;
  max-width: 320px;
}

.pegy-ticker {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.pegy-value {
  font-family: var(--mono);
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.verdict-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--sans);
}

.verdict-badge.undervalued { background: var(--green-dim); color: var(--green); }
.verdict-badge.fair        { background: rgba(255, 215, 64, 0.12); color: var(--yellow); }
.verdict-badge.overvalued  { background: var(--red-dim); color: var(--red); }

/* ---------- PEGY gauge visualization ---------- */
.pegy-gauge-wrap {
  padding: 0 4px;
}

.pegy-gauge {
  position: relative;
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--green) 0%,
    var(--green) 33.3%,
    var(--yellow) 33.3%,
    var(--yellow) 66.6%,
    var(--red) 66.6%,
    var(--red) 100%
  );
  opacity: 0.9;
}

.pegy-gauge-marker {
  position: absolute;
  top: -5px;
  left: 0%;
  width: 2px;
  height: 20px;
  background: var(--text);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(232, 234, 242, 0.6);
  transition: left 0.4s ease;
}

.pegy-gauge-marker::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
}

.pegy-gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.pegy-gauge-labels .undervalued-label { color: var(--green); }
.pegy-gauge-labels .fair-label        { color: var(--yellow); }
.pegy-gauge-labels .overvalued-label  { color: var(--red); }

/* ---------- Compound interest results ---------- */
.ci-results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.ci-result-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px;
}

.ci-result-item .stat-value { font-size: 1.15rem; }

.ci-result-item.value .stat-value    { color: var(--text); }
.ci-result-item.invested .stat-value { color: var(--blue); }
.ci-result-item.profit .stat-value   { color: var(--green); }
.ci-result-item.pct .stat-value      { color: var(--green); }

.ci-chart-wrap {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 6px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .tool-body { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .ci-results-grid { grid-template-columns: repeat(2, 1fr); }
  .pegy-value { font-size: 2.1rem; }
}

@media (max-width: 480px) {
  .ci-results-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ci-result-item { padding: 12px; }
  .ci-result-item .stat-value { font-size: 1rem; }
  .tool-subtitle { font-size: 0.8rem; }
}
