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

  :root {
    --bg: #f5f3ef;
    --surface: #ffffff;
    --surface2: #f0ede8;
    --border: rgba(0,0,0,0.1);
    --border-strong: rgba(0,0,0,0.18);
    --text: #1a1915;
    --text-muted: #6b6860;
    --text-hint: #9b9890;
    --accent: #2c5f8a;
    --accent-light: #e8f1f8;
    --danger: #c0392b;
    --radius: 10px;
    --radius-lg: 14px;
  }

  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 2rem 1.5rem;
  }

  h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 28px;
    font-weight: 400;
    color: var(--text);
    margin-bottom: 0.2rem;
  }
  .subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 1.75rem; }

  .metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 1.5rem;
  }
  .metric {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.125rem;
  }
  .metric-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 6px; }
  .metric-value { font-size: 22px; font-weight: 500; color: var(--text); }
  .metric-sub { font-size: 12px; color: var(--text-hint); margin-top: 3px; }

  .main-panels {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    margin-bottom: 1.5rem;
  }

  .panel {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
  }
  .panel-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 1.125rem;
  }

  label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 5px; }
  input[type="text"],
  input[type="number"],
  input[type="date"],
  select {
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    background: var(--surface2);
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
  }
  input:focus, select:focus { border-color: var(--accent); background: #fff; }
  select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6860' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

  .form-row { margin-bottom: 11px; }
  .form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 11px; }

  .add-btn {
    width: 100%;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 6px;
    transition: opacity 0.15s, transform 0.1s;
  }
  .add-btn:hover { opacity: 0.9; }
  .add-btn:active { transform: scale(0.98); }

  /* Report button — outlined style */
  .report-btn {
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    background: var(--surface);
    color: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, transform 0.1s;
  }
  .report-btn:hover { background: var(--accent-light); }
  .report-btn:active { transform: scale(0.98); }

  /* Modal overlay */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20,18,14,0.45);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    position: relative;
  }
  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
  }
  .modal-header h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 20px;
    font-weight: 400;
  }
  .modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 20px;
    padding: 4px;
    line-height: 1;
    border-radius: 6px;
  }
  .modal-close:hover { background: var(--surface2); color: var(--text); }

  .run-btn {
    padding: 9px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.15s;
    white-space: nowrap;
  }
  .run-btn:hover { opacity: 0.9; }

  .report-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 11px;
  }
  .report-controls-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 1.25rem;
  }
  .report-controls-row .form-row { flex: 1; margin-bottom: 0; }

  /* Result area */
  .report-result { margin-top: 1.25rem; }
  .result-summary {
    background: var(--accent-light);
    border: 1px solid rgba(44,95,138,0.2);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }
  .result-label { font-size: 13px; color: var(--accent); }
  .result-total { font-size: 26px; font-weight: 500; color: var(--accent); }
  .result-meta { font-size: 12px; color: var(--text-muted); }

  .result-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .result-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 6px 8px;
    border-bottom: 0.5px solid var(--border-strong);
  }
  .result-table td { padding: 8px 8px; border-bottom: 0.5px solid var(--border); color: var(--text); vertical-align: middle; }
  .result-table tr:last-child td { border-bottom: none; }
  .result-table .amt { text-align: right; font-weight: 500; }
  .no-results { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 14px; }

  .ledger { max-height: 300px; overflow-y: auto; }
  .ledger-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 0.5px solid var(--border);
  }
  .ledger-item:last-child { border-bottom: none; }
  .cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .ledger-info { flex: 1; min-width: 0; }
  .ledger-desc { font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ledger-meta { font-size: 11px; color: var(--text-hint); margin-top: 2px; }
  .ledger-amount { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; }
  .ledger-del { background: none; border: none; cursor: pointer; color: var(--text-hint); font-size: 15px; padding: 0 2px; line-height: 1; flex-shrink: 0; }
  .ledger-del:hover { color: var(--danger); }

  .empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); font-size: 14px; }
  .empty-state i { font-size: 30px; display: block; margin-bottom: 8px; color: var(--text-hint); }

  .charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .chart-wrap { position: relative; }

  .legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; }
  .legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }
  .legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

  .payment-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
    white-space: nowrap;
  }

  .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
  }

  @media (max-width: 768px) {
    .main-panels { grid-template-columns: 1fr; }
    .charts-row { grid-template-columns: 1fr; }
    .report-controls { grid-template-columns: 1fr; }
    .report-controls-row { flex-wrap: wrap; }
  }

/* ── Additions for full web app ── */
.topnav {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto 1.5rem auto;
}
.topnav .brand { font-family: 'DM Serif Display', serif; font-size: 20px; color: var(--text); text-decoration: none; }
.topnav .nav-links { display: flex; align-items: center; gap: 18px; }
.topnav a.nav-link { font-size: 13px; color: var(--text-muted); text-decoration: none; padding: 4px 2px; }
.topnav a.nav-link:hover, .topnav a.nav-link.active { color: var(--accent); }
.topnav .user-chip { font-size: 12px; color: var(--text-hint); }
.container { max-width: 1100px; margin: 0 auto; }

.flash { max-width: 1100px; margin: 0 auto 1rem auto; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; }
.flash.error { background: #fbeae8; color: var(--danger); border: 0.5px solid rgba(192,57,43,0.3); }
.flash.success { background: #e9f4ec; color: #1d7a3e; border: 0.5px solid rgba(29,122,62,0.3); }

.auth-wrap { max-width: 400px; margin: 8vh auto 0 auto; }
.auth-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; }
.auth-card h1 { margin-bottom: 0.3rem; }
.auth-card .subtitle { margin-bottom: 1.5rem; }
.auth-foot { font-size: 13px; color: var(--text-muted); margin-top: 1.25rem; text-align: center; }
.auth-foot a { color: var(--accent); }

.add-btn, .run-btn {
  width: 100%; padding: 10px; font-size: 14px; font-weight: 500; font-family: 'DM Sans', sans-serif;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.add-btn:hover, .run-btn:hover { filter: brightness(1.08); }

.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 1.5rem; }
.account-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 1rem 1.125rem; }
.account-name { font-size: 14px; font-weight: 500; }
.account-kind { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-hint); margin: 2px 0 8px; }
.account-balance { font-size: 20px; font-weight: 500; }
.account-balance.negative { color: var(--danger); }
.history-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 0.5px solid var(--border); font-size: 13px; }
.history-item:last-child { border-bottom: none; }
.tx-type { font-size: 11px; padding: 2px 7px; border-radius: 4px; font-weight: 500; white-space: nowrap; }
.tx-type.expense { background: #fbeae8; color: var(--danger); }
.tx-type.income { background: #e9f4ec; color: #1d7a3e; }
.tx-type.transfer { background: var(--accent-light); color: var(--accent); }
