:root {
    color-scheme: light;
    --ink: #171717;
    --muted: #707070;
    --line: #e3e3e3;
    --paper: #ffffff;
    --wash: #f6f6f4;
    --green: #147a42;
    --green-dark: #0d6133;
    --blue: #1559b7;
    --blue-dark: #10458e;
    --red: #c52c32;
    --red-dark: #a91d24;
    --mono: 'Courier New', Consolas, monospace;
    --sans: Arial, 'Helvetica Neue', sans-serif;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--paper);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #111; outline-offset: 2px; }
.site-header { min-height: 76px; display: flex; align-items: center; gap: 38px; padding: 0 max(26px, calc((100vw - 1240px) / 2)); border-bottom: 1px solid var(--line); }
.wordmark { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font: 500 12px var(--mono); white-space: nowrap; }
.wordmark-mark { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--ink); font: 500 12px var(--mono); }
.main-nav { display: flex; align-self: stretch; gap: 6px; }
.nav-button { position: relative; width: 94px; height: 75px; border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.nav-button.is-active { color: var(--ink); font-weight: 700; }
.nav-button.is-active::after { position: absolute; right: 12px; bottom: 0; left: 12px; height: 3px; background: var(--ink); content: ''; }
.header-add { margin-left: auto; }
.sign-out-button { margin-left: 0; }
.login-shell { width: min(410px, calc(100% - 32px)); margin: clamp(50px, 14vh, 140px) auto 60px; padding: 34px; border: 1px solid var(--ink); border-radius: 3px; background: #fff; }
.login-mark { display: grid; width: 44px; height: 44px; place-items: center; margin-bottom: 29px; border: 1px solid var(--ink); font: 500 14px var(--mono); }
.login-shell h1 { font-size: 27px; }
.login-intro { margin: 10px 0 26px; color: var(--muted); font-size: 13px; }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 600; }
.login-form input { width: 100%; height: 43px; padding: 10px 11px; border: 1px solid #cfcfcf; border-radius: 2px; background: #fff; color: var(--ink); font-size: 13px; }
.login-form .login-submit { margin-top: 2px; }
.login-message { min-height: 0; margin: -3px 0; color: var(--red-dark); font-size: 12px; }
.login-message:empty { display: none; }
.page-shell { width: min(1240px, calc(100% - 52px)); margin: 0 auto; padding: 42px 0 72px; }
.page-heading, .section-heading { display: flex; align-items: end; justify-content: space-between; gap: 22px; }
.page-heading { margin-bottom: 30px; }
.eyebrow, .period-label, .list-label { margin: 0 0 9px; color: var(--muted); font: 500 10px var(--mono); letter-spacing: 0; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: 32px; line-height: 1.1; font-weight: 600; }
h2 { margin: 0; font-size: 19px; line-height: 1.25; font-weight: 600; }
h3 { margin: 0; font-size: 14px; font-weight: 600; }
.period-label { margin: 0 0 4px; }
.button { display: inline-flex; width: 96px; min-width: 96px; height: 40px; align-items: center; justify-content: center; padding: 0 8px; border: 1px solid transparent; border-radius: 2px; color: #fff; font-size: 12px; font-weight: 600; transition: background-color 120ms ease, border-color 120ms ease; }
.button:disabled { opacity: .55; cursor: wait; }
.button-add { background: var(--green); }
.button-add:hover { background: var(--green-dark); }
.button-edit { background: var(--blue); }
.button-edit:hover { background: var(--blue-dark); }
.button-delete { background: var(--red); }
.button-delete:hover { background: var(--red-dark); }
.button-neutral { border-color: #cfcfcf; background: #fff; color: var(--ink); }
.button-neutral:hover { background: var(--wash); }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.summary-card { min-height: 145px; padding: 19px 20px; border: 1px solid var(--line); border-radius: 3px; background: #fff; }
.summary-card p { margin: 0 0 17px; color: var(--muted); font-size: 12px; font-weight: 600; }
.summary-card strong { display: block; overflow: hidden; font: 500 26px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.summary-card span { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.summary-net { border-color: var(--ink); background: var(--ink); color: #fff; }
.summary-net p, .summary-net span { color: #d0d0d0; }
.overview-columns { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 28px; margin-top: 37px; }
.panel { min-width: 0; }
.section-heading { margin-bottom: 16px; }
.section-heading .eyebrow { margin-bottom: 6px; }
.card-list { display: grid; gap: 9px; }
.record-card, .todo-card { display: flex; min-width: 0; align-items: center; gap: 14px; padding: 15px; border: 1px solid var(--line); border-radius: 3px; background: #fff; }
.record-icon { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border: 1px solid var(--line); border-radius: 2px; font: 500 20px var(--mono); }
.record-icon.is-income { color: var(--green); }
.record-icon.is-cost { color: var(--ink); }
.record-copy, .todo-copy { min-width: 0; flex: 1; }
.record-title-line { display: flex; min-width: 0; align-items: center; gap: 9px; }
.record-title-line h3, .todo-copy h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-label { flex: 0 0 auto; padding-left: 9px; border-left: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.record-meta { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.card-notes { margin: 7px 0 0; color: #555; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.attachment-link { display: inline-block; margin-top: 8px; color: var(--ink); font-size: 12px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.record-amount { flex: 0 0 auto; font: 500 14px var(--mono); white-space: nowrap; }
.record-amount.is-income-text { color: var(--green-dark); }
.record-card-compact { padding: 11px 12px; gap: 11px; }
.record-card-compact .record-icon { width: 30px; height: 30px; flex-basis: 30px; font-size: 18px; }
.record-card-compact .record-amount { font-size: 12px; }
.receipt-thumb { width: 40px; height: 40px; flex: 0 0 40px; border: 1px solid var(--line); border-radius: 2px; object-fit: cover; }
.card-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.todo-card { align-items: flex-start; }
.todo-check { display: grid; width: 22px; height: 22px; flex: 0 0 22px; place-items: center; margin-top: 1px; border: 1px solid #888; border-radius: 2px; background: #fff; color: var(--ink); font-size: 14px; }
.todo-check[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.todo-card.is-complete .todo-copy h3 { color: var(--muted); text-decoration: line-through; }
.todo-card .card-actions { margin-left: 8px; }
.empty-state { padding: 22px 16px; border: 1px dashed #ccc; color: var(--muted); font-size: 12px; text-align: center; }
.empty-state p { margin: 0; }
.page-section-heading { margin-bottom: 22px; }
.filter-row { display: flex; gap: 6px; margin-bottom: 14px; }
.filter-button { width: 96px; min-width: 96px; height: 40px; border: 1px solid var(--line); border-radius: 2px; background: #fff; color: var(--muted); font-size: 12px; font-weight: 600; }
.filter-button.is-selected { border-color: var(--ink); background: var(--ink); color: #fff; }
.record-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.todo-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px; }
.list-label { margin: 0 0 11px; }
.notice { margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--ink); background: var(--wash); font-size: 13px; }
.notice.is-error { border-color: var(--red); color: var(--red-dark); }
.editor-dialog { width: min(560px, calc(100% - 28px)); max-height: min(90vh, 800px); padding: 25px; border: 1px solid var(--ink); border-radius: 3px; background: #fff; color: var(--ink); }
.editor-dialog::backdrop { background: rgb(0 0 0 / 42%); }
.editor-dialog form { display: grid; gap: 16px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.dialog-heading h2 { font-size: 21px; }
.dialog-close { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 2px; background: #fff; font-size: 25px; line-height: 1; }
.editor-dialog label { display: grid; gap: 7px; font-size: 12px; font-weight: 600; }
.editor-dialog input:not([type="checkbox"]):not([type="file"]), .editor-dialog select, .editor-dialog textarea { width: 100%; min-height: 42px; padding: 10px 11px; border: 1px solid #cfcfcf; border-radius: 2px; background: #fff; color: var(--ink); font-size: 13px; }
.editor-dialog textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 14px; }
.editor-dialog input[type="file"] { max-width: 100%; font-size: 12px; }
.file-hint { color: var(--muted); font-size: 11px; font-weight: 400; }
.editor-dialog .remove-receipt { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

@media (max-width: 860px) {
    .site-header { gap: 16px; padding: 0 20px; }
    .main-nav { margin-left: auto; }
    .header-add { margin-left: 0; }
    .page-shell { width: calc(100% - 40px); }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .overview-columns { grid-template-columns: 1fr; gap: 30px; }
}

@media (max-width: 620px) {
    .site-header { min-height: 66px; flex-wrap: wrap; gap: 0 10px; padding: 9px 14px 0; }
    .wordmark { margin-right: auto; }
    .wordmark > span:not(.wordmark-mark) { display: none; }
    .main-nav { order: 3; width: 100%; height: 43px; justify-content: space-around; margin: 5px 0 0; }
    .nav-button { width: 33.333%; height: 43px; }
    .nav-button.is-active::after { right: 15px; left: 15px; }
    .header-add { width: 96px; min-width: 96px; margin-left: 0; }
    .sign-out-button { width: 96px; min-width: 96px; }
    .page-shell { width: calc(100% - 28px); padding-top: 28px; }
    .page-heading { margin-bottom: 22px; }
    h1 { font-size: 28px; }
    .period-label { font-size: 9px; text-align: right; }
    .summary-card { min-height: 123px; padding: 14px; }
    .summary-card p { margin-bottom: 14px; }
    .summary-card strong { font-size: 21px; }
    .summary-card span { font-size: 10px; }
    .section-heading { align-items: center; }
    .record-list, .todo-columns { grid-template-columns: 1fr; }
    .record-card { gap: 9px; padding: 11px; }
    .record-card, .todo-card { flex-wrap: wrap; }
    .record-card .card-actions, .todo-card .card-actions { width: 100%; justify-content: flex-end; gap: 7px; margin-left: 0; }
    .record-card .button, .todo-card .button { width: 96px; min-width: 96px; height: 40px; padding: 0 8px; font-size: 12px; }
    .record-amount { font-size: 11px; }
    .record-title-line { gap: 6px; }
    .type-label { padding-left: 6px; font-size: 9px; }
    .receipt-thumb { width: 32px; height: 32px; flex-basis: 32px; }
    .todo-card { gap: 9px; padding: 12px; }
    .filter-row { gap: 5px; }
    .filter-button { width: auto; min-width: 0; flex: 1; padding: 0 5px; }
    .form-grid { grid-template-columns: 1fr; }
    .editor-dialog { padding: 19px; }
}
