:root {
  --ink: #17231e;
  --muted: #68746f;
  --paper: #f5f3ec;
  --panel: #fffefa;
  --line: #deddd4;
  --green: #1c624b;
  --green-dark: #124533;
  --green-soft: #dcebe3;
  --mint: #8ac6a7;
  --red: #af4d45;
  --red-soft: #f4dfdc;
  --gold: #d7a64a;
  --shadow: 0 18px 50px rgba(32, 48, 40, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--paper); color: var(--ink); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 85% 5%, rgba(138,198,167,.17), transparent 24rem), var(--paper); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.site-header { height: 76px; padding: 0 clamp(20px, 5vw, 72px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(23,35,30,.1); background: rgba(245,243,236,.88); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; gap: 11px; align-items: center; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--green); color: white; font-family: Georgia, serif; font-size: 23px; font-weight: 700; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.brand span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-family: Georgia, serif; font-size: 20px; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 4px; letter-spacing: .02em; }
.header-actions { display: flex; align-items: center; gap: 22px; }
.header-actions form { margin: 0; }
.nav-link { border: 0; padding: 4px 0; background: none; text-decoration: none; color: var(--muted); font-size: 14px; cursor: pointer; }
.nav-link:hover { color: var(--green); }

.page-shell { width: min(1380px, calc(100% - 40px)); margin: 0 auto; padding: 55px 0 70px; }
.site-footer { padding: 20px; text-align: center; color: var(--muted); font-size: 12px; border-top: 1px solid rgba(23,35,30,.08); }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; }
h1 { font-size: clamp(36px, 4.2vw, 58px); line-height: .98; letter-spacing: -.035em; margin-bottom: 14px; }
h2 { font-size: 25px; margin-bottom: 0; }
.hero-row { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 32px; }
.hero-copy, .form-heading > p:last-child { color: var(--muted); margin-bottom: 0; }
.sync-status { display: flex; align-items: center; gap: 7px; margin: 13px 0 0; color: var(--muted); font-size: 12px; }
.sync-status > span { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(138,198,167,.18); }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 17px; border: 1px solid transparent; border-radius: 11px; text-decoration: none; font-weight: 750; font-size: 14px; cursor: pointer; transition: transform .15s, background .15s, border .15s; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--green); box-shadow: 0 8px 20px rgba(28,98,75,.18); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { background: var(--ink); color: white; }
.button-ghost { border-color: var(--line); background: transparent; }
.button-danger { border-color: #e9c8c4; background: var(--red-soft); color: #8d382f; }
.button-wide { width: 100%; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 20px; }
.summary-card { display: flex; align-items: center; gap: 17px; min-height: 126px; padding: 24px; background: var(--panel); border: 1px solid rgba(23,35,30,.09); border-radius: var(--radius); box-shadow: var(--shadow); }
.summary-card p { margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.summary-card strong { font-family: Georgia, serif; font-size: clamp(26px, 3vw, 36px); letter-spacing: -.03em; }
.summary-icon { display: grid; place-items: center; flex: 0 0 43px; height: 43px; border-radius: 50%; font-size: 20px; }
.income-card .summary-icon { background: var(--green-soft); color: var(--green); }
.expense-card .summary-icon { background: var(--red-soft); color: var(--red); }
.balance-card { background: var(--green-dark); color: white; }
.balance-card p { color: #bad0c7; }
.balance-card .summary-icon { background: rgba(255,255,255,.1); }
.balance-card.negative { background: #6f332d; }

.panel { background: var(--panel); border: 1px solid rgba(23,35,30,.09); border-radius: var(--radius); box-shadow: var(--shadow); }
.filter-panel { padding: 18px 20px; margin-bottom: 20px; }
.filter-form { display: grid; grid-template-columns: 1fr 1fr 1.2fr 1.2fr auto; gap: 12px; align-items: end; }
label { display: flex; flex-direction: column; gap: 7px; color: #435049; font-size: 12px; font-weight: 750; }
input, select, textarea { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); outline: none; font-size: 14px; font-weight: 500; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(28,98,75,.1); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(290px, .75fr); gap: 20px; align-items: start; }
.movements-panel, .category-panel { overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 24px 25px 19px; }
.text-link, .back-link { color: var(--green); font-size: 13px; font-weight: 750; text-decoration: none; }
.transaction-list { border-top: 1px solid var(--line); }
.transaction-row { display: grid; grid-template-columns: 42px minmax(150px, 1fr) 60px 128px 50px; gap: 13px; align-items: center; padding: 17px 24px; border-bottom: 1px solid #ebe9e2; }
.transaction-row:last-child { border-bottom: 0; }
.transaction-badge { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; font-weight: 900; }
.transaction-badge.income { color: var(--green); background: var(--green-soft); }
.transaction-badge.expense { color: var(--red); background: var(--red-soft); }
.transaction-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.transaction-main strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.transaction-main span, .transaction-row time { color: var(--muted); font-size: 12px; }
.transaction-amount { text-align: right; }
.transaction-amount.income { color: var(--green); }
.transaction-amount.expense { color: var(--ink); }
.icon-button { color: var(--muted); font-size: 11px; font-weight: 700; text-decoration: none; text-align: right; }
.source-label { color: var(--green); font-weight: 750; }
.source-lock { color: var(--green); font-size: 11px; font-weight: 750; text-align: right; }
.empty-state { padding: 55px 20px 60px; text-align: center; border-top: 1px solid var(--line); }
.empty-state > span { display: block; color: var(--mint); font-size: 40px; }
.empty-state h3 { margin: 12px 0 6px; font-size: 24px; }
.empty-state p, .muted-copy { color: var(--muted); }
.empty-state p { margin-bottom: 22px; }

.category-list { padding: 3px 25px 27px; }
.category-item { margin-top: 20px; }
.category-item > div:first-child { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.progress-track { height: 6px; border-radius: 10px; background: #e8e8e1; overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--mint)); }
.muted-copy { padding: 5px 25px 30px; line-height: 1.6; font-size: 14px; }

.form-page { width: min(820px, 100%); margin: 0 auto; }
.narrow-page { width: min(620px, 100%); }
.back-link { display: inline-block; margin-bottom: 32px; }
.form-heading { margin-bottom: 28px; }
.form-heading h1 { font-size: clamp(38px, 5vw, 50px); }
.transaction-form { padding: 28px; }
.kind-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 25px; padding: 0; border: 0; }
.kind-switch legend { margin-bottom: 8px; color: #435049; font-size: 12px; font-weight: 750; }
.kind-switch label { position: relative; }
.kind-switch input { position: absolute; opacity: 0; pointer-events: none; }
.kind-switch span { display: grid; place-items: center; min-height: 45px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 14px; cursor: pointer; }
.kind-switch input:checked + span { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); box-shadow: inset 0 0 0 1px var(--green); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.full-width { grid-column: 1 / -1; }
.optional { color: var(--muted); font-weight: 500; }
.amount-input { font-size: 20px; font-weight: 750; }
.form-actions { display: flex; gap: 11px; align-items: center; margin-top: 28px; padding-top: 23px; border-top: 1px solid var(--line); }
.action-spacer { flex: 1; }
.stack-form { display: flex; flex-direction: column; gap: 18px; }
.stack-form small { color: var(--muted); font-weight: 500; }

.flash-stack { position: fixed; top: 90px; right: 22px; z-index: 20; width: min(390px, calc(100% - 44px)); }
.flash { padding: 13px 16px; margin-bottom: 8px; border: 1px solid; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; font-weight: 650; }
.flash-success { color: var(--green-dark); border-color: #b8d4c4; background: #edf7f1; }
.flash-error { color: #7d312a; border-color: #e7beb9; background: #fff0ee; }

.auth-page { background: linear-gradient(135deg, #102e25 0%, #174c3a 52%, #c9a75c 150%); }
.auth-page::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .22; background-image: radial-gradient(circle at 20% 25%, #fff 0 1px, transparent 1px), radial-gradient(circle at 80% 70%, #fff 0 1px, transparent 1px); background-size: 48px 48px, 64px 64px; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px 20px; }
.login-card { position: relative; width: min(440px, 100%); padding: 42px; background: var(--panel); border: 1px solid rgba(255,255,255,.4); border-radius: 24px; box-shadow: 0 30px 90px rgba(0,0,0,.25); }
.login-brand { margin-bottom: 30px; }
.brand-mark-large { width: 52px; height: 52px; font-size: 31px; border-radius: 15px; }
.login-card h1 { font-size: 44px; }
.login-intro { color: var(--muted); line-height: 1.55; margin-bottom: 25px; }
.privacy-note { margin: 22px 0 0; text-align: center; color: var(--muted); font-size: 11px; }
.error-card { width: min(600px, 100%); margin: 70px auto; padding: 45px; text-align: center; }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { min-height: 100px; }
  .filter-form { grid-template-columns: 1fr 1fr; }
  .filter-button { grid-column: 1 / -1; }
  .content-grid { grid-template-columns: 1fr; }
  .category-panel { order: -1; }
}

@media (max-width: 620px) {
  .site-header { height: 66px; padding: 0 16px; }
  .brand small, .nav-link:not(.button-link) { display: none; }
  .header-actions { gap: 10px; }
  .page-shell { width: min(100% - 24px, 1380px); padding-top: 34px; }
  .hero-row { align-items: stretch; flex-direction: column; }
  .hero-row .button { width: 100%; }
  .filter-form { grid-template-columns: 1fr; }
  .filter-button { grid-column: auto; }
  .transaction-row { grid-template-columns: 38px minmax(0, 1fr) auto; padding: 15px; }
  .transaction-row time { display: none; }
  .transaction-amount { grid-column: 2; text-align: left; }
  .icon-button, .source-lock { grid-column: 3; grid-row: 1 / span 2; }
  .panel-heading { padding: 20px 17px 16px; }
  .panel-heading .text-link { font-size: 11px; }
  .form-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; }
  .transaction-form, .login-card { padding: 23px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .button { flex: 1 1 auto; }
  .action-spacer { display: none; }
}
