:root {
  --bg: #f3efe7;
  --ink: #1c1612;
  --muted: #74685c;
  --line: rgba(28, 22, 18, 0.1);
  --card: #fffdf9;
  --gold: #e09a12;
  --gold-deep: #b45309;
  --gold-soft: #fff4d6;
  --green: #0f9f6e;
  --green-soft: #e7f7ef;
  --red: #e11d48;
  --red-soft: #fde8ec;
  --blue: #2563eb;
  --sidebar: #1b1612;
  --sidebar-text: #f6f0e6;
  --radius: 22px;
  --shadow: 0 12px 32px rgba(60, 40, 10, 0.06);
  --sans: Manrope, "Segoe UI", sans-serif;
  --display: Manrope, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  background:
    radial-gradient(900px 420px at 110% -10%, #ffe7b8 0%, transparent 50%),
    radial-gradient(700px 380px at -10% 0%, #fde7d4 0%, transparent 46%),
    var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
::selection { background: #f3d48a; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 260px 1fr; height: 100%; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.brand-name { font-family: var(--sans); font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.brand-sub { color: #b5a89a; font-size: 12px; font-weight: 700; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  color: #d9cfc3;
  text-decoration: none;
  font-weight: 700;
}
.nav a:hover { background: rgba(255, 255, 255, 0.05); color: white; }
.nav a.active { background: rgba(224, 154, 18, 0.16); color: #ffd36a; }
.nav-ico { width: 22px; display: grid; place-items: center; }
.nav-ico svg { display: block; }
.side-card {
  margin-top: auto;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 14px;
}
.side-card span, .side-note { color: #b5a89a; font-size: 12px; font-weight: 700; }
.side-card strong {
  display: block;
  margin: 4px 0;
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #ffd36a;
}
.side-card small { color: #d9cfc3; font-weight: 600; }
.side-note { margin: 10px 4px 0; line-height: 1.4; }
#sideBalance { margin-top: auto; }

main { min-width: 0; height: 100%; overflow: auto; padding: 28px 32px 48px; }
.topbar {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
  max-width: 980px;
}
.actions { margin-left: auto; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-weight: 800; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
h1 { margin: 0; font-family: var(--sans); font-size: 32px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.subtitle { margin: 8px 0 0; color: var(--muted); font-weight: 600; }
.actions, .welcome-actions, .row-actions, .filters { display: flex; flex-wrap: wrap; gap: 8px; }
.view { display: flex; flex-direction: column; gap: 16px; max-width: 980px; }

.btn {
  border: 0;
  background: var(--ink);
  color: white;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 800;
  line-height: 1;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn.gold { background: linear-gradient(180deg, #f0b429, #d4890b); color: #1b1612; }
.btn.green { background: var(--green); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { padding: 9px 12px; font-size: 14px; }
.actions .btn-main {
  width: 214px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: white;
  position: relative;
  overflow: hidden;
  transform: skewX(-12deg);
  transition: transform .15s ease, filter .15s ease;
}
.actions .btn-main.in {
  background: linear-gradient(180deg, #8ee56f 0%, #3cbe4e 46%, #149a3d 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), inset 0 -10px 14px rgba(8, 90, 30, 0.18), 0 5px 0 #0d7a32;
}
.actions .btn-main.out {
  transform: skewX(12deg);
  background: linear-gradient(180deg, #8ecbff 0%, #3aa2f3 48%, #1c7fe6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), inset 0 -10px 14px rgba(10, 50, 140, 0.18), 0 5px 0 #1565b8;
}
.actions .btn-main::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 5px;
  height: 42%;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.btn-face {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  transform: skewX(12deg);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.actions .btn-main.out .btn-face { transform: skewX(-12deg); padding: 0 16px; }
.actions .btn-main:hover { filter: brightness(1.05); }
.actions .btn-main.in:hover { transform: skewX(-12deg) translateY(-2px); }
.actions .btn-main.out:hover { transform: skewX(12deg) translateY(-2px); }
.actions .btn-main.in:active { transform: skewX(-12deg) translateY(3px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 1px 0 #0d7a32; }
.actions .btn-main.out:active { transform: skewX(12deg) translateY(3px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 1px 0 #1565b8; }
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
}
.icon-btn:hover, .tx:hover .icon-btn { background: rgba(28, 22, 18, 0.05); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(520px 180px at 100% 0%, rgba(224, 154, 18, 0.38), transparent 55%),
    linear-gradient(160deg, #2a2118, #1b1612 62%);
  color: #f8f1e6;
  border-radius: 28px;
  padding: 28px;
}
.hero::after {
  content: "€";
  position: absolute;
  right: 18px;
  bottom: -36px;
  font-family: var(--sans);
  font-size: 180px;
  color: rgba(255, 255, 255, 0.04);
  pointer-events: none;
}
.hero-label { margin: 0; color: #d9cfc3; font-weight: 800; }
.hero-sum {
  position: relative;
  margin: 8px 0 16px;
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(36px, 4vw, 48px);
  letter-spacing: -0.03em;
  line-height: 1;
}
.hero-pills { position: relative; display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
}
.pill b { color: #ffd36a; }
.dash-now { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 14px; }
.spend-card, .goal-focus {
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.spend-card { background: linear-gradient(180deg, #e7f7ef, #fffdf9 70%); }
.goal-focus { background: var(--card); border-top: 4px solid var(--accent, var(--gold)); }
.dash-kicker { margin: 0 0 6px; color: var(--muted); font-size: 13px; font-weight: 800; }
.dash-sum { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin: 0 0 8px; }
.dash-hint { margin: 10px 0 12px; color: var(--muted); font-weight: 600; font-size: 14px; line-height: 1.4; }
.dash-h { margin: 0 0 10px; font-size: 18px; }
.together { margin: 0; color: var(--muted); font-weight: 700; font-size: 14px; }
.month-row { display: flex; flex-wrap: wrap; gap: 10px; }
.month-chip {
  width: min(100%, 200px);
  background: var(--card);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.month-chip span { display: block; color: var(--muted); font-size: 13px; font-weight: 800; }
.month-chip strong { display: block; margin-top: 4px; font-size: 22px; font-weight: 800; }
.track.thick { height: 12px; margin-top: 14px; }

.stat-grid, .grid-2, .goal-grid, .cat-grid { display: grid; gap: 14px; }
.stat-grid { grid-template-columns: repeat(3, minmax(0, 280px)); }
.grid-2 { grid-template-columns: 1.25fr 0.75fr; }
.goal-grid, .cat-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card, .stat, .goal-card, .cat-card, .empty {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card, .empty { padding: 18px 18px 16px; }
.stat { padding: 16px 18px; }
.stat span, .card-h span { color: var(--muted); font-size: 13px; font-weight: 800; }
.stat strong {
  display: block;
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.stat small, .hint, .tx-sub, .goal-name small { color: var(--muted); font-weight: 600; }
.stat small { display: block; margin-top: 6px; }
.card-h { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 12px; }
.card-h h2, .modal h3, .empty h3 { margin: 0; font-size: 20px; letter-spacing: -0.03em; }
.linkish { border: 0; background: none; color: var(--gold-deep); font-weight: 800; padding: 0; }

.goal-card, .cat-card { padding: 16px; border-top: 4px solid var(--accent, var(--gold)); }
.goal-top, .cat-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.goal-name, .cat-name { display: flex; gap: 10px; align-items: center; min-width: 0; }
.goal-name b, .cat-name b, .tx-title { display: block; }
.goal-name small, .clamp { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emoji-bubble {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center; font-size: 22px; background: #f6f1e8; flex: none;
}
.ring { width: 64px; height: 64px; flex: none; }
.goal-sums { margin: 14px 0 8px; font-weight: 800; }
.goal-sums b { font-family: var(--sans); font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.track { display: block; height: 8px; background: #f1ebe3; border-radius: 999px; overflow: hidden; }
.fill { display: block; height: 100%; border-radius: inherit; width: 0; transition: width 0.35s ease; }
.goal-line {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 0;
}
.goal-line + .goal-line { border-top: 1px solid var(--line); }
.goal-line-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.goal-line small { color: var(--muted); font-weight: 700; }
.goal-plan { margin: 10px 0 12px; color: var(--muted); font-weight: 700; font-size: 14px; min-height: 1.2em; }
.row-actions { margin-top: 4px; }
.help-banner {
  background: var(--gold-soft);
  border-radius: 18px;
  padding: 14px 16px;
  font-weight: 700;
}
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #f6f1e8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.tag.danger { background: var(--red-soft); color: var(--red); }
.tag.ok { background: var(--green-soft); color: var(--green); }

.cat-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 0; }
.cat-row + .cat-row { border-top: 1px solid var(--line); }
.cat-mid { min-width: 0; }
.cat-line { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; margin-bottom: 6px; }
.share { color: var(--muted); font-weight: 800; font-size: 13px; }

.tx-day { margin: 14px 0 0; color: var(--muted); font-size: 13px; font-weight: 800; }
.tx-day:first-child { margin-top: 0; }
.tx { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 0; }
.tx + .tx { border-top: 1px solid var(--line); }
.tx-main { min-width: 0; }
.tx-sub { font-size: 13px; }
.tx-sum { display: flex; align-items: center; gap: 4px; }
.tx-sum b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-sum small { display: block; text-align: right; }
.tx-sum-col { display: flex; flex-direction: column; align-items: flex-end; }
.plus { color: var(--green); }
.minus { color: var(--red); }
.save { color: var(--gold-deep); }
.back { color: var(--blue); }
.tx-actions { display: flex; }
@media (hover: hover) {
  .tx-actions { opacity: 0; }
  .tx:hover .tx-actions, .tx:focus-within .tx-actions { opacity: 1; }
}

.insights { display: flex; flex-direction: column; gap: 8px; }
.insight {
  background: var(--card);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-weight: 700;
}
.insight::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--gold); }

.empty { text-align: center; padding: 36px 20px; }
.empty-mark { font-size: 42px; }
.empty p { color: var(--muted); margin: 8px auto 16px; max-width: 460px; font-weight: 600; }
.archived { margin-top: 6px; }
.archived summary { cursor: pointer; font-weight: 800; color: var(--muted); padding: 8px 0; }
.muted { color: var(--muted); }

.filters { align-items: center; }
.seg { display: flex; padding: 4px; gap: 4px; background: rgba(28, 22, 18, 0.05); border-radius: 999px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 8px 12px; font-weight: 800; color: var(--muted); }
.seg button.active { background: white; color: var(--ink); box-shadow: var(--shadow); }
.search, .date-input, select.plain, .field input, .field select, .field textarea {
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 700;
}
.search { min-width: min(240px, 100%); }
.field input:focus, .field select:focus, .field textarea:focus, .search:focus, .date-input:focus, select.plain:focus {
  border-color: #e3b04a;
  box-shadow: 0 0 0 4px rgba(224, 154, 18, 0.15);
  outline: none;
}
.tx-meta { color: var(--muted); font-weight: 800; font-size: 13px; }
.more { align-self: center; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 170px; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.bar-pair { width: 100%; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.bar { width: 42%; max-width: 10px; border-radius: 999px 999px 3px 3px; min-height: 0; }
.bar.in { background: var(--green); }
.bar.out { background: #f0a3b2; }
.bar-col span { font-size: 10px; color: var(--muted); font-weight: 800; height: 14px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 13px; font-weight: 800; margin-bottom: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.in { background: var(--green); }
.dot.out { background: #f0a3b2; }

.donut-wrap { display: flex; gap: 18px; align-items: center; }
.donut {
  width: 190px; height: 190px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
}
.donut-hole {
  width: 118px; height: 118px; border-radius: 50%; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.donut-hole span { color: var(--muted); font-size: 12px; font-weight: 800; }
.donut-hole strong { font-size: 16px; letter-spacing: -0.03em; }
.legend-list { list-style: none; margin: 0; padding: 0; width: 100%; }
.legend-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; font-weight: 700; }
.legend-list li + li { border-top: 1px solid var(--line); }
.who { display: flex; gap: 8px; align-items: center; min-width: 0; }

.modal-back {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(28, 22, 18, 0.46);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 18px;
}
.modal {
  width: min(520px, 100%);
  background: #fffdf9;
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24);
  max-height: min(90vh, 820px);
  overflow: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.fields { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 800; color: var(--muted); }
.field textarea { min-height: 74px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { margin: 0; font-size: 13px; }
.hint.warn { color: var(--red); }
.hint button { background: none; border: 0; padding: 0; color: var(--gold-deep); font-weight: 800; text-decoration: underline; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 800; }
.chips, .swatches, .emoji-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .emoji-grid button {
  border: 1px solid var(--line); background: white; border-radius: 999px; font-weight: 800;
}
.chip { padding: 8px 12px; }
.emoji-grid button { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid white; box-shadow: 0 0 0 1px rgba(0,0,0,.12); padding: 0; }
.emoji-grid button.active, .swatch.active { outline: 2px solid var(--ink); }
.modal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.modal-actions .right { display: flex; gap: 8px; }

.toast {
  position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1b1612; color: white; border-radius: 999px;
  padding: 12px 16px; font-weight: 700; max-width: min(520px, calc(100% - 24px));
  box-shadow: 0 12px 30px rgba(0,0,0,.2);
}
.skeleton {
  height: 140px; border-radius: 24px;
  background: linear-gradient(90deg, #efe8dc, #f7f2ea, #efe8dc);
  background-size: 200% 100%;
  animation: shine 1.2s linear infinite;
}
.skeleton.short { height: 92px; }
.skeleton-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@keyframes shine { to { background-position: -200% 0; } }
.noscript { padding: 24px; font-weight: 800; }
.hero-sum, .stat strong, .side-card strong, .tx-sum b, .goal-sums b { font-variant-numeric: tabular-nums; }

@media (max-width: 980px) {
  .stat-grid, .grid-2, .skeleton-grid, .form-row, .dash-now { grid-template-columns: 1fr; }
  .donut-wrap { flex-direction: column; align-items: flex-start; }
  h1 { font-size: 32px; }
}
@media (max-width: 800px) {
  .app { display: block; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: auto; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    display: block; border-top: 1px solid rgba(255,255,255,.06);
  }
  .brand, #sideBalance { display: none; }
  .nav { flex-direction: row; justify-content: space-between; }
  .nav a { flex: 1; flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 2px; text-align: center; }
  main { height: 100%; padding: 18px 14px 96px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .toast { bottom: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
