:root {
    color-scheme: light;
    --ink: #1d2925;
    --muted: #78827d;
    --line: #e4e9e4;
    --paper: #f2f5f0;
    --white: #fff;
    --green: #27765e;
    --green-dark: #1d5e4a;
    --green-soft: #e6f2eb;
    --coral: #c85f4e;
    --coral-soft: #f8ebe7;
    --yellow: #f0c66c;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background-color: var(--paper);
    background-image: linear-gradient(rgba(39,118,94,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(39,118,94,.025) 1px, transparent 1px);
    background-size: 36px 36px;
    font: 14px/1.5 "Trebuchet MS", "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 23px; font-weight: 700; }
.brand-mark { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 9px 3px 9px 3px; color: #fff; background: var(--green); font: 700 17px/1 Georgia, serif; }
.brand-period { color: var(--coral); }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 1.25px; }
.button { display: inline-flex; min-height: 43px; align-items: center; justify-content: center; gap: 16px; padding: 0 17px; border: 0; border-radius: 5px; font-weight: 700; transition: background .18s ease, transform .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { border: 1px solid var(--line); color: var(--ink); background: #fff; }
.button-secondary:hover { border-color: #b7c8bb; background: #f6f9f5; }
.button-danger { color: #fff; background: var(--coral); }
.button-danger:hover { background: #ae4c3e; }
.button-dark { min-height: 39px; color: #fff; background: var(--ink); }
.button-dark:hover { background: #394841; }
.button-wide { width: 100%; margin-top: 2px; }
.button-quiet { display: grid; width: 35px; height: 35px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: transparent; font-size: 17px; transform: rotate(45deg); }
.button-quiet:hover { color: var(--coral); border-color: var(--coral); }

/* Account entry */
.auth-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(370px, .92fr) minmax(420px, 1.08fr); background: var(--white); }
.auth-panel { display: flex; width: min(390px, calc(100% - 48px)); flex-direction: column; justify-content: center; margin: auto; padding: 55px 0; }
.auth-panel .brand { margin-bottom: 78px; }
.auth-panel .eyebrow { margin-bottom: 17px; }
.auth-panel h1 { margin: 0; font: 400 48px/1.09 Georgia, "Times New Roman", serif; }
.auth-copy { max-width: 325px; margin: 17px 0 28px; color: var(--muted); font-size: 14px; }
.auth-footnote { margin: 17px 0 0; color: var(--muted); font-size: 12px; }
.auth-switch { margin-top: 11px; font-size: 12px; }
.auth-art { position: relative; display: flex; min-height: 620px; overflow: hidden; flex-direction: column; justify-content: space-between; padding: 46px 8%; background: #254c40; color: #fff; }
.auth-art::before { position: absolute; top: 19%; right: -15%; width: 70%; aspect-ratio: 1; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; content: ""; }
.auth-art::after { position: absolute; top: 28%; right: -6%; width: 53%; aspect-ratio: 1; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; content: ""; }
.art-caption { z-index: 1; color: #b7d3c4; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; }
.art-big-number { z-index: 1; align-self: flex-start; margin: auto 0; font: 400 clamp(42px, 5vw, 68px)/1.04 Georgia, "Times New Roman", serif; }
.art-scribble { position: absolute; z-index: 1; top: 51%; right: 25%; color: var(--yellow); font-size: 64px; transform: rotate(-35deg); }
.art-note { z-index: 1; display: flex; width: 215px; flex-direction: column; padding: 18px 20px; border-left: 3px solid var(--yellow); color: var(--ink); background: #f5f0e2; box-shadow: 0 14px 40px rgba(0,0,0,.15); transform: rotate(-3deg); }
.art-note span { color: var(--muted); font-size: 11px; }
.art-note strong { margin-top: 2px; font: 20px Georgia, serif; }
.art-note i { margin-top: 13px; color: var(--muted); font-size: 10px; font-style: normal; }

/* Forms and feedback */
.form-stack { display: grid; gap: 17px; }
.form-stack > label, .field-row > label { display: grid; gap: 7px; color: #48534e; font-size: 12px; font-weight: 700; }
.form-stack input:not([type="radio"]):not([type="checkbox"]):not([type="file"]), .form-stack textarea, .period-filter input, .type-filter select {
    width: 100%; min-width: 0; min-height: 42px; padding: 10px 11px; border: 1px solid #dfe5df; border-radius: 4px; outline: none; color: var(--ink); background: #fff; font-size: 13px; font-weight: 400;
}
.form-stack input:focus, .form-stack textarea:focus, .period-filter input:focus, .type-filter select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(39,118,94,.1); }
.form-stack textarea { min-height: 76px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.optional { color: #929b96; font-size: 10px; font-weight: 400; }
.upload-label input[type="file"] { width: 100%; padding: 10px; border: 1px dashed #cbd5cd; border-radius: 4px; color: var(--muted); background: #fbfcfa; font-size: 11px; }
.upload-help { margin-top: -3px; color: #929b96; font-size: 10px; font-weight: 400; }
.check-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.check-label input { accent-color: var(--coral); }
.notice { margin: 0 0 18px; padding: 11px 14px; border-radius: 4px; font-size: 13px; }
.notice-error { border: 1px solid #f0d2cb; color: #8d392c; background: #fff5f2; }
.notice-success { border: 1px solid #cfe5d6; color: #245c43; background: #eef7f0; }
.inline-form { display: inline-flex; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; clip-path: inset(50%); }

/* Dashboard */
.app-shell { min-height: 100vh; }
.topbar { display: flex; height: 70px; align-items: center; justify-content: space-between; padding: 0 max(5.5vw, 24px); border-bottom: 1px solid var(--line); background: #fff; }
.topbar .brand { font-size: 21px; }
.topbar .brand-mark { width: 29px; height: 29px; }
.topbar-right { display: flex; align-items: center; gap: 17px; }
.today-label { color: var(--muted); font-size: 12px; }
.user-chip { padding-left: 17px; border-left: 1px solid var(--line); font-size: 12px; font-weight: 700; }
.dashboard { width: min(1200px, calc(100% - 64px)); margin: 0 auto; padding: 41px 0 24px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading .eyebrow { margin-bottom: 4px; }
.page-heading h1 { margin: 0; font: 400 36px/1.15 Georgia, "Times New Roman", serif; }
.period-filter { display: flex; align-items: flex-end; gap: 9px; }
.period-filter label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.period-filter input { min-height: 38px; width: 142px; padding: 7px 8px; font-size: 12px; }
.period-divider { align-self: center; padding-top: 14px; color: #9da69f; }
.summary-grid { display: grid; grid-template-columns: 1.12fr 1fr 1fr; gap: 12px; margin-bottom: 34px; }
.summary-item { min-height: 140px; padding: 22px 25px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.summary-balance { border-color: #d7e4d8; background: #e8f1e8; }
.summary-label { display: flex; align-items: center; justify-content: space-between; color: #737e77; font-size: 10px; font-weight: 700; letter-spacing: .75px; }
.summary-value { margin-top: 12px; font: 400 27px/1.2 Georgia, "Times New Roman", serif; }
.summary-balance .summary-value { color: #214f40; font-size: 31px; }
.summary-meta { margin-top: 8px; color: #87918a; font-size: 11px; }
.summary-meta span { margin: 0 4px; color: var(--green); }
.summary-icon { display: grid; width: 23px; height: 23px; place-items: center; border-radius: 50%; font-size: 14px; }
.income-icon { color: var(--green); background: var(--green-soft); }
.expense-icon { color: var(--coral); background: var(--coral-soft); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .8fr); gap: 32px; align-items: start; }
.section-heading { display: flex; min-height: 48px; align-items: flex-start; justify-content: space-between; gap: 14px; }
.section-heading .eyebrow { margin-bottom: 3px; }
.section-heading h2 { margin: 0; font: 400 22px/1.25 Georgia, "Times New Roman", serif; }
.type-filter select { width: auto; min-height: 34px; padding: 6px 26px 6px 10px; font-size: 11px; }
.transaction-list { margin-top: 14px; border-top: 1px solid var(--line); }
.transaction-row { display: grid; min-height: 74px; grid-template-columns: 37px minmax(0, 1fr) auto 67px; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.transaction-row:hover { background: rgba(255,255,255,.62); }
.transaction-symbol { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; font-size: 17px; }
.symbol-income { color: var(--green); background: var(--green-soft); }
.symbol-expense { color: var(--coral); background: var(--coral-soft); }
.transaction-info { display: grid; min-width: 0; gap: 3px; }
.transaction-info strong { overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.transaction-info span { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.transaction-info i { padding: 0 3px; color: #aab1ac; font-style: normal; }
.transaction-amount { white-space: nowrap; color: var(--coral); font-size: 12px; font-weight: 700; }
.transaction-amount.amount-income { color: var(--green); }
.transaction-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; color: #98a19b; }
.transaction-actions a, .transaction-actions button { padding: 2px; border: 0; color: inherit; background: transparent; font-size: 14px; }
.transaction-actions a:hover, .transaction-actions button:hover { color: var(--green); }
.confirm-dialog { width: min(420px, calc(100% - 32px)); margin: auto; padding: 27px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; box-shadow: 0 24px 70px rgba(20,38,30,.2); }
.confirm-dialog::backdrop { background: rgba(17,31,25,.48); backdrop-filter: blur(2px); }
.confirm-mark { display: grid; width: 36px; height: 36px; margin-bottom: 20px; place-items: center; border-radius: 50%; color: var(--coral); background: var(--coral-soft); font: 700 18px Georgia, serif; }
.confirm-dialog .eyebrow { margin-bottom: 5px; }
.confirm-dialog h2 { margin: 0; font: 400 24px/1.25 Georgia, "Times New Roman", serif; }
.confirm-dialog > p:last-of-type { margin: 10px 0 24px; color: var(--muted); font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.dialog-actions form { margin: 0; }
.dialog-actions .button { min-height: 40px; }
.list-limit { color: var(--muted); font-size: 11px; }
.empty-state { display: grid; min-height: 176px; justify-items: center; align-content: center; gap: 5px; color: var(--muted); text-align: center; }
.empty-mark { display: grid; width: 35px; height: 35px; margin-bottom: 5px; place-items: center; border: 1px solid #ccd8ce; border-radius: 50%; color: var(--green); font-size: 20px; }
.empty-state strong { color: var(--ink); font-size: 13px; }
.empty-state span:last-child { font-size: 11px; }
.entry-panel { padding: 21px; border: 1px solid var(--line); border-top: 3px solid var(--green); border-radius: 5px; background: #fff; }
.entry-panel .section-heading { margin-bottom: 18px; }
.entry-panel .section-heading h2 { font-size: 20px; }
.cancel-edit { color: var(--coral); font-size: 11px; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0; padding: 4px; border: 1px solid var(--line); border-radius: 5px; }
.segment { display: flex; min-height: 35px; align-items: center; justify-content: center; border-radius: 3px; color: var(--muted); font-size: 11px; cursor: pointer; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment:has(input:checked[value="expense"]) { color: #9b4134; background: var(--coral-soft); font-weight: 700; }
.segment:has(input:checked[value="income"]) { color: #276047; background: var(--green-soft); font-weight: 700; }
.entry-panel .form-stack { gap: 14px; }
.category-section { margin-top: 36px; }
.category-section .section-heading { margin-bottom: 12px; }
.category-list { display: grid; gap: 14px; }
.category-row { display: grid; gap: 7px; }
.category-topline { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.category-topline small { margin-left: 5px; color: #98a19b; font-size: 10px; }
.category-topline strong { white-space: nowrap; font-size: 11px; }
.bar-track { height: 5px; overflow: hidden; border-radius: 5px; background: #e9ede9; }
.bar-fill { display: block; height: 100%; border-radius: inherit; }
.bar-income { background: #55a47c; }
.bar-expense { background: #d88270; }
.muted-copy { color: var(--muted); font-size: 12px; }
.page-footer { display: flex; justify-content: space-between; margin-top: 52px; padding-top: 15px; border-top: 1px solid var(--line); color: #909a93; font-size: 10px; }
.page-footer > span:first-child { color: var(--ink); font-weight: 700; }
.page-footer > span:first-child span:last-child { margin-left: 7px; color: #909a93; font-weight: 400; }

@media (max-width: 900px) {
    .content-grid { grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 25px; }
    .summary-item { padding: 19px 16px; }
    .summary-value { font-size: 23px; }
    .summary-balance .summary-value { font-size: 27px; }
    .dashboard { width: min(100% - 40px, 760px); }
}
@media (max-width: 700px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-panel { width: min(420px, calc(100% - 40px)); min-height: 100vh; padding: 35px 0; }
    .auth-panel .brand { margin-bottom: 54px; }
    .auth-art { display: none; }
    .topbar { height: 62px; padding: 0 20px; }
    .today-label { display: none; }
    .dashboard { width: calc(100% - 36px); padding-top: 29px; }
    .page-heading { align-items: flex-start; flex-direction: column; gap: 17px; }
    .page-heading h1 { font-size: 32px; }
    .period-filter { width: 100%; gap: 7px; }
    .period-filter label { flex: 1; min-width: 0; }
    .period-filter input { width: 100%; }
    .period-filter .button { padding: 0 11px; }
    .summary-grid { grid-template-columns: 1fr 1fr; margin-bottom: 28px; }
    .summary-item { min-height: 115px; padding: 16px 13px; }
    .summary-item:first-child { grid-column: 1 / -1; }
    .summary-label { font-size: 9px; letter-spacing: .4px; }
    .summary-value { margin-top: 9px; font-size: 19px; }
    .summary-balance .summary-value { font-size: 26px; }
    .summary-meta { font-size: 10px; }
    .content-grid { grid-template-columns: 1fr; gap: 31px; }
    .entry-panel { grid-row: 1; }
    .transaction-row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 9px; }
    .transaction-actions { grid-column: 2 / -1; justify-content: flex-start; margin-top: -13px; padding-bottom: 8px; }
    .transaction-info strong { font-size: 12px; }
    .transaction-amount { font-size: 11px; }
    .page-footer { margin-top: 35px; }
}
@media (max-width: 380px) {
    .dashboard { width: calc(100% - 28px); }
    .period-filter { flex-wrap: wrap; }
    .period-filter label { flex-basis: calc(50% - 14px); }
    .period-divider { display: none; }
    .period-filter .button { flex: 1; }
    .summary-item { padding-right: 9px; padding-left: 9px; }
    .summary-value { font-size: 17px; }
    .summary-balance .summary-value { font-size: 23px; }
}