:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1a2d23;
  background: #f2f5ef;
  font-synthesis: none;
  --ink: #1a2d23;
  --muted: #526357;
  --green: #205339;
  --green-dark: #163e2b;
  --surface: #fff;
  --line: #dbe4d9;
  --pale: #e8f0e5;
  --danger: #9d3330;
  --focus: #26794d;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
a { color: inherit; }

.app-header { border-bottom: 1px solid var(--line); background: #f8faf6; }
.header-inner, .workspace { max-width: 1060px; margin: 0 auto; padding-inline: 16px; }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 750; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--green); display: flex; flex-direction: column; gap: 3px; justify-content: center; align-items: center; }
.brand-mark i { width: 14px; height: 2px; border-radius: 5px; background: #e2efca; }
.brand-mark i:last-child { width: 9px; margin-right: 5px; }
.workspace { padding-top: 18px; padding-bottom: calc(89px + env(safe-area-inset-bottom, 0px)); }
.trial-badge { color: var(--green); background: var(--pale); border-radius: 7px; padding: 4px 9px; font-size: 13px; font-weight: 650; }
.trial-note { padding: 9px 11px; margin: 0 0 12px; color: var(--muted); background: #f8faf6; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; line-height: 1.5; }
.page { min-width: 0; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; min-width: 0; }
h1 { font-size: 24px; line-height: 1.25; letter-spacing: -.025em; }
h2 { font-size: 19px; line-height: 1.3; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; }

.overview {
  position: relative; isolation: isolate; overflow: hidden;
  margin-bottom: 20px; padding: 17px 18px 16px; border-radius: 18px;
  background: linear-gradient(135deg, #20563c, #133a28); color: #fff;
}
.overview::before {
  content: ""; z-index: -1; position: absolute; width: 240px; height: 240px; top: -120px; right: -104px;
  border-radius: 50%; border: 1px solid #ffffff24;
  box-shadow: 0 0 0 19px #ffffff10, 0 0 0 38px #ffffff0d, 0 0 0 58px #ffffff09;
}
.overview-date { color: #d6e6d7; font-size: 13px; margin-bottom: 11px; }
.overview-label { color: #e2eee2; font-size: 14px; }
.overview-balance { font-size: clamp(30px, 7vw, 41px); line-height: 1.15; font-weight: 750; letter-spacing: -.04em; margin-top: 5px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.overview-detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; border-top: 1px solid #ffffff37; margin-top: 16px; padding-top: 12px; }
.overview-detail span, .overview-detail strong { display: block; }
.overview-detail span { font-size: 13px; color: #d6e6d7; margin-bottom: 2px; }
.overview-detail strong { font-size: 16px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.entry-form { padding: 13px; }
.kind-picker { padding: 3px; margin: 0 0 12px; min-width: 0; border: 0; background: #edf2eb; border-radius: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; }
.kind-picker label { position: relative; cursor: pointer; }
.kind-picker label input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kind-picker label span { display: grid; place-items: center; padding: 4px; min-height: 40px; border-radius: 9px; font-size: 14px; font-weight: 650; color: var(--muted); }
.kind-picker label input:checked + span { background: #fff; color: var(--green-dark); box-shadow: 0 1px 4px #182c2022; }
.kind-picker label input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.ocr-panel { margin-bottom: 13px; }
.ocr-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.quiet-button.ocr-action { min-height: 44px; gap: 7px; color: var(--green-dark); background: #edf4eb; border-color: #d4e2d2; }
.quiet-button.ocr-action:hover { background: var(--pale); }
.ocr-icon { position: relative; display: inline-block; flex: 0 0 16px; height: 13px; }
.camera-icon { border: 1.5px solid currentColor; border-radius: 3px; }
.camera-icon::before { content: ""; position: absolute; inset: -3px auto auto 3px; width: 5px; height: 2px; border-radius: 1px 1px 0 0; background: currentColor; }
.camera-icon::after { content: ""; position: absolute; inset: 2px 4px; border: 1.3px solid currentColor; border-radius: 50%; }
.upload-icon { border: 1.5px solid currentColor; border-top: 0; border-radius: 2px; height: 7px; margin-top: 6px; }
.upload-icon::before { content: ""; position: absolute; top: -7px; left: 5.5px; width: 1.5px; height: 9px; background: currentColor; }
.upload-icon::after { content: ""; position: absolute; top: -6px; left: 3.5px; width: 5.5px; height: 5.5px; border-top: 1.5px solid currentColor; border-left: 1.5px solid currentColor; transform: rotate(45deg); }
.ocr-status { color: var(--muted); font-size: 13px; line-height: 1.5; }
.ocr-status:not(:empty) { margin-top: 7px; }
.ocr-status[data-error] { color: var(--danger); }
.ocr-candidates { display: grid; gap: 5px; padding: 0; margin: 7px 0 0; list-style: none; }
.quiet-button.ocr-candidate { width: 100%; min-height: 42px; justify-content: flex-start; gap: 9px; white-space: normal; text-align: left; }
.ocr-candidate strong { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.ocr-candidate span { min-width: 0; color: var(--muted); font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.quiet-button.ocr-candidate[aria-pressed=true] { background: var(--pale); border-color: #91ae91; }
.entry-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 9px; }
.entry-fields > label, .filter-dates > label, .login-panel label, .dialog-panel label { min-width: 0; display: grid; gap: 5px; font-size: 14px; font-weight: 650; }
.entry-fields label small, .dialog-panel label small { font-size: 12px; color: var(--muted); font-weight: 400; }
.note-field { grid-column: 1 / -1; }
input:not([type=radio]), select { display: block; width: 100%; min-width: 0; min-height: 43px; padding: 7px 9px; border: 1px solid #cdd9cb; border-radius: 9px; color: var(--ink); background: #fcfdfb; font-size: 16px; font-weight: 500; }
input[type=date] { max-width: 100%; text-align: start; }
input[type=date]::-webkit-date-and-time-value { text-align: start; }
input::placeholder { color: #66756a; opacity: 1; }
.amount-input { position: relative; display: block; }
.amount-input > span { position: absolute; inset: 0 auto 0 10px; display: grid; align-items: center; color: var(--green); pointer-events: none; }
.amount-input input { padding-left: 26px; font-weight: 680; }
.form-actions { margin-top: 13px; }
.primary-button { width: 100%; min-height: 47px; padding: 10px 14px; border: 1px solid var(--green); border-radius: 10px; background: var(--green); color: #fff; font-weight: 700; }
.primary-button:hover { background: var(--green-dark); }
.quiet-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 7px 10px; white-space: nowrap; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--green); text-decoration: none; font-size: 14px; font-weight: 650; }
.quiet-button:hover { background: var(--pale); }
.quiet-button.outline { background: #f8faf6; border-color: #cfdbcd; }
.quiet-button.outline:hover { background: var(--pale); }
.helper, .form-error { font-size: 14px; line-height: 1.5; }
.helper { color: var(--muted); }
.entry-form .helper, .form-error { margin-top: 9px; }
.form-error { color: var(--danger); }

.tabs { position: fixed; z-index: 2; inset: auto 0 0; padding: 3px 10px calc(3px + env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; border-top: 1px solid var(--line); background: #fcfefa; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 56px; padding: 4px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 650; }
.tab[aria-current=page] { background: var(--pale); color: var(--green-dark); }
.tab-icon { display: inline-block; position: relative; width: 18px; height: 18px; }
.tab-add { border: 1.5px solid currentColor; border-radius: 5px; }
.tab-add::before, .tab-add::after { content: ""; position: absolute; background: currentColor; border-radius: 1px; inset: 7px 3px; }
.tab-add::after { transform: rotate(90deg); }
.tab-lines::before { content: ""; position: absolute; inset: 4px 1px auto; height: 1.5px; background: currentColor; border-radius: 1px; box-shadow: 0 4px currentColor, 0 8px currentColor; }
.tab-ledger { border: 1.5px solid currentColor; border-radius: 3px; }
.tab-ledger::before { content: ""; position: absolute; inset: 0 auto 0 5px; width: 1.5px; background: currentColor; }

.filter-form { padding: 11px; }
.filter-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.filter-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 7px; }
.section-status { font-size: 13px; color: var(--muted); margin: 12px 1px 7px; }
.section-status[data-error] { color: var(--danger); }
.flow-list { display: grid; gap: 8px; }
.flow-card { padding: 12px 13px; }
.flow-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.flow-card-name { display: flex; flex-wrap: wrap; align-items: center; column-gap: 7px; row-gap: 2px; min-width: 0; }
.flow-card-title { font-size: 15px; }
.flow-card-badge { border-radius: 6px; padding: 2px 5px; background: var(--pale); color: var(--green); font-size: 12px; }
.flow-card-amount { font-size: 17px; color: var(--ink); font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: right; }
.flow-card-amount.income { color: var(--green); }
.flow-card-amount.expense { color: var(--danger); }
.flow-card-note { font-size: 14px; color: var(--ink); margin-top: 6px; overflow-wrap: anywhere; white-space: pre-wrap; }
.flow-card-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 7px; margin-top: 3px; }
.flow-card-meta { display: flex; flex-wrap: wrap; column-gap: 8px; row-gap: 3px; min-width: 0; color: var(--muted); font-size: 12px; padding-block: 5px; overflow-wrap: anywhere; }
.flow-card-bottom button { min-height: 36px; padding-inline: 6px; }
.empty-state { padding: 23px 12px; text-align: center; font-size: 14px; color: var(--muted); }
.ledger-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 12px; margin-bottom: 10px; background: var(--pale); }
.ledger-totals div { min-width: 0; }
.ledger-totals span, .ledger-totals strong { display: block; overflow-wrap: anywhere; }
.ledger-totals span { font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.ledger-totals strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.ledger-group { margin-top: 14px; }
.ledger-group h2 { font-size: 15px; margin: 0 1px 6px; }
.ledger-group table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 12px; text-align: right; }
.ledger-group th, .ledger-group td { padding: 9px 4px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ledger-group th:first-child { width: 26%; text-align: left; padding-left: 8px; }
.ledger-group th:last-child, .ledger-group td:last-child { padding-right: 8px; }
.ledger-group thead th { color: var(--muted); }
.ledger-group tbody tr:last-child > * { border-bottom: 0; }
.ledger-group tbody td:last-child { font-weight: 700; }

.login-screen { max-width: 440px; margin: 30px auto; padding: 0 16px; }
.login-panel, .dialog-panel { padding: 17px; }
.login-panel h1 { margin-bottom: 8px; }
.login-panel form { margin-top: 13px; }
.login-panel .primary-button, .login-panel .quiet-button, .dialog-panel .primary-button { margin-top: 12px; }
.overlay { position: fixed; z-index: 5; inset: 0; display: grid; align-items: center; justify-items: center; background: #10251db0; padding: 16px; overflow: auto; }
.dialog-panel { width: 100%; max-width: 410px; box-shadow: 0 16px 45px #10251d4d; }
.dialog-panel form { margin-top: 12px; }
.dialog-panel form label + label { margin-top: 10px; }
.toast { position: fixed; z-index: 6; left: 50%; bottom: calc(73px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 30px); border-radius: 10px; padding: 9px 13px; color: white; background: var(--green-dark); font-size: 14px; box-shadow: 0 3px 14px #10251d38; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; clip: rect(0, 0, 0, 0); overflow: hidden; white-space: nowrap; border: 0; }

@media (max-width: 390px) {
  .entry-fields { grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr); }
  .entry-fields input[type=date], .filter-dates input[type=date] { padding-inline: 5px; }
  .filter-form { padding-inline: 9px; }
  .filter-dates { gap: 5px; }
}

@media (max-width: 335px) {
  .entry-fields, .filter-dates { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 680px) {
  .header-inner, .workspace { padding-inline: 26px; }
  .workspace { padding-top: 20px; padding-bottom: 35px; }
  .tabs { position: static; width: fit-content; display: flex; gap: 4px; padding: 4px; margin-bottom: 23px; border: 1px solid var(--line); border-radius: 13px; }
  .tab { flex-direction: row; gap: 8px; min-width: 105px; min-height: 43px; padding: 8px 14px; font-size: 14px; }
  #entry-page { display: grid; grid-template-columns: minmax(245px, .78fr) minmax(0, 1.22fr); gap: 0 22px; align-items: start; }
  #entry-page .overview { grid-column: 1; grid-row: 1 / span 2; padding: 20px; }
  #entry-page .heading, #entry-page .entry-form { grid-column: 2; }
  .entry-form { padding: 16px; }
  .filter-form { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; padding: 13px; }
  .filter-dates { width: 60%; }
  .filter-actions { margin-top: 0; }
  .ledger-group table { font-size: 14px; }
  .ledger-group th, .ledger-group td { padding: 10px 9px; }
  .ledger-group th:first-child { padding-left: 12px; }
  .ledger-group th:last-child, .ledger-group td:last-child { padding-right: 12px; }
  .toast { bottom: 24px; }
}
