/* Ledgerly — visual system
   Palette: deep green (money/ledger), warm paper neutrals, ink text.
   Type: Fraunces for headings/figures, Public Sans for UI/body. */

:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --ink: #1E2528;
  --ink-2: #4D5A5E;
  --ink-3: #7C888C;
  --hairline: #E4E1D8;
  --hairline-2: #D2CEC2;

  --green: #177245;
  --green-deep: #0F5231;
  --green-soft: #E7F0E9;
  --green-ink: #0E4A2C;

  --red: #B23A3A;
  --red-soft: #F8E9E7;
  --amber: #9A6A08;
  --amber-soft: #FBF2DF;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(30, 37, 40, .05), 0 4px 14px rgba(30, 37, 40, .06);
  --shadow-lift: 0 2px 4px rgba(30, 37, 40, .06), 0 10px 28px rgba(30, 37, 40, .10);

  --sans: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
p { margin: 0; }
a { color: var(--green-deep); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------------- shell */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 20;
}
.topbar-in {
  max-width: 1040px; margin: 0 auto; padding: 0 20px;
  height: 58px; display: flex; align-items: center; gap: 22px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--serif); font-size: 19px; font-weight: 600;
  color: var(--ink); text-decoration: none; letter-spacing: -.01em;
}
.brand svg { width: 26px; height: 26px; flex: none; }
.brand svg rect { fill: var(--green); }
.brand svg path { stroke: #fff; stroke-width: 1.8; fill: none; stroke-linecap: round; }

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  padding: 7px 13px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14.5px;
}
.nav a:hover { background: #F1EFE8; color: var(--ink); }
.nav a[aria-current="page"] { background: var(--green-soft); color: var(--green-ink); font-weight: 600; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { color: var(--ink-3); font-size: 13.5px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font: 600 14.5px/1.2 var(--sans); cursor: pointer; text-decoration: none;
  background: var(--green); color: #fff; transition: background .12s ease;
  min-height: 40px;
}
.btn:hover { background: var(--green-deep); }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--hairline-2); }
.btn.ghost:hover { background: #F1EFE8; color: var(--ink); }
.btn.danger-ghost { background: transparent; color: var(--red); border-color: #E7CFCF; }
.btn.danger-ghost:hover { background: var(--red-soft); }
.btn.big { padding: 12px 22px; font-size: 15.5px; border-radius: 11px; min-height: 46px; }
.btn.block { width: 100%; }
button.btn { font-family: var(--sans); }

/* ---------------------------------------------------------------- cards & forms */

.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }

.auth-card { max-width: 400px; margin: 7vh auto 0; padding: 32px; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-sub { color: var(--ink-2); font-size: 14.5px; margin-bottom: 22px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; color: var(--ink-2); }
.field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--hairline-2); background: #fff;
  font: 400 15px/1.4 var(--sans); color: var(--ink); min-height: 42px;
}
.field input:focus, .field select:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px rgba(23, 114, 69, .13); }
.field .hint { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.alert {
  padding: 11px 14px; border-radius: 9px; font-size: 14px; margin-bottom: 18px;
  border: 1px solid;
}
.alert.error { background: var(--red-soft); color: #7C2626; border-color: #EBCFCB; }
.alert.ok { background: var(--green-soft); color: var(--green-ink); border-color: #CFE2D4; }

.auth-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--ink-2); }
.auth-alt a { font-weight: 600; }

/* ---------------------------------------------------------------- page headers */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 27px; }
.page-head .sub { color: var(--ink-2); font-size: 14.5px; margin-top: 3px; }

/* ---------------------------------------------------------------- hero budget */

.budget-hero {
  background: linear-gradient(135deg, #10502F 0%, #177245 62%, #2A8757 100%);
  color: #fff; border-radius: var(--radius-lg);
  padding: 30px 32px 26px; margin-bottom: 26px;
  box-shadow: var(--shadow-lift);
  position: relative; overflow: hidden;
}
.budget-hero .ring { position: absolute; right: -60px; top: -80px; width: 280px; height: 280px; border-radius: 50%; border: 44px solid rgba(255,255,255,.06); }
.budget-hero .ring2 { position: absolute; right: 60px; bottom: -120px; width: 220px; height: 220px; border-radius: 50%; border: 34px solid rgba(255,255,255,.05); }
.budget-hero .label { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #BFE3CD; }
.budget-hero .figure { font-family: var(--serif); font-size: clamp(38px, 6vw, 52px); font-weight: 600; line-height: 1.1; margin: 8px 0 4px; letter-spacing: -.01em; }
.budget-hero .figure small { font-size: .45em; font-weight: 500; color: #D8EDE0; margin-right: 6px; }
.budget-hero .of { color: #CBE7D6; font-size: 15px; }
.budget-hero .of strong { color: #fff; font-weight: 600; }
.hero-track { margin-top: 18px; height: 10px; border-radius: 99px; background: rgba(255,255,255,.22); overflow: hidden; max-width: 560px; }
.hero-fill { height: 100%; border-radius: 99px; background: #EAF3E6; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.hero-fill.warn { background: #F5D48A; }
.hero-fill.over { background: #F3B9B0; }
.hero-meta { display: flex; justify-content: space-between; gap: 12px; max-width: 560px; margin-top: 9px; font-size: 13.5px; color: #CBE7D6; flex-wrap: wrap; }
.hero-meta strong { color: #fff; }

/* ---------------------------------------------------------------- stat tiles */

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 26px; }
.tile { padding: 18px 20px; }
.tile .t-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.tile .t-value { font-family: var(--serif); font-size: 27px; font-weight: 600; margin-top: 5px; letter-spacing: -.01em; }
.tile .t-note { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.tile .t-note.up { color: var(--red); }
.tile .t-note.down { color: var(--green-deep); }

/* ---------------------------------------------------------------- charts */

.chart-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; margin-bottom: 26px; }
.panel { padding: 20px 22px; }
.panel h2 { font-size: 17.5px; }
.panel .p-sub { font-size: 13px; color: var(--ink-3); margin: 3px 0 16px; }

.hbar-row { display: grid; grid-template-columns: 96px 1fr 76px; align-items: center; gap: 10px; padding: 7px 0; }
.hbar-row .c-name { font-size: 13.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 18px; display: flex; align-items: center; }
.hbar-fill { height: 14px; border-radius: 4px; min-width: 2px; transition: width .4s ease; }
.hbar-row .c-amt { font-size: 13.5px; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
.hbar-row .c-amt span { color: var(--ink-3); font-weight: 400; }
.hbar-empty { padding: 26px 0 20px; text-align: center; color: var(--ink-3); font-size: 14px; }

.vbar-chart { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding: 4px 4px 0; }
.vbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.vbar { width: 100%; max-width: 26px; border-radius: 4px 4px 0 0; min-height: 3px; transition: height .4s ease; position: relative; }
.vbar.current { box-shadow: inset 0 0 0 1.5px var(--green-deep); }
.vbar-col:hover .vbar { filter: brightness(1.08); }
.vbar-x { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.vbar-x.current { color: var(--ink); font-weight: 600; }
.vbar-val { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- expense list */

.exp-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 18px; border-bottom: 1px solid var(--hairline);
}
.exp-row:last-child { border-bottom: 0; }
.exp-dot { width: 34px; height: 34px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; }
.exp-dot svg { width: 16px; height: 16px; }
.exp-main { min-width: 0; flex: 1; }
.exp-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-cat { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.exp-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.exp-amt small { color: var(--ink-3); font-weight: 400; margin-right: 4px; }
.exp-day { font-size: 12px; color: var(--ink-3); width: 52px; text-align: right; flex: none; }
.exp-actions { display: flex; gap: 4px; flex: none; }
.icon-btn {
  background: transparent; border: 0; border-radius: 7px; padding: 7px;
  cursor: pointer; color: var(--ink-3); display: inline-flex; line-height: 0;
}
.icon-btn:hover { background: #F1EFE8; color: var(--ink); }
.icon-btn.delete:hover { background: var(--red-soft); color: var(--red); }
.icon-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.list-card { overflow: hidden; }
.list-empty { padding: 44px 24px; text-align: center; }
.list-empty h3 { font-size: 17px; margin-bottom: 5px; }
.list-empty p { color: var(--ink-2); font-size: 14px; margin-bottom: 18px; }

/* ---------------------------------------------------------------- forms on dashboard */

.dash-side { display: grid; grid-template-columns: 320px 1fr; gap: 22px; align-items: start; }
.quick-form { position: sticky; top: 78px; }
.quick-form h2 { font-size: 17.5px; margin-bottom: 14px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--hairline-2); background: #fff; border-radius: 99px;
  padding: 6px 13px; font: 500 13px/1.2 var(--sans); color: var(--ink-2);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip:hover { border-color: var(--green); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--green-soft); border-color: var(--green); color: var(--green-ink); font-weight: 600; }

/* ---------------------------------------------------------------- expenses page */

.filter-row { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filter-row select {
  padding: 8px 30px 8px 12px; border-radius: 9px; border: 1px solid var(--hairline-2);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234D5A5E' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  font: 500 13.5px/1.2 var(--sans); color: var(--ink); appearance: none; min-height: 38px;
}
.filter-row .spacer { flex: 1; }
.day-group { margin-bottom: 6px; }
.day-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 14px 18px 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .05em;
}
.day-head .day-total { font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none; color: var(--ink-2); }

/* ---------------------------------------------------------------- budget page */

.budget-panel { max-width: 560px; padding: 26px 28px; }
.budget-figure { font-family: var(--serif); font-size: 42px; font-weight: 600; letter-spacing: -.01em; }
.budget-figure small { font-size: 16px; color: var(--ink-3); font-family: var(--sans); font-weight: 500; }
.budget-help { color: var(--ink-2); font-size: 14.5px; margin: 8px 0 20px; line-height: 1.55; }

.month-nav { display: flex; align-items: center; gap: 14px; }
.month-nav a { display: inline-flex; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
.month-nav a:hover { background: #F1EFE8; }
.month-nav a[aria-disabled="true"] { opacity: .35; pointer-events: none; }
.month-nav .month-name { font-family: var(--serif); font-size: 19px; font-weight: 600; min-width: 150px; text-align: center; }

/* ---------------------------------------------------------------- footer */

.site-foot { text-align: center; padding: 26px 20px 34px; color: var(--ink-3); font-size: 12.5px; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 880px) {
  .chart-grid, .dash-side { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; gap: 12px; }
  .quick-form { position: static; }
  .nav { display: none; }
  .topbar-in { gap: 12px; }
}
@media (max-width: 560px) {
  .wrap { padding: 20px 14px 46px; }
  .budget-hero { padding: 24px 20px; }
  .who { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 23px; }
  .hbar-row { grid-template-columns: 78px 1fr 64px; }
  .day-group .exp-day { display: none; }
}

/* mobile nav: compact horizontal scroll row under topbar */
.mnav { display: none; }
@media (max-width: 880px) {
  .mnav {
    display: flex; gap: 4px; padding: 6px 14px; overflow-x: auto;
    background: var(--surface); border-bottom: 1px solid var(--hairline);
    position: sticky; top: 58px; z-index: 19;
  }
  .mnav a {
    padding: 7px 13px; border-radius: 8px; text-decoration: none;
    color: var(--ink-2); font-weight: 500; font-size: 14px; white-space: nowrap;
  }
  .mnav a[aria-current="page"] { background: var(--green-soft); color: var(--green-ink); font-weight: 600; }
}
