:root {
  color-scheme: light;
  --bg: #f5f5ef; --paper: #fffefa; --ink: #213a32; --muted: #596b60; --line: #d8ded2;
  --forest: #173f35; --green: #275d46; --mint: #e1eedf; --rust: #98552c; --gold: #edb575;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "Microsoft JhengHei", sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
[hidden], .symbols { display: none !important; }
.shell { width: min(1160px, calc(100% - 64px)); margin: 0 auto; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #c87b34; outline-offset: 3px; }
.icon { display: inline-block; width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.topbar { border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar-inner, .brand, .account, .footer, .footer > span, .eyebrow, .month-tools, .month-control, .section-bar, .views, .panel-heading, .dialog-heading, .dialog-actions { display: flex; align-items: center; }
.topbar-inner { justify-content: space-between; gap: 16px; min-height: 72px; }
.brand { gap: 10px; flex: none; font-weight: 800; font-size: 1.2rem; letter-spacing: .04em; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--forest); color: #f2dcac; }
.brand small, .eyebrow, .paper-top span, .footer { font: 700 .68rem/1.5 ui-monospace, Consolas, monospace; letter-spacing: .13em; }
.brand small { color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line); }
.account { gap: 12px; min-width: 0; font-size: .84rem; color: var(--muted); }
#account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-layout { display: grid; grid-template-columns: 1.1fr 1fr; margin: clamp(32px, 6vh, 76px) auto; max-width: 1020px; border: 1px solid var(--line); border-radius: 24px; overflow: hidden; background: var(--paper); box-shadow: 0 18px 55px #243c2e0c; }
.cover { display: flex; flex-direction: column; justify-content: space-between; gap: 28px; padding: clamp(30px, 4.2vw, 60px); position: relative; isolation: isolate; overflow: hidden; color: #fffdf1; background-color: var(--forest); background-image: linear-gradient(90deg, #efffe808 1px, transparent 1px), linear-gradient(#efffe808 1px, transparent 1px); background-size: 30px 30px; }
.cover::after { content: ""; position: absolute; z-index: -1; right: -140px; bottom: -180px; width: 490px; height: 490px; border: 1px solid #f4eac01a; border-radius: 50%; box-shadow: 0 0 0 34px #f2ebba08, 0 0 0 68px #f2ebba08; }
.eyebrow { gap: 8px; color: var(--green); }
.eyebrow.light { color: #d4dfc4; }
.rule { height: 2px; width: 22px; background: var(--gold); }
.cover h1 { margin: 22px 0 16px; font-size: clamp(2.25rem, 4.3vw, 3.8rem); letter-spacing: -.065em; line-height: 1.28; }
.cover h1 span { color: var(--gold); }
.cover p { color: #e1e9d9; line-height: 1.9; }
.paper { width: min(100%, 310px); align-self: center; padding: 14px 20px; color: #34523e; background: #f5edcf; border-radius: 3px; box-shadow: 5px 6px 0 #b2c4a0, 10px 15px 23px #08261a50; transform: rotate(-4deg); }
.paper-top, .paper-foot { display: flex; align-items: center; justify-content: space-between; }
.paper-top { padding-bottom: 8px; border-bottom: 2px solid #6c8066; }
.paper-top span { font-size: .58rem; }
.paper-days, .paper-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.paper i { font: normal .75rem/2 ui-monospace, monospace; }
.paper-week i { border: 1px solid #b8bea6; border-right: 0; font-weight: bold; }
.paper-week i:last-child { border-right: 1px solid #b8bea6; }
.paper-foot { gap: 8px; margin-top: 10px; }
.paper-foot span { height: 1px; width: 25%; background: #a9b296; }
.paper-foot b { transform: rotate(-7deg); color: #925335; border: 1px solid; padding: 1px 6px; font-size: .68rem; }
.auth-card { padding: clamp(28px, 4.1vw, 58px); align-self: center; min-width: 0; }
.auth-card h2, .page-heading h1 { margin: 8px 0; letter-spacing: -.05em; line-height: 1.22; }
.auth-card h2 { font-size: clamp(1.75rem, 2.8vw, 2.25rem); }
.muted, .hint { color: var(--muted); }
.auth-card > p, .page-heading p, .list-summary, .empty p { font-size: .9rem; }
.segmented { margin: 24px 0 20px; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 10px; background: #eef1e9; }
.segmented button, .views button { border: 0; color: var(--muted); background: transparent; border-radius: 7px; padding: 8px; font-weight: 650; }
.segmented [aria-pressed="true"] { background: var(--paper); color: var(--forest); box-shadow: 0 1px 4px #253f2926; }
.form-stack { display: grid; gap: 16px; }
label { display: block; font-size: .87rem; font-weight: 650; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea { width: 100%; min-width: 0; margin-top: 6px; padding: 10px 12px; color: var(--ink); background: var(--paper); border: 1px solid #b9c6b8; border-radius: 8px; font-size: 1rem; }
input::placeholder, textarea::placeholder { color: #79837a; }
textarea { resize: vertical; }
.primary, .quiet, .danger, .icon-btn, .views button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; }
.primary, .quiet, .danger { min-height: 42px; border: 1px solid transparent; border-radius: 8px; padding: 9px 18px; font-weight: 650; }
.primary { background: var(--forest); color: white; }
.primary:hover:not(:disabled), .danger:hover:not(:disabled) { filter: brightness(1.18); }
.quiet { background: var(--paper); border-color: var(--line); color: var(--ink); }
.quiet:hover, .icon-btn:hover:not(:disabled) { background-color: #eaf0e5; }
.danger { background: #923f33; color: white; }
.small { min-height: 36px; padding: 6px 12px; font-size: .85rem; white-space: nowrap; }
.preview-link, .text-btn { color: var(--green); background: none; border: 0; font-weight: 650; padding: 3px; }
.preview-link { display: block; margin: 14px auto 0; font-size: .87rem; }
.preview-link:hover, .text-btn:hover { text-decoration: underline; }
.notice { padding: 10px 13px; border: 1px solid #ded4b5; border-radius: 8px; color: #64562f; background: #f8f3e4; font-size: .84rem; overflow-wrap: anywhere; }
#auth-message { margin-top: 14px; font-size: .82rem; }
.notice.error { color: #803b31; background: #fff0e9; border-color: #e6bdb1; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; padding: 38px 0 24px; }
.page-heading h1 { font-size: clamp(2rem, 4vw, 2.9rem); }
.month-tools { gap: 8px; flex-wrap: wrap; }
.month-control { border: 1px solid var(--line); border-radius: 9px; background: var(--paper); padding: 2px; }
.month-control input { padding: 5px 0; width: 10em; margin: 0; border: 0; text-align: center; background: transparent; font-variant-numeric: tabular-nums; }
.icon-btn { width: 34px; height: 34px; border-radius: 7px; border: 0; background: transparent; color: var(--green); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 0 0 25px; }
#preview-note { margin-bottom: 16px; }
.metric, .panel { background: var(--paper); border: 1px solid var(--line); border-radius: 15px; }
.metric { padding: 17px 19px; }
.metric > div { display: flex; align-items: center; gap: 8px; font-size: .87rem; font-weight: 650; }
.metric-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--green); background: var(--mint); }
.metric-icon.rust { background: #f5e7d7; color: var(--rust); }
.metric strong { display: block; margin: 10px 0 3px; font-size: clamp(1.2rem, 2vw, 1.7rem); line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric small { color: var(--muted); font-size: .76rem; }
.balance { background: var(--forest); color: white; }
.balance .metric-icon { background: #37624a; color: #f1cd99; }
.balance small { color: #d1decc; }
.section-bar { justify-content: space-between; gap: 8px; padding: 0 0 12px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.views { gap: 4px; }
.views button { padding: 9px 14px; font-size: .93rem; }
.views [aria-pressed="true"] { background: #dce9da; color: var(--forest); }
.records { display: grid; grid-template-columns: minmax(255px, .72fr) minmax(0, 1.8fr); align-items: start; gap: 18px; margin-bottom: 36px; }
.records.cash { grid-template-columns: minmax(0, 1fr); }
.panel { padding: 20px; min-width: 0; }
.panel h2, dialog h2 { font-size: 1.22rem; letter-spacing: -.025em; margin: 3px 0 0; }
.weekdays, .calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; gap: 3px; }
.weekdays { margin: 19px 0 6px; color: var(--muted); font-size: .72rem; font-weight: 650; }
.day { min-height: 38px; display: grid; align-content: center; border-radius: 7px; font: 550 .82rem/1.15 ui-monospace, Consolas, monospace; }
.day.worked { background: var(--mint); color: #24573b; }
.day.today { box-shadow: inset 0 0 0 1.5px #b57b3b; }
.day small { font-size: .65rem; }
.calendar-key { display: flex; align-items: center; gap: 6px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .73rem; color: var(--muted); }
.calendar-key i { width: 9px; height: 9px; background: #6d976c; border-radius: 2px; }
.calendar-key span { margin-left: auto; }
.panel-heading { justify-content: space-between; gap: 8px; }
.count, .kind { padding: 2px 8px; border-radius: 5px; background: #edf0e7; color: var(--muted); font-size: .75rem; white-space: nowrap; }
.list-summary { color: var(--muted); margin: 10px 0 18px; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 8px; text-align: left; }
th { background: #f1f3ec; color: var(--muted); font-size: .75rem; white-space: nowrap; }
td { overflow-wrap: anywhere; }
td.numeric, td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 3px; }
.row-actions .icon-btn { width: 30px; height: 32px; }
.remove { color: var(--rust); }
.kind.income { background: var(--mint); color: var(--green); }
.kind.expense { background: #f4e6dc; color: var(--rust); }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.empty .icon { width: 28px; height: 28px; }
.empty h3 { font-size: 1rem; color: var(--ink); margin: 7px 0 4px; }
.footer { justify-content: space-between; gap: 12px; padding: 20px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .68rem; }
.footer > span { gap: 6px; }
.footer b { color: #aa8251; }
dialog { width: min(455px, calc(100% - 28px)); max-height: 90dvh; padding: 25px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); color: var(--ink); box-shadow: 0 18px 70px #0a291f30; }
dialog::backdrop { background: #122e26a6; }
.dialog-heading, .dialog-actions { justify-content: space-between; }
.dialog-actions { justify-content: flex-end; gap: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; padding: 0; border: 0; margin: 0; }
.hint { font-size: .8rem; }
#delete-description { overflow-wrap: anywhere; }
#load-status { margin-bottom: 25px; }
@media (max-width: 900px) {
  .records { grid-template-columns: minmax(0, 1fr); }
  .calendar-panel { display: grid; grid-template-columns: minmax(0, 1fr); }
  .day { min-height: 32px; }
}
@media (max-width: 700px) {
  .shell { width: min(100% - 28px, 560px); }
  .topbar-inner { min-height: 60px; }
  .brand small { display: none; }
  .account { gap: 6px; }
  .auth-layout { grid-template-columns: 1fr; margin: 18px auto 25px; border-radius: 16px; }
  .cover { padding: 23px; }
  .cover h1 { font-size: 2rem; margin: 10px 0 0; }
  .cover h1 br { display: none; }
  .cover p, .paper { display: none; }
  .auth-card { padding: 24px; }
  .page-heading { align-items: start; flex-direction: column; padding: 24px 0 18px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 17px; }
  .metric { padding: 13px; }
  .views button { padding: 8px; }
  .panel { padding: 15px; }
  .section-bar { flex-wrap: wrap; }
  .day { min-height: 35px; }
  #entry-table, #entry-table tbody { display: block; }
  #entry-table thead { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  #entry-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; padding: 13px 0; border-top: 1px solid var(--line); }
  #entry-table td { border: 0; padding: 0; min-width: 0; white-space: normal; }
  #entry-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .7rem; }
  .footer { letter-spacing: .04em; }
}
