@font-face {
  font-family: Geist;
  src: url("./geist-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --red: #a80f16;
  --red-dark: #6e0a0f;
  --green: #087847;
  --gold: #d8b867;
  --ink: #261b1c;
  --muted: #655b5c;
  --line: #e9e0e0;
  --bg: #f8f6f6;
  --card: #fff;
  --shadow: 0 1px 2px #36181808, 0 8px 24px #36181806;
  --wine: #580c14;
  --radius: 1.1rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Geist, ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  line-height: 1.5;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.muted { color: var(--muted); }

.shell { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 1.6rem 1rem 1.35rem;
  background: radial-gradient(120% 55% at 40% 0, #921720, transparent), var(--wine);
  color: #fff;
  overflow: auto;
}
.brand {
  display: flex;
  gap: .8rem;
  align-items: center;
  padding: .1rem .55rem 1.45rem;
  border-bottom: 1px solid #fff3;
}
.brand img, .login-brand img {
  display: block;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
}
.brand img { width: 3rem; height: 3rem; box-shadow: 0 0 0 3px #e3c87c35; }
.brand strong { display: block; font-size: 1.1rem; letter-spacing: -.03em; line-height: 1.2; }
.brand small { color: #f1d6d8; font-size: .875rem; }
.nav { display: grid; gap: .35rem; margin: 1.15rem 0 1.5rem; }
.nav a {
  position: relative;
  display: flex;
  gap: .7rem;
  align-items: center;
  min-height: 2.85rem;
  padding: .65rem .8rem;
  border: 1px solid transparent;
  border-radius: .7rem;
  color: #f5dedf;
  font-size: .925rem;
  font-weight: 500;
  text-decoration: none;
}
.nav a:hover, .mobile-menu a:hover { background: #fff1; color: #fff; }
.nav a.active { background: #ffffff24; border-color: #ffffff24; color: #fff; font-weight: 650; }
.nav a.active::before {
  content: "";
  position: absolute;
  inset: .68rem auto .68rem -.08rem;
  width: 3px;
  border-radius: 3px;
  background: var(--gold);
}
.nav .icon { width: 1.2rem; text-align: center; color: #f5dca0; font-size: 1.15rem; line-height: 1; }
.sidebar a:focus-visible, .mobile-menu a:focus-visible { outline-color: var(--gold); }
.sidebar-foot {
  margin-top: auto;
  padding: 1rem .55rem 0;
  border-top: 1px solid #fff3;
  color: #ebccce;
  font-size: .8rem;
  line-height: 1.55;
}

.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 5.2rem;
  padding: .95rem clamp(1.25rem, 3vw, 2.5rem);
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: clamp(1.25rem, 2.25vw, 1.65rem); letter-spacing: -.045em; line-height: 1.18; }
.topbar p { margin: .2rem 0 0; color: var(--muted); font-size: .875rem; }
.user-chip { display: flex; align-items: center; gap: .65rem; font-size: .875rem; font-weight: 600; }
.avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: #f9e7e9;
  color: var(--red-dark);
  font-weight: 750;
}
.content { max-width: 96rem; margin-inline: auto; padding: 1.8rem clamp(1.25rem, 3vw, 2.5rem) 4rem; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .85rem 1rem;
  margin-bottom: 1.35rem;
}
.toolbar strong { display: block; font-size: 1.075rem; letter-spacing: -.025em; }
.toolbar .muted { margin-top: .13rem; font-size: .925rem; }
.actions, .row-actions { display: flex; gap: .55rem; }
.actions { flex-wrap: wrap; }

.btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 2.7rem;
  padding: .55rem .95rem;
  border: 1px solid transparent;
  border-radius: .65rem;
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 2px 3px #6e0a0f25; }
.btn-primary:hover { background: #8a1117; }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 2px 3px #08784724; }
.btn-green:hover { background: #065f38; }
.btn-soft, .icon-btn { background: #fff; border-color: #e1d7d7; color: var(--ink); }
.btn-soft:hover, .icon-btn:hover { background: #f8f1f2; border-color: #dccbcd; }
.btn-danger { background: #fff5f5; color: #9d151c; border-color: #f2d7d9; }
.btn-danger:hover { background: #fce6e7; }
.btn-sm { min-height: 2.2rem; padding: .4rem .65rem; font-size: .875rem; white-space: nowrap; }
.icon-btn { flex: 0 0 auto; width: 2.5rem; min-height: 2.5rem; padding: 0; font-size: 1.1rem; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.card, .filter-card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card { padding: clamp(1rem, 2vw, 1.45rem); }
.metric { --metric-color: var(--red); --metric-tint: #faebed; }
.metric.income { --metric-color: var(--green); --metric-tint: #e8f5ee; }
.metric.balance { --metric-color: #77591e; --metric-tint: #fbf3df; }
.metric.pending { --metric-color: #8c4c0a; --metric-tint: #fcf1e3; }
.metric small {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .23rem .55rem;
  border-radius: .45rem;
  background: var(--metric-tint);
  color: var(--metric-color);
  font-size: .875rem;
  font-weight: 650;
}
.metric strong {
  display: block;
  margin: .65rem 0 .27rem;
  font-size: clamp(1.15rem, 2.1vw, 1.8rem);
  font-weight: 750;
  letter-spacing: -.055em;
  line-height: 1.12;
  overflow-wrap: anywhere;
}
.metric .trend { display: block; color: var(--muted); font-size: .875rem; line-height: 1.4; }
.metric strong, .amount, .category-item strong, .table td:nth-child(2) { font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(15rem, .42fr); align-items: start; gap: 1.15rem; }
.section-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .95rem; }
.section-title h2 { margin: 0; font-size: 1.125rem; letter-spacing: -.035em; }
.section-title a { color: var(--red); font-size: .875rem; font-weight: 650; text-decoration: none; }
.section-title a:hover { text-decoration: underline; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: .75rem; background: #fff; }
.table { width: 100%; min-width: 37rem; border-collapse: collapse; }
.table th {
  padding: .72rem .85rem;
  background: #f9f6f7;
  color: #5d5052;
  font-size: .875rem;
  font-weight: 650;
  text-align: left;
}
.table td { padding: .8rem .85rem; border-top: 1px solid #efe8e8; font-size: .9rem; vertical-align: middle; }
.table tr:hover td { background: #fefafa; }
.table td:nth-child(2), .table td:nth-child(4) { white-space: nowrap; }
.entry-main { font-weight: 650; overflow-wrap: anywhere; }
.entry-sub { margin-top: .17rem; color: var(--muted); font-size: .875rem; }
.amount { font-weight: 700; white-space: nowrap; }
.amount.income { color: var(--green); }
.amount.expense { color: var(--red); }
.badge { display: inline-flex; padding: .22rem .55rem; border-radius: 999px; font-size: .875rem; font-weight: 650; white-space: nowrap; }
.badge-paid { background: #e6f4ed; color: #08643d; }
.badge-pending { background: #fff0d9; color: #815000; }
.badge-overdue { background: #fbe7e9; color: #9d151c; }
.empty { width: 100%; padding: 2.7rem 1rem; color: var(--muted); text-align: center; }

.quick-panel {
  padding: clamp(1.15rem, 2.4vw, 1.65rem);
  border-radius: var(--radius);
  color: #fff;
  background:
    radial-gradient(60% 150% at 100% 0, #d8b86741, transparent),
    linear-gradient(135deg, #6e0a0f, #9b1420);
  box-shadow: var(--shadow);
}
.quick-panel h2 { margin: 0 0 .35rem; font-size: 1.2rem; letter-spacing: -.035em; }
.quick-panel p { margin: 0 0 1.15rem; color: #f7dfe1; font-size: .925rem; }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.quick-actions .btn { background: #fff; color: var(--wine); }
.quick-actions .btn:hover { background: #faeeef; }
.quick-actions .out { background: #fff2; color: #fff; border-color: #fff5; }
.quick-actions .out:hover { background: #fff3; }
.quick-actions .btn:focus-visible { outline-color: var(--gold); }

.filter-card { padding: 1rem; margin-bottom: 1.1rem; }
.filter-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .8rem; align-items: end; }
.field { display: grid; min-width: 0; gap: .4rem; }
.field[hidden] { display: none; }
.field label { color: #4b3b3d; font-size: .9rem; font-weight: 650; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.money-field { position: relative; }
.money-prefix {
  position: absolute;
  inset: 0 auto 0 .75rem;
  display: flex;
  align-items: center;
  color: var(--green);
  font-weight: 700;
  pointer-events: none;
}
.field .money-input { padding-inline-start: 2.55rem; font-variant-numeric: tabular-nums; }
.field input, .field select, .field textarea {
  width: 100%;
  min-width: 0;
  min-height: 2.7rem;
  padding: .55rem .75rem;
  border: 1px solid #ded2d3;
  border-radius: .65rem;
  background-color: #fff;
  color: var(--ink);
}
.field select {
  appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, #6a5b5c 50%), linear-gradient(135deg, #6a5b5c 50%, transparent 50%);
  background-position: right 1rem center, right .7rem center;
  background-size: .32rem .32rem;
  background-repeat: no-repeat;
}
.field input::placeholder, .field textarea::placeholder { color: #7a6b6d; }
.field :is(input, select, textarea):focus { border-color: #ad3a41; outline: 3px solid #a80f161a; outline-offset: 0; }
.field textarea { min-height: 5rem; resize: vertical; }
.field input[type="color"] { padding: .35rem; }
.field input[type="file"] { padding: .4rem; font-size: .9rem; }
::file-selector-button {
  margin-inline-end: .55rem;
  padding: .4rem .6rem;
  border: 0;
  border-radius: .45rem;
  background: #f6e9eb;
  color: var(--wine);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.form-grid .wide { grid-column: 1 / -1; }
.flash { margin-bottom: 1rem; padding: .75rem .9rem; border-radius: .65rem; font-weight: 600; }
.flash-success { background: #e3f4eb; color: #086a42; }
.flash-error { background: #fde8e8; color: #92161d; }

dialog {
  width: min(42rem, calc(100% - 1.25rem));
  max-height: calc(100% - 1.5rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 25px 80px #24070b45;
}
dialog::backdrop { background: #2114179c; backdrop-filter: blur(3px); }
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .7rem;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.dialog-head h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.04em; }
.dialog-body { padding: 1.15rem 1.25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .65rem; padding-top: 1.1rem; }

.login-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(23rem, .86fr);
  min-height: 100vh;
  min-height: 100svh;
  padding: .8rem;
  background: #faf8f8;
}
.login-visual {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 6vw, 5.5rem);
  border-radius: 1.4rem;
  color: #fff;
  background:
    radial-gradient(95% 78% at 5% 0, #e2b45a49, transparent 65%),
    radial-gradient(95% 110% at 95% 85%, #b41720, transparent 65%),
    linear-gradient(145deg, #661019, #810f1a 64%, #6e0a0f);
}
.login-visual::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: -7rem;
  bottom: -18rem;
  width: clamp(25rem, 43vw, 50rem);
  aspect-ratio: 1;
  border: 1px solid #ffe7a024;
  border-radius: 3rem;
  transform: rotate(45deg);
  box-shadow: 0 0 0 2.25rem #ffe7a00b, 0 0 0 4.5rem #ffe7a00b, 0 0 0 6.75rem #ffe7a009;
  pointer-events: none;
}
.login-brand { width: min(100%, 36rem); }
.login-brand img {
  width: clamp(5.5rem, 9vw, 8rem);
  aspect-ratio: 1;
  box-shadow: 0 0 0 .35rem #e8ca783f, 0 0 0 .8rem #e8ca7818, 0 10px 30px #42101658;
}
.login-brand h1 {
  max-width: 13.5ch;
  margin: 2.4rem 0 .95rem;
  font-size: clamp(2.15rem, 4.3vw, 4.65rem);
  font-weight: 670;
  letter-spacing: -.067em;
  line-height: 1.04;
  text-wrap: balance;
}
.login-brand p { max-width: 29rem; margin: 0; color: #f7dddf; font-size: clamp(1rem, 1.4vw, 1.15rem); }
.login-form { display: grid; place-items: center; padding: clamp(1.2rem, 4vw, 3.5rem); }
.login-box {
  width: min(100%, 28.5rem);
  padding: clamp(1.45rem, 3.25vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  background: #fff;
  box-shadow: 0 1px 2px #4b1a1f0b, 0 18px 45px #4b1a1f09;
}
.login-box h2 {
  margin: 0 0 .55rem;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 730;
  letter-spacing: -.06em;
  line-height: 1.05;
}
.login-box > p { margin: 0 0 1.6rem; color: var(--muted); text-wrap: pretty; }
.login-box .field { margin-bottom: 1rem; }
.login-box .field input { min-height: 3.05rem; }
.login-box .btn { width: 100%; min-height: 3.05rem; margin-top: .25rem; }

.chart {
  display: flex;
  align-items: end;
  gap: .55rem;
  height: 14.3rem;
  padding-top: .65rem;
  overflow-x: auto;
  background: repeating-linear-gradient(to bottom, transparent 0 2.73rem, #f1e9ea 2.73rem 2.79rem) top / 100% calc(100% - 1.6rem) no-repeat;
}
.chart:has(.empty) { align-items: center; background: #fcfafa; border-radius: .75rem; }
.bar-group { position: relative; display: flex; flex: 1 0 2rem; align-items: end; justify-content: center; gap: .25rem; height: 100%; padding-bottom: 1.65rem; }
.bar { width: min(1.55rem, 36%); min-height: 2px; border-radius: .35rem .35rem .12rem .12rem; }
.bar.income { background: var(--green); }
.bar.expense { background: var(--red); }
.bar-label { position: absolute; bottom: 0; color: var(--muted); font-size: .8rem; }
.legend { display: flex; flex-wrap: wrap; gap: .35rem .85rem; color: var(--muted); font-size: .875rem; }
.legend span::before { content: ""; display: inline-block; width: .56rem; height: .56rem; margin-right: .37rem; border-radius: .15rem; }
.legend .lg-income::before { background: var(--green); }
.legend .lg-expense::before { background: var(--red); }
.donut { position: relative; width: min(10rem, 78%); aspect-ratio: 1; margin: .9rem auto; border-radius: 50%; }
.donut::after { content: ""; position: absolute; inset: 16%; border-radius: 50%; background: #fff; }
.category-list { display: grid; gap: .45rem; margin-top: .95rem; }
.category-item { display: flex; justify-content: space-between; gap: .65rem; padding-top: .5rem; border-top: 1px solid var(--line); font-size: .875rem; }
.category-item strong { white-space: nowrap; }
.dot { display: inline-block; width: .57rem; height: .57rem; margin-right: .45rem; border-radius: 50%; }
.mobile-menu, .mobile-only { display: none; }

@media (max-width: 1150px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .quick-actions { max-width: 22rem; }
}

@media (max-width: 970px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar, .topbar p, .user-name { display: none; }
  .mobile-only { display: inline-flex; }
  .topbar { min-height: 4.25rem; padding: .7rem 1rem; }
  .content { padding: 1.1rem 1rem 3rem; }
  .cards, .grid-2 { gap: .7rem; }
  .card { border-radius: .9rem; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry-table, .entry-table tbody { display: block; min-width: 0; }
  .entry-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .entry-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: .45rem .65rem;
    padding: .8rem;
  }
  .entry-table tr + tr { border-top: 1px solid var(--line); }
  .entry-table td { padding: 0; border: 0; }
  .entry-table td:first-child { grid-column: 1 / -1; }
  .entry-table td:nth-child(2) { color: var(--muted); }
  .entry-table td:nth-child(3) { justify-self: end; }
  .entry-table td:nth-child(4) { white-space: normal; }
  .entry-table td:nth-child(5) { justify-self: end; }
  .entry-table td:nth-child(5):not(:has(a)) { display: none; }
  .entry-table td:nth-child(6) { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  .dialog-head, .dialog-body { padding-inline: 1rem; }
  .mobile-menu {
    position: fixed;
    z-index: 10;
    inset: 4.6rem .8rem auto;
    gap: .2rem;
    padding: .5rem;
    border-radius: .85rem;
    background: var(--wine);
    color: #fff;
    box-shadow: 0 10px 32px #41232b55;
  }
  .mobile-menu.open { display: grid; }
  .mobile-menu a { padding: .65rem .8rem; border-radius: .55rem; font-size: .95rem; text-decoration: none; }
  .login-page { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; padding: .6rem; }
  .login-visual { justify-content: start; padding: 1.55rem 1.35rem; border-radius: 1rem; }
  .login-visual::after { bottom: -24rem; right: -17rem; width: 33rem; }
  .login-brand { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .9rem; }
  .login-brand img { width: 3.5rem; box-shadow: 0 0 0 .22rem #e8ca7840; }
  .login-brand h1 { max-width: 19ch; margin: 0; font-size: clamp(1.15rem, 4.8vw, 1.85rem); letter-spacing: -.05em; text-wrap: wrap; }
  .login-brand p { display: none; }
  .login-form { align-items: start; padding: 1.2rem .35rem; }
  .login-box { padding: 1.4rem; }
}

@media (max-width: 420px) {
  .topbar { gap: .5rem; }
  .user-chip { gap: .4rem; }
  .avatar { width: 1.95rem; height: 1.95rem; }
  .content { padding-inline: .75rem; }
  .card { padding: .8rem; }
  .metric .trend { font-size: .82rem; }
  .toolbar .actions { width: 100%; }
  .toolbar .actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .icon-btn { transition: none; }
}
