:root {
  --bg: #f4f7f6;
  --card: #ffffff;
  --ink: #17211f;
  --muted: #5c6b66;
  --brand: #1f6f5c;
  --brand-2: #2e8b73;
  --brand-soft: #e5f2ee;
  --line: #dbe6e1;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --ok: #1b6b3a;
  --ok-soft: #e6f4ea;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(20, 45, 38, .07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, "DejaVu Sans", Arial, sans-serif;
  line-height: 1.65;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }
small, .muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: .7rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 1.25rem; color: var(--brand); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a {
  padding: .35rem .65rem; border-radius: 8px; color: var(--muted); font-size: .93rem;
}
.nav a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.nav a.active { background: var(--brand); color: #fff; }
.logout { margin-inline-start: auto; }

.container { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.footer {
  max-width: 1180px; margin: 0 auto; padding: 1rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line);
}

.flash {
  padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid var(--line);
  background: var(--card);
}
.flash.ok { background: var(--ok-soft); border-color: #b9dfc5; color: var(--ok); }
.flash.error { background: var(--danger-soft); border-color: #f2b8b5; color: var(--danger); }
.flash.warn { background: var(--warn-soft); border-color: #f0d48a; color: var(--warn); }

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid.three, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.card.tight { padding: .8rem .9rem; }
.card h2, .card h3 { margin-top: 0; }
.kpi .label { color: var(--muted); font-size: .85rem; }
.kpi .value { font-size: 1.55rem; font-weight: 800; margin-top: .15rem; }
.kpi .value.negative { color: var(--danger); }
.kpi .value.positive { color: var(--brand); }
.kpi .hint { color: var(--muted); font-size: .8rem; margin-top: .2rem; }

.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin: 1.4rem 0 .7rem; flex-wrap: wrap;
}
.section-head h1, .section-head h2 { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: .5rem .9rem; border-radius: 10px; cursor: pointer; font: inherit; font-size: .92rem;
}
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger.ghost { background: transparent; color: var(--danger); }
.btn.small { padding: .28rem .55rem; font-size: .8rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }

label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: .25rem; }
input, select, textarea {
  width: 100%; padding: .52rem .6rem; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); font: inherit; font-size: .93rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type="checkbox"] { width: auto; accent-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.inline { display: flex; align-items: center; gap: .45rem; }
.inline label { margin: 0; }
.checkbox-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.checkbox-row label { display: inline-flex; align-items: center; gap: .35rem; margin: 0; }

table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; }
th, td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
th { color: var(--muted); font-size: .82rem; font-weight: 700; background: #fbfdfc; }
tbody tr:hover { background: #fafcfb; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.negative { color: var(--danger); }
.positive { color: var(--brand); }
.center { text-align: center; }

.badge {
  display: inline-block; padding: .12rem .45rem; border-radius: 999px; font-size: .75rem;
  background: var(--brand-soft); color: var(--brand); border: 1px solid #cbe6dd;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #f0d48a; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: #f2b8b5; }
.badge.muted { background: #eef2f0; color: var(--muted); border-color: var(--line); }

.progress { height: 8px; background: #edf3f0; border-radius: 999px; overflow: hidden; margin: .4rem 0; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.progress.warn > span { background: linear-gradient(90deg, #b7791f, #d69e2e); }

.chart-row { margin: .55rem 0; }
.chart-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; }
.chart-row .progress { height: 12px; }

.fund-card { display: flex; flex-direction: column; gap: .25rem; }
.fund-card .top { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.fund-card .name { font-weight: 700; }
.fund-card .balance { font-size: 1.15rem; font-weight: 800; }
.fund-card .meta { color: var(--muted); font-size: .82rem; }

.hero {
  background: linear-gradient(135deg, #174d41, #2e8b73);
  color: #fff; border-radius: var(--radius); padding: 1.25rem 1.4rem; box-shadow: var(--shadow);
}
.hero .label { opacity: .8; font-size: .85rem; }
.hero .value { font-size: 2.2rem; font-weight: 800; }
.hero .sub { opacity: .85; font-size: .9rem; }
.hero .actions .btn { background: #fff; color: var(--brand); border-color: #fff; }
.hero .actions .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }

.split-row { display: grid; grid-template-columns: 1.4fr 1.2fr .8fr auto; gap: .5rem; align-items: end; margin-bottom: .5rem; }
@media (max-width: 720px) { .split-row { grid-template-columns: 1fr 1fr; } }
.split-row .remove { align-self: end; }

.note {
  border-inline-start: 4px solid var(--brand); background: var(--brand-soft);
  padding: .7rem .9rem; border-radius: 8px; color: #174d41; font-size: .88rem;
}
.note.warn { border-color: #b7791f; background: var(--warn-soft); color: #6b4700; }
.note.danger { border-color: var(--danger); background: var(--danger-soft); color: #7a1a15; }

.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs a { padding: .3rem .6rem; border-radius: 8px; background: #eef3f1; color: var(--muted); font-size: .85rem; }
.tabs a.active { background: var(--brand); color: #fff; }

.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; }
.right { text-align: right; }
.left { text-align: left; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.login-wrap { max-width: 420px; margin: 8vh auto; }
