:root {
  --surface: #FBFDFB; --card: #FFFFFF; --tert: #F2F5F3; --text: #1A1F1C; --muted: #737A76;
  --brand: #274E3A; --brand2: #DCE8E1; --brand3: #EAF0EC; --error: #D64E40; --warn: #D9943B;
  --border: #E6EBE8; --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }
h1 { font-size: 26px; font-weight: 500; margin: 0; }
h3 { font-weight: 500; margin: 8px 0 4px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 12px; }

.topbar { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { font-weight: 600; color: var(--brand); text-decoration: none; font-size: 17px; white-space: nowrap; }
nav { display: flex; align-items: center; gap: 4px; overflow-x: auto; }
nav a, nav .link { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; }
nav a.active { background: var(--brand3); color: var(--brand); }
.link { background: none; border: 0; cursor: pointer; font: inherit; }
.inline { display: inline; margin: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: var(--radius);
  background: var(--brand); color: #fff; border: 0; font-size: 15px; font-weight: 500; cursor: pointer; text-decoration: none; transition: transform .1s, opacity .1s; }
.btn:hover { opacity: .92; } .btn:active { transform: scale(.98); }
.btn.secondary { background: var(--brand2); color: var(--brand); }
.btn.danger { background: var(--error); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }

.flash { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: var(--brand3); color: var(--brand); }
.flash.err { background: #FBE7E4; color: #9B2C20; }
.flash.warn { background: #FCF1E2; color: #8A5A17; }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; flex-wrap: wrap; }
.link-row { text-decoration: none; color: inherit; } .link-row:hover { border-color: #B8C4BC; }
.grow { flex: 1; min-width: 160px; }
.title { font-weight: 500; font-size: 16px; }
.right { text-align: right; }
.amount { color: var(--brand); font-weight: 500; font-size: 16px; }
.chev { color: #B8C4BC; font-size: 22px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--brand3); color: var(--brand); display: flex; align-items: center; justify-content: center; font-weight: 500; flex-shrink: 0; }
.avatar.lg { width: 72px; height: 72px; font-size: 30px; margin: 0 auto; }
.empty { text-align: center; padding: 48px 16px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--brand3); border-radius: var(--radius); padding: 12px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-weight: 500; color: var(--brand); font-size: 17px; }
.year-filter { margin-bottom: 12px; }
.year-filter select { margin-left: 8px; }

.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { flex: 1; }

.form { margin-bottom: 24px; }
fieldset { border: 1px solid var(--border); background: var(--card); border-radius: var(--radius); padding: 12px 16px 4px; margin: 0 0 20px; }
legend { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 0 6px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--tert); border: 1px solid transparent; border-radius: 8px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); background: #fff; }
.has-err input, .has-err select, .has-err textarea { border-color: var(--error); }
.err-msg { display: block; color: var(--error); font-size: 12px; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.segment-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.segment { display: flex; background: var(--tert); border-radius: 8px; padding: 3px; margin-bottom: 12px; }
.segment label { flex: 1; margin: 0; }
.segment input { display: none; }
.segment span { display: block; text-align: center; padding: 8px; border-radius: 6px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }
.segment input:checked + span { background: var(--brand); color: #fff; }

.summary { background: var(--brand3); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; color: var(--brand); }
.sum-row { display: flex; justify-content: space-between; align-items: center; margin: 0 0 10px; font-size: 14px; color: var(--brand); }
.sum-row small { color: var(--muted); }
.sum-row.toggle input { width: 22px; height: 22px; margin: 0; accent-color: var(--brand); }
.summary hr { border: 0; border-top: 1px solid var(--brand2); margin: 6px 0 10px; }
.sum-row.tot { font-size: 16px; font-weight: 500; margin: 0; }
.sum-row.tot span:last-child { font-size: 24px; }

body.auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 32px 24px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .muted { margin: 0 0 20px; }
.auth-card .btn { width: 100%; }
.logo { width: 52px; height: 52px; border-radius: 14px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; margin-bottom: 16px; }

@media (max-width: 560px) {
  .grid2, .stats { grid-template-columns: 1fr; }
  .brand { display: none; }
  .right { text-align: left; }
}
