* { box-sizing: border-box; }
[hidden] { display: none !important; }
@font-face {
  font-family: "Source Han Sans CN";
  src: url("source-han-sans-cn-vf.woff2") format("woff2");
  font-weight: 250 900;
  font-display: swap;
}
:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei UI", sans-serif;
  color: #182744;
  background: #f7f2e7;
  --ink: #182744;
  --muted: #526078;
  --brand: #1847a2;
  --tint: #e5edfc;
  --action: #ffc434;
  --action-hover: #f4b51d;
  --action-ink: #202b43;
  --surface: #fffdf8;
  --line: #e8e2d7;
  --soft: #f1eee6;
  --income-ink: #775012;
  --red: #a53938;
}
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; }
button, summary { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2.05rem, 5vw, 3rem); line-height: 1.14; letter-spacing: -.045em; }
h2 { font-size: 1.13rem; letter-spacing: -.018em; }
.icon-library, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { display: block; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 38px; padding: 37px 20px 25px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { background: var(--brand); color: var(--action); display: grid; place-items: center; border-radius: 15px; width: 43px; height: 43px; font-weight: 760; }
.brand strong, .brand small { display: block; }
.brand small, .sidebar-foot { color: var(--muted); font-size: .8rem; }
.sidebar-foot { margin-top: auto; }
.navigation { display: grid; gap: 5px; }
.navigation button { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 6px 12px; text-align: left; border: 0; border-radius: 18px; color: var(--muted); background: transparent; font-weight: 630; }
.navigation button[aria-current] { color: var(--brand); background: var(--tint); }
.nav-icon { display: grid; place-items: center; }
main { width: min(100%, 1100px); margin-inline: auto; padding: 42px clamp(23px, 5vw, 64px) 48px; }
.topbar, .section-head, .category-label, .transaction, .account-line, .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar { margin-bottom: 25px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
#language-switch { text-decoration: none; font-size: .81rem; white-space: nowrap; }
#language-switch:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.eyebrow { display: flex; align-items: center; gap: 9px; color: var(--muted); margin-bottom: 8px; font-size: .82rem; font-weight: 650; }
.eyebrow span { color: var(--muted); font-size: .73rem; font-weight: 540; padding: 4px 7px; background: var(--soft); border-radius: 8px; }
.primary, .quiet { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; min-height: 44px; font-weight: 650; }
.primary { background: var(--action); color: var(--action-ink); border-radius: 17px; padding: 11px 17px; white-space: nowrap; }
.primary:hover { background: var(--action-hover); }
.quiet { background: var(--soft); color: var(--ink); border-radius: 14px; padding: 8px 13px; }
.quiet:hover { background: var(--tint); }
.icon-button { width: 44px; height: 44px; flex: none; padding: 0; border-radius: 50%; }
.overview-stack, .account-list { display: grid; gap: 17px; }
.surface { background: var(--surface); border-radius: 26px; padding: clamp(16px, 3vw, 26px); min-width: 0; }
.section-head { flex-wrap: wrap; margin-bottom: 13px; }
.period-controls { display: flex; align-items: center; gap: 3px; padding: 2px; border-radius: 28px; background: #ffffff2b; }
.period-controls .quiet { background: transparent; color: inherit; }
.period-controls strong { min-width: 7ch; text-align: center; font-size: .86rem; }
.hero { --hero-inset: clamp(16px, 3vw, 26px); color: white; background: var(--brand); padding: 0; overflow: hidden; }
.hero .section-head { margin: 0; padding: var(--hero-inset) var(--hero-inset) 15px; }
.hero .period-controls { color: white; background: #ffffff24; }
.hero .period-controls .quiet:focus-visible { outline-color: #fff4cb; outline-offset: -3px; }
.surface:not(.hero) .period-controls { background: var(--soft); }
.hero h2 { font-size: .89rem; color: white; font-weight: 650; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric { padding: 14px var(--hero-inset) 16px; }
.metric span { display: block; font-size: .85rem; margin-bottom: 4px; }
.metric strong { font-size: clamp(1.03rem, 2.6vw, 1.45rem); }
.metric:first-child { grid-column: 1 / -1; padding-top: 0; padding-bottom: 22px; }
.metric:first-child span { color: #e0ebff; }
.metric:not(:first-child) { background: var(--action); color: var(--action-ink); }
.metric:last-child { border-inline-start: 1px solid #81550d42; }
.metric:first-child strong { font-size: clamp(2.13rem, 7vw, 3.65rem); font-weight: 700; line-height: 1; letter-spacing: -.045em; }
.money { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.category { display: block; width: 100%; background: transparent; border: 0; border-radius: 11px; color: var(--ink); padding: 9px 3px; min-height: 48px; text-align: left; }
.category:hover { background: #f4f0e6; }
.bar { display: block; margin-top: 7px; height: 5px; border-radius: 4px; background: var(--tint); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.transaction { min-height: 61px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.transaction:last-child { border-bottom: 0; }
.tx-main { display: flex; align-items: start; gap: 10px; min-width: 0; }
.tx-mark { display: grid; flex: none; place-items: center; background: var(--tint); color: var(--brand); font-size: .83rem; font-weight: 650; border-radius: 14px; width: 37px; height: 37px; }
.tx-mark.income { background: #fff0c7; color: var(--income-ink); }
.tx-mark.transfer { background: #eaeef4; color: var(--muted); }
.tx-wrap, .transaction-title { min-width: 0; overflow-wrap: anywhere; }
.transaction small { display: block; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.transaction > .money { flex: none; text-align: right; font-size: .95rem; }
.income { color: var(--income-ink); }
.transfer, .muted { color: var(--muted); }
.error { color: var(--red); font-size: .88rem; }
.empty { color: var(--muted); padding: 10px 0; }
.list-day { color: var(--muted); font-size: .88rem; margin-top: 15px; }
.ledger-filter { background: var(--tint); padding: 7px 10px 7px 15px; border-radius: 17px; margin-bottom: 14px; }
.account-line { min-height: 42px; }
.account-detail { margin-top: 9px; }
.account-detail summary { color: var(--brand); padding: 7px 0; min-height: 40px; }
form label, .field { display: grid; gap: 5px; font-size: .875rem; }
input:not([type="radio"], [type="checkbox"]), select { width: 100%; min-width: 0; color: var(--ink); border: 1px solid transparent; border-radius: 14px; min-height: 46px; padding: 9px 10px; background: var(--soft); font-size: 1rem; }
select { appearance: none; padding-inline-end: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%234b4d66' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.balance-form, .create-project { display: flex; align-items: end; gap: 8px; margin: 8px 0 14px; }
.balance-form label, .create-project label { flex: 1; min-width: 0; max-width: 350px; }
.balance-result { min-height: 1.5em; color: var(--muted); }
.project-list { display: grid; gap: 7px; }
.project-row { display: grid; grid-template-columns: 39px minmax(0,1fr) auto 18px; align-items: center; gap: 10px; width: 100%; border: 0; text-align: left; background: var(--soft); color: var(--ink); border-radius: 17px; min-height: 62px; padding: 9px 11px; }
.project-row:hover { background: var(--tint); }
.project-row strong, .project-row small { display: block; overflow-wrap: anywhere; }
.project-row small { color: var(--muted); margin-top: 2px; }
.project-chip { display: inline-flex; align-items: center; gap: 3px; border: 0; border-radius: 9px; background: var(--tint); color: var(--brand); padding: 4px 7px; font-size: .75rem; margin-top: 4px; max-width: 100%; overflow-wrap: anywhere; text-align: left; }
button.project-chip { min-height: 36px; }
.project-chip.unset { background: transparent; color: var(--muted); padding-inline: 0; }
.project-chip .icon, .entry-extras .icon { width: 15px; height: 15px; }
dialog { color: var(--ink); background: var(--surface); border: 0; border-radius: 30px; width: min(510px, calc(100% - 28px)); max-height: calc(100dvh - 22px); padding: 22px; box-shadow: 0 24px 80px #172a5638; }
dialog::backdrop { background: #17264466; }
.dialog-head h2 { font-size: 1.47rem; }
#assign-form { display: grid; gap: 12px; }
#entry-dialog {
  --entry-sheet-limit: calc(100dvh - 28px);
  --entry-paper: var(--surface);
  --entry-field: #f5f2eb;
  --entry-rule: var(--line);
  --entry-gutter: 22px;
  --entry-accent: var(--brand);
  --entry-amount-ink: white;
  --entry-action: var(--action);
  --entry-action-hover: var(--action-hover);
  --entry-action-ink: var(--action-ink);
  --entry-tint: var(--tint);
  --entry-selection-ink: var(--brand);
  --entry-amount-focus: var(--action);
  --entry-caption: #e0ebff;
  background: var(--entry-paper);
  max-height: var(--entry-sheet-limit);
  overflow: hidden;
  padding: 0;
}
#entry-dialog[data-kind="income"] {
  --entry-paper: #fffbef;
  --entry-accent: var(--action);
  --entry-amount-ink: var(--action-ink);
  --entry-action: var(--brand);
  --entry-action-hover: #123780;
  --entry-action-ink: white;
  --entry-tint: #ffedbc;
  --entry-selection-ink: #63420d;
  --entry-amount-focus: var(--brand);
  --entry-caption: #61410d;
}
#entry-dialog[data-kind="transfer"] {
  --entry-paper: #fafbfd;
  --entry-accent: #354976;
  --entry-action: #2d3d61;
  --entry-action-hover: #253652;
  --entry-action-ink: white;
  --entry-tint: #e5ebf3;
  --entry-selection-ink: #2d3d61;
  --entry-amount-focus: #b8c9ec;
  --entry-caption: #e7effa;
}
#entry-form { display: flex; flex-direction: column; max-height: var(--entry-sheet-limit); font-family: "Source Han Sans CN", "PingFang SC", "Noto Sans SC", sans-serif; }
html[lang="en"] { font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
html[lang="en"] #entry-form { font-family: inherit; }
#entry-form > .dialog-head {
  position: relative;
  flex: none;
  min-height: 69px;
  padding: 10px var(--entry-gutter);
  border-bottom: 1px solid var(--entry-rule);
}
#entry-form > .dialog-head h2 { font-size: 1.44rem; line-height: 1.3; font-weight: 790; }
#close-entry { background: var(--entry-field); color: var(--muted); }
.entry-body { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; padding: 13px var(--entry-gutter) 14px; }
.entry-footer { flex: none; padding: 10px var(--entry-gutter) 15px; border-top: 1px solid var(--entry-rule); }
.entry-footer .save { color: var(--entry-action-ink); background: var(--entry-action); }
.entry-footer .save:hover { background: var(--entry-action-hover); }
#entry-form input:not([type="radio"], [type="checkbox"], #entry-amount), #entry-form select, #open-clock {
  color: var(--ink);
  background-color: var(--entry-field);
  border: 1px solid var(--entry-rule);
}
.segments { display: grid; grid-template-columns: repeat(3,1fr); padding: 4px; margin: 0; gap: 4px; background: var(--soft); border: 0; border-radius: 27px; }
.segments label { position: relative; display: grid; place-items: center; padding: 5px; min-height: 40px; border-radius: 22px; cursor: pointer; }
.segments label:has(:checked) { color: var(--entry-selection-ink); background: var(--entry-tint); font-weight: 700; }
.segments label:has(:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.segments input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.amount-field { align-content: center; min-height: 100px; background: var(--entry-accent); border-radius: 19px; padding: 11px 15px 7px; color: var(--entry-caption); }
.amount-field input { color: var(--entry-amount-ink); caret-color: var(--entry-amount-ink); font-size: 2.5rem; line-height: 1.1; font-weight: 760; letter-spacing: -.032em; font-variant-numeric: tabular-nums; padding: 0 0 4px; background: transparent; border: 0; }
.amount-field input::placeholder { color: var(--entry-caption); }
#entry-amount:focus-visible { outline: none; }
.fields, .entry-extras { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px 11px; }
.entry-extras label:has(> .icon) { display: flex; align-items: center; gap: 4px; }
.date-actions { display: flex; align-self: end; gap: 6px; }
.date-actions .quiet { padding-inline: 9px; }
.save { width: 100%; min-height: 49px; }
.toast { margin: -8px 0 13px; color: var(--brand); background: var(--tint); border-radius: 14px; padding: 10px 13px; }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 0; border: 0; }
  .sidebar .brand, .sidebar-foot { display: none; }
  .navigation { position: fixed; z-index: 2; left: max(13px,env(safe-area-inset-left)); right: calc(84px + env(safe-area-inset-right)); bottom: max(10px,env(safe-area-inset-bottom)); grid-template-columns: repeat(4,minmax(0,1fr)); background: #fffdf8f2; backdrop-filter: blur(18px); border: 1px solid #fffdf8; box-shadow: 0 6px 26px #172a5624; border-radius: 28px; padding: 5px 7px; gap: 3px; }
  .navigation button { flex-direction: column; justify-content: center; gap: 1px; padding: 0; font-size: .74rem; min-height: 53px; }
  .navigation button[aria-current] { background: transparent; }
  .nav-icon { width: 46px; height: 29px; border-radius: 17px; }
  .navigation button[aria-current] .nav-icon { background: var(--tint); }
  main { padding: max(17px,env(safe-area-inset-top)) 14px calc(90px + env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 15px; }
  .overview-grid { grid-template-columns: 1fr; gap: 12px; }
  .overview-stack { gap: 12px; }
  #add-entry { position: fixed; z-index: 3; right: max(14px,env(safe-area-inset-right)); bottom: max(13px,env(safe-area-inset-bottom)); width: 59px; height: 59px; border-radius: 21px; padding: 0; font-size: 0; box-shadow: 0 7px 16px #674a163b; }
  #add-entry .icon { width: 28px; height: 28px; }
  dialog { position: fixed; inset: auto 0 0; margin: 0 auto; width: min(570px,100%); max-width: none; max-height: min(85dvh, 690px); padding: 10px 17px max(15px,env(safe-area-inset-bottom)); border-radius: 29px 29px 0 0; overflow: auto; }
  dialog::before { content: ""; display: block; background: #d4d7e1; width: 32px; height: 4px; border-radius: 5px; margin: 0 auto 3px; }
  #entry-dialog { --entry-sheet-limit: min(87dvh, 730px); --entry-gutter: 18px; translate: 0 var(--entry-drag, 0px); }
  #entry-dialog::before { display: none; }
  #entry-form > .dialog-head { padding-top: 15px; touch-action: none; cursor: grab; }
  #entry-form > .dialog-head::before { content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 32px; height: 4px; border-radius: 5px; background: #d4d7e1; }
  .entry-footer { padding-bottom: max(13px, env(safe-area-inset-bottom)); }
  dialog[open] { animation: sheet-in 230ms cubic-bezier(.2,.8,.25,1) both; }
}
@media (max-width: 360px) {
  .surface:not(.hero) { padding: 14px; }
  .project-row { gap: 5px; }
  .transaction > .money { font-size: .85rem; }
}
@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } }
.date-field { grid-column: 1 / -1; }
.clock-button { width: 100%; justify-content: space-between; font-size: 1.0625rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.clock-button::after { content: ""; width: 7px; height: 7px; margin-right: 3px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg) translateY(-2px); }
.clock-button[aria-expanded="true"]::after { transform: rotate(225deg) translateY(-2px); }
#clock-panel { background: var(--entry-field); border: 1px solid var(--entry-rule); border-radius: 18px; padding: 5px 8px 4px; }
#entry-form:has(#clock-panel:not([hidden])) > .entry-footer { display: none; }
.clock-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 3px 2px 8px; }
.clock-toolbar strong { font-size: .9rem; }
.clock-toolbar #apply-clock { background: transparent; }
.clock-wheels { --wheel-row: 35px; width: min(100%, 294px); margin-inline: auto; display: grid; grid-template-columns: minmax(0, 2.7fr) repeat(2,minmax(0,1fr)); gap: 0; text-align: center; }
.clock-wheels > div { min-width: 0; }
.clock-wheels > div > span { display: block; color: var(--muted); font-size: .76rem; padding: 4px 0 1px; }
.clock-wheel { height: calc(3 * var(--wheel-row)); padding-block: var(--wheel-row); overflow-y: auto; overflow-x: hidden; scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior-y: contain; }
.clock-wheel::-webkit-scrollbar { display: none; }
.clock-wheel [role="option"] { height: var(--wheel-row); display: grid; place-items: center; scroll-snap-align: center; color: var(--muted); font-variant-numeric: tabular-nums; cursor: pointer; font-size: 1.125rem; line-height: 1.15; white-space: nowrap; }
html[lang="en"] .clock-wheel[data-part="date"] [role="option"] { font-size: 1rem; }
.clock-wheel [aria-selected="true"] { color: var(--entry-selection-ink); background: var(--entry-tint); font-weight: 730; }
.clock-wheels > div:first-child [aria-selected="true"] { border-radius: 10px 0 0 10px; }
.clock-wheels > div:last-child [aria-selected="true"] { border-radius: 0 10px 10px 0; }
.clock-wheel:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.clock-actions { display: flex; align-items: center; gap: 2px; }
.clock-actions .quiet { background: transparent; padding-inline: 8px; font-size: .85rem; }
.clock-actions #close-clock { margin-inline-start: auto; color: var(--muted); }
.tx-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tx-mark.refund { background: #fff0c7; color: var(--income-ink); }
.refund { color: var(--brand); }
.refund-context { color: var(--muted); font-size: .9rem; background: var(--soft); padding: 10px 12px; border-radius: 12px; }
.create-setting { display: grid; gap: 8px; max-width: 450px; margin: 7px 0 15px; }
.create-setting .primary { justify-self: start; }
.reconcile-check { display: flex; align-items: center; gap: 8px; width: fit-content; min-height: 36px; color: var(--ink); cursor: pointer; }
.reconcile-check input { width: 17px; height: 17px; margin: 0; flex: none; accent-color: var(--brand); }
.reconcile-check-inline { color: var(--muted); font-size: .8rem; }
.template-tools { display: flex; align-items: center; gap: 8px; justify-content: space-between; color: var(--muted); font-size: .82rem; }
#entry-templates { min-width: 0; }
#entry-form:has(#entry-templates:not([hidden])) .entry-body { row-gap: 10px; }
.template-rail { min-width: 0; position: relative; }
.template-rail::before, .template-rail::after { content: ""; position: absolute; top: 1px; bottom: 2px; width: 17px; z-index: 1; pointer-events: none; }
.template-rail[data-more-left]::before { left: 0; background: linear-gradient(to right,var(--entry-paper),transparent); }
.template-rail[data-more-right]::after { right: 0; background: linear-gradient(to left,var(--entry-paper),transparent); }
.template-list { display: flex; min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain; gap: 6px; padding: 3px; scrollbar-width: none; }
.template-list::-webkit-scrollbar { display: none; }
#entry-templates .quiet { min-height: 34px; padding: 4px 9px; font-size: .8rem; white-space: nowrap; }
#template-list .template-button { flex: none; display: inline-block; min-width: 62px; max-width: min(74%, 12rem); min-height: 42px; overflow: hidden; text-overflow: ellipsis; }
.template-button[aria-pressed="true"] { background: var(--entry-tint); color: var(--entry-selection-ink); }
#template-editor { display: grid; gap: 7px; background: var(--entry-field); padding: 10px; border-radius: 14px; margin-top: 7px; }
.template-editor-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.template-feedback { font-size: .82rem; margin-top: 5px; color: var(--muted); }
.template-feedback.error { color: var(--red); }
.amount-field:focus-within { box-shadow: inset 0 -2px 0 var(--entry-amount-focus); }
.statement-range, .statement-compare { display: grid; grid-template-columns: minmax(0,1.25fr) repeat(2,minmax(0,1fr)) auto; gap: 10px; align-items: end; }
.statement-compare { grid-template-columns: repeat(2,minmax(0,1fr)) auto; margin: 16px 0 10px; }
.statement-range input[type="date"] { padding-inline: 7px; }
.statement-note { margin-top: 9px; font-size: .85rem; }
.statement-metrics { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,101px),1fr)); gap: 8px; }
.statement-metric { display: grid; gap: 3px; border-radius: 14px; background: var(--soft); padding: 10px 12px; }
.statement-metric:first-child { background: var(--tint); color: var(--brand); }
.statement-metric span { font-size: .85rem; }
.statement-results .account-detail { border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  html { scroll-padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
  .statement-range, .statement-compare { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .statement-source { grid-column: 1 / -1; }
  .statement-range > button, .statement-compare > button { grid-column: 1 / -1; justify-self: start; }
}
