/* Direction: warm family ledger — cream paper, ink text, chunky rounded cards, friendly grotesque */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-background: #faf6ee;
  --color-surface: #ffffff;
  --color-surface-2: #f3ecdd;
  --color-text: #1f1b16;
  --color-text-secondary: #6b6257;
  --color-muted: #a39a8a;
  --color-border: #e7dcc6;
  --color-primary: #1f6f4a;
  --color-primary-hover: #18593c;
  --color-accent: #f59e0b;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, sans-serif;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow: 0 1px 2px rgba(31,27,22,.06), 0 8px 24px rgba(31,27,22,.07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-background);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
  background-image: radial-gradient(#e7dcc6 1px, transparent 1px);
  background-size: 22px 22px;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(250,246,238,.9), rgba(250,246,238,.75));
}
main, header .wrap, footer .wrap { position: relative; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.02em; line-height: 1.15; margin: 0; }
.muted { color: var(--color-text-secondary); }

header.site {
  position: sticky; top: 0; z-index: 20;
  background: rgba(250,246,238,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}
.site-bar { display: flex; align-items: center; gap: 14px; padding: 14px 0; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--color-text); color: #fff;
}
.logo-mark svg { width: 22px; height: 22px; }
.month-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.month-label { font-weight: 700; min-width: 150px; text-align: center; font-family: var(--font-display); font-size: 18px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--color-border);
  background: var(--color-surface); cursor: pointer; display: grid; place-items: center; color: var(--color-text);
}
.icon-btn:hover { background: var(--color-surface-2); }
.icon-btn svg { width: 18px; height: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 15px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .15s ease-out, background .15s ease-out;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-surface-2); }
.btn-danger-ghost { background: transparent; color: var(--color-danger); min-height: 36px; padding: 6px 10px; font-size: 13px; }
.btn-danger-ghost:hover { background: #fee2e2; }

.hero { padding: 36px 0 8px; }
.hero-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px;
}
.total-card { background: var(--color-text); color: #fdf9f0; border-color: var(--color-text); overflow: hidden; position: relative; }
.total-card::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245,158,11,.45), transparent 70%);
}
.total-eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; color: #d8cdb8; font-weight: 700; }
.total-amount { font-family: var(--font-display); font-size: clamp(44px, 6vw, 64px); line-height: 1; margin: 8px 0; }
.total-sub { color: #d8cdb8; display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.total-pills { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.mini-pill { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); color: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

.layout { display: grid; grid-template-columns: 380px 1fr; gap: 18px; padding: 18px 0 60px; align-items: start; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

.card h2 { font-size: 22px; margin-bottom: 4px; }
.card .sub { color: var(--color-text-secondary); font-size: 14px; margin: 0 0 16px; }
.field { margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type="text"], input[type="number"], input[type="date"], input[type="month"], select, textarea {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1.5px solid var(--color-border);
  background: #fffdf8; padding: 10px 12px; font: inherit; color: inherit;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid rgba(31,111,74,.3); outline-offset: 1px; border-color: var(--color-primary); }
textarea { resize: vertical; min-height: 56px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.error { color: var(--color-danger); font-size: 13px; min-height: 18px; margin: 8px 0; }
.success { color: var(--color-primary); font-size: 13px; min-height: 18px; margin: 8px 0; font-weight: 600; }

.cat-select-wrap { display: flex; gap: 8px; }
.color-preview { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--color-border); flex: none; }

.chart-wrap { position: relative; height: 240px; }
.legend { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.legend .bar { height: 8px; border-radius: 99px; background: var(--color-surface-2); overflow: hidden; flex: 1; }
.legend .fill { height: 100%; border-radius: 99px; }
.legend .amt { font-weight: 700; margin-left: auto; white-space: nowrap; }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 6px 8px 6px 12px;
  background: var(--color-surface-2); border: 1px solid var(--color-border); font-size: 13px; font-weight: 600;
}
.chip button { border: 0; background: #fff; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; line-height: 1; }
.cat-form { display: flex; gap: 8px; margin-top: 12px; }
.cat-form input[type="text"] { flex: 1; }
input[type="color"] { width: 48px; height: 44px; border-radius: 12px; border: 1.5px solid var(--color-border); background: #fff; padding: 4px; cursor: pointer; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 190px; }
.search { flex: 1; min-width: 160px; }

.expense-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.expense {
  display: flex; gap: 12px; align-items: center; padding: 13px 14px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md); background: #fffdf8;
}
.exp-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; font-family: var(--font-display); }
.exp-main { min-width: 0; flex: 1; }
.exp-note { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-meta { font-size: 13px; color: var(--color-text-secondary); }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; color: #fff; vertical-align: middle; margin-right: 6px; }
.exp-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.del { border: 0; background: transparent; cursor: pointer; color: var(--color-muted); border-radius: 10px; width: 36px; height: 36px; display: grid; place-items: center; }
.del:hover { background: #fee2e2; color: var(--color-danger); }

.empty { text-align: center; padding: 34px 16px; border: 1.5px dashed var(--color-border); border-radius: var(--radius-md); background: #fffdf8; }
.empty p { color: var(--color-text-secondary); margin: 8px 0 0; }

dialog { border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 0; max-width: 440px; width: calc(100vw - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(31,27,22,.45); }
.modal-body { padding: 24px; }
.modal-body h2 { margin-bottom: 6px; }

footer { border-top: 1px solid var(--color-border); padding: 22px 0 34px; color: var(--color-text-secondary); font-size: 14px; }

@media (max-width: 640px) {
  .month-label { min-width: 110px; font-size: 16px; }
  .site-bar { flex-wrap: wrap; }
  .row2 { grid-template-columns: 1fr; }
  .card { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
