.card p.replace-impact {color:var(--error)}
:root {font-size:16px;color-scheme:light;--blue:#0066cc;--muted:#63636a;--paper:#f2f1f6;--soft:#edf3fc;--error:#b42318}
* {box-sizing:border-box}
[hidden],:empty#formHint,:empty#notice {display:none!important}
body {margin:0;background:var(--paper);color:#1c1c1e;font-size:1.0625rem;line-height:1.625rem}
#shell {max-width:48rem;margin:auto;height:100vh;height:100dvh;display:flex;flex-direction:column;padding:env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left)}
header {padding:8px 16px 0}
.heading {margin-top:12px;display:flex;align-items:center;gap:12px}
.brand {font-size:1.375rem}
.helper,small,.hint,.card label>span,.metric small,.card p,.record small {font-size:.875rem;line-height:1.25rem;color:var(--muted)}
.settings {font-size:.875rem;line-height:1.25rem}
.settings img {width:20px;height:20px}
h1,h2,h3,p {margin:0;overflow-wrap:anywhere}
h1 {font-size:1.75rem;line-height:2.25rem}
h2,h3 {font-size:1.0625rem;line-height:1.625rem}
#page {flex:1;min-height:0;overflow:auto;padding:12px 16px 24px;scroll-padding:12px}
#page {touch-action:pan-y pinch-zoom;overscroll-behavior-x:contain}
.stack, form {display:grid;gap:12px;min-width:0}
.card,.metric,.item {background:white;border:0;border-radius:16px;padding:13px;min-width:0}
.card h2+.line,.card p+p,.card h2+p,.card h2+.metrics {margin-top:6px}
.card p {white-space:pre-line}
.card b,.metric strong {font-weight:700;font-size:1.25rem;line-height:1.75rem}
.card label,.date-picker {display:grid;gap:4px}
strong,b,span,small,li,summary,select {overflow-wrap:anywhere}
input,select,textarea {font:inherit;color:inherit;background:white;border:none;width:100%;max-width:100%;min-width:0;min-height:36px}
input[inputmode=decimal],.hero strong {font-size:1.875rem;line-height:2.5rem;font-weight:700}
input[inputmode=decimal]::placeholder {font-size:1rem;font-weight:400;color:var(--muted);opacity:1}
textarea {resize:vertical}
.card:has(.single-date),.date-picker {min-height:76px}
textarea[name=notes] {border-radius:10px}
input[name=name] {border-radius:12px}
.memory-navigation {touch-action:pan-y pinch-zoom}
form [aria-invalid=true] {box-shadow:inset 0 0 0 1px var(--error)}
.field-error {margin-top:4px;overflow-wrap:anywhere}
.card .field-error,.error,.danger {color:var(--error)}
button,summary,.dial {min-height:44px;overflow-wrap:anywhere}
button {color:var(--blue)}
button:disabled {opacity:.55}
.line,.section-head,.actions,.record-foot,.search-line {display:flex;align-items:center;gap:8px}
.line,.section-head,.record-foot {justify-content:space-between}
.line>*,.record-foot>* {min-width:0}
.actions,.section-head,.record-foot {flex-wrap:wrap}
.line b,.record-foot .actions {text-align:right}
.section-head>span {flex:1}
.section-head button,.record-foot button {font-size:.875rem}
.category-buttons {display:flex;flex-wrap:wrap}
.category {flex:0 1 auto;max-width:100%;padding:8px .5rem;border:0;color:#1c1c1e}
@media (max-width:389px){.category {min-width:calc((100% - 8px)/3)}}
.category.selected {background:#e8f1ff;color:var(--blue);font-weight:700}
.primary,.secondary,.quick button,dialog .actions button {background:var(--blue);color:white;text-align:center;font-weight:700;border-radius:16px;padding:12px;min-height:50px}
.primary {width:100%}
.primary:disabled {background:#e2e2e8;color:#63636a}
.secondary,.quick button:not(.primary),dialog .actions button:first-child {background:var(--soft);color:var(--blue)}
.quick button,dialog .actions button {flex:1}
.item,.date-picker,.metric {width:100%;text-align:left}
.date-picker small,button.metric small {color:var(--blue)}
.date-picker .range-day {color:#1c1c1e;padding:0 22px 0 28px}
[data-day],.range-day {position:relative}
.day-calendar,.day-down {position:absolute;top:50%;transform:translateY(-50%);pointer-events:none}
.day-calendar {left:0}
.day-down {right:0}
.metrics {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.segments {display:flex;gap:4px;background:var(--soft);border-radius:16px;padding:2px}
.segments button {flex:1;min-width:0;border-radius:12px;padding:6px;font-size:.875rem;font-weight:700}
.segments [aria-pressed=true] {background:var(--blue);color:white}
.metrics.three {grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.metric strong,.hero strong,#unpaid,#capacity strong {display:block;color:#1c1c1e}
.metrics .metric {padding:13px}
.card>.metrics .metric {padding:4px 0}
.empty {text-align:center;padding:36px 8px}
.record {display:grid;gap:6px}
.record-foot {margin-top:8px}
.actions button,.dial {min-width:44px}
.record-foot button,.card .actions button {border:1px solid currentColor;border-radius:12px;padding:5px 9px}
details.note summary {display:block;overflow:hidden;white-space:pre-line;min-height:0;cursor:pointer}
details.note[open] summary {font-size:0;display:block}
details.note[open] summary::after {content:'收起全文';font-size:.875rem;color:var(--blue)}
.dial {display:grid;place-items:center;border-radius:14px;background:#e8f1ff}
.search-line input {border:1px solid #d8dbe2;min-height:44px;padding:6px;border-radius:10px}
.search-line .primary {width:auto;min-height:44px;padding:6px 14px}
nav {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:white;border-top:1px solid #d8dbe2;padding:8px 8px env(safe-area-inset-bottom)}
nav button {min-height:55px;color:var(--muted);display:flex;flex-direction:column;align-items:center;gap:3px;font-size:.875rem;line-height:1.25rem}
nav [aria-current=page] {color:var(--blue);font-weight:bold}
#notice {padding:8px 16px;background:white;max-height:24vh;overflow:auto;white-space:pre-line;font-size:.875rem}
dialog {color:inherit;border:0;border-radius:20px;padding:20px;width:min(calc(100% - 32px),28rem);max-height:85dvh;overflow:auto}
dialog::backdrop {background:rgb(28 28 30 / 38%)}
dialog.minimal-confirm,dialog.formal-dialog {width:min(calc(100% - 48px),30rem);max-width:none;background:white;border-radius:24px;text-align:center}
dialog.minimal-confirm {padding:14px 20px}
dialog.minimal-confirm h2,dialog.formal-dialog h2 {font-size:1.375rem;line-height:1.875rem;margin:0}
dialog.minimal-confirm p {font-size:1.0625rem;line-height:1.625rem;margin:8px 0 0}
dialog.minimal-confirm .actions,dialog.formal-dialog .actions {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:12px}
dialog.minimal-confirm .actions button,dialog.formal-dialog .actions button {border-radius:14px;padding:10px 12px;min-height:48px;line-height:1.5rem}
dialog.formal-dialog {padding:20px}
dialog.formal-dialog>*+* {margin-top:12px}
dialog.formal-dialog .actions {gap:8px}
dialog.formal-dialog .actions:has(> [data-id=ok]:first-child) {grid-template-columns:minmax(0,1fr)}
dialog.formal-dialog .actions button {font-size:1rem}
dialog.formal-dialog>p {font-size:1rem;line-height:1.5rem}
dialog.formal-dialog.dialog-replace h2 {color:var(--error)}
dialog.formal-dialog .actions button {color:white;background:var(--blue)}
dialog.formal-dialog .actions [data-id=cancel] {color:var(--blue);background:var(--soft)}
dialog.formal-dialog.dialog-replace .actions [data-id=ok] {color:white;background:var(--error)}
.dialog-object {padding:12px;background:#f2f3f7;border-radius:12px;overflow-wrap:anywhere}
.dialog-object p {margin-top:4px;color:var(--muted)}
dialog.dialog-replace.pointer-open h2:focus,#calendarTitle[autofocus]:focus {outline:none}
dialog.dialog-replace:not(.pointer-open) h2:focus {outline:2px solid var(--blue);outline-offset:2px}
dialog small {display:block}
dialog h2 {margin-bottom:12px}
dialog .actions {margin-top:12px}
dialog .actions button.danger {background:var(--error);color:white}
.calendar,.year-grid,.month-grid {display:grid;text-align:center;grid-template-columns:repeat(7,minmax(0,1fr))}
.year-grid,.month-grid {grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}

.calendar button,.year-grid button,.month-grid button {min-width:0;padding:0;border-radius:10px}
dialog .chosen {background:var(--blue);color:white}
dialog .inside {background:#e8f1ff}
@media(max-width:350px){.segments button{padding-inline:2px}.debt-row{flex-wrap:wrap}}

html {touch-action:manipulation;overscroll-behavior-x:contain}
.single-date small,.draft-note summary {color:var(--blue)}
.order-inputs {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,9rem),1fr));gap:8px}
input[inputmode=decimal],input[type=search] {border-radius:12px;background:#e8f1ff;padding:4px 10px}
input[inputmode=decimal]:focus-visible {border:0;outline:2px solid var(--blue);outline-offset:1px}
.draft-note summary {text-align:center;list-style:none;line-height:44px}
.draft-note summary span {margin-left:12px}
.draft-note[open] summary span {display:none}
.draft-note[open] summary::after {content:'收起';margin-left:12px}
#suggestions:not(:empty),#historyMatches:not(:empty) {max-height:30dvh;overflow:auto;scroll-margin:8px}
#suggestions .line,#historyMatches .line {min-height:44px}
dialog [data-act=prevMonth],dialog [data-act=nextMonth] {min-width:44px;font-size:2rem}
dialog [data-act=chooseYM]:focus:not(:focus-visible) {outline:none}
.date-calendar :is([data-act=prevMonth],[data-act=nextMonth]):focus {outline:none}
.date-calendar :is([data-act=prevMonth],[data-act=nextMonth]):focus-visible {
  color:#003366
}
.heading:has(#back:not([hidden])) {display:flex;align-items:center;gap:10px}

.derived {background:#edf4ff}
.edit-body {display:grid;gap:12px}
#average,#unpaid,#capacity strong {display:block;font-size:1.25rem;line-height:1.75rem}
#formHint:empty {display:none}
table {border-collapse:collapse;width:100%;font-size:.875rem}
th,td {overflow-wrap:anywhere;text-align:right;padding:5px 2px;border-bottom:1px solid #e2e2e8}
th:first-child {text-align:left}
#back svg {display:block;margin:auto;position:relative;top:2px;width:2rem;height:2rem;max-width:40px;max-height:40px}
#back {flex:none;width:44px;min-width:44px;height:44px;min-height:44px;margin-left:-12px;padding:0;background:transparent;border:0;color:inherit;font-size:1rem}
.search-line .primary {flex:none;white-space:nowrap}
.hero small,.metric small {display:block}
.single-date {display:grid;gap:4px;width:100%;min-height:50px;text-align:left}
#suggestions:not(:empty),#peopleResults:not(:empty) {margin-top:8px}
#suggestions:not(:empty) {display:grid;gap:8px}
.card .single-date [data-day] {padding-left:28px;padding-right:24px;color:#1c1c1e;font-size:1.0625rem;line-height:1.625rem}
html:not(.kb-nav) .single-date:focus {outline:none}

.revealed {background:#edf3fc;border-radius:12px}
.file-select {display:block;position:relative;color:var(--blue);min-height:48px;cursor:pointer}
.file-select input {position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}
.kb-nav .single-date:focus-within {border-radius:12px}
.kb-nav .single-date:focus-within,.kb-nav .file-select:focus-within {outline:2px solid var(--blue);outline-offset:2px}
.subline {display:block}
form #notice {border:none;border-radius:12px;font-size:.875rem;padding:10px 13px}
label[data-formatted]{position:relative}
label[data-formatted]:not(:focus-within)>input{color:transparent}
label[data-formatted]:not(:focus-within)::after{content:attr(data-formatted);position:absolute;bottom:0;left:10px;font-size:1.875rem;line-height:2.5rem;font-weight:700;pointer-events:none;color:#1c1c1e}
#notice[data-tone=warn]{background:#fff6df;color:#765100}
#notice[data-tone=success] {background:#eaf7ee;color:#16703a}
#notice[data-tone=error] {background:#fff0ed;color:#b42318}
#notice[data-tone=info] {background:#edf4ff;color:#18589e}
.banner.success {color:#16703a;background:#eaf7ee}
.banner.error {color:var(--error);background:#fff0ed}
.card .file-name {overflow-wrap:anywhere;font-size:1.0625rem;line-height:1.625rem;color:#0058a8;margin:12px 0 18px}
#page label.file-select.primary {color:white;display:flex;align-items:center;justify-content:center;position:relative}
.debt-row b,.line>b {word-break:normal;overflow-wrap:normal;flex-shrink:0;max-width:58%}
#page .stack>.hint {margin:0}
details.note .preview-note {display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;white-space:pre-line}
details.note[open] .preview-note {display:none}
.note-toggle {display:block;font-size:.875rem;color:var(--blue)}
details.note[open] .note-toggle {display:none}
.quick.query-actions .primary {flex:3}
.quick.query-actions button:not(.primary) {flex:0 1 auto;border:1px solid var(--blue);background:white}
#page .quick.query-actions:has(:only-child) .primary {flex:1}
form[data-type=expense] button[type=submit]:disabled,
button[data-validate-on-submit]:disabled,
form[inert] button[data-validate-on-submit] {background:var(--blue);color:white;opacity:.55}
.outline {border:1px solid currentColor;border-radius:12px;padding:4px 9px;flex:none;font-size:.875rem}
.empty strong {color:#1c1c1e;font-size:1.0625rem}
.empty p {margin-top:6px}
.customer-form .card {padding:6px 12px}
.customer-form label {gap:2px}
.customer-form input,.customer-form textarea {min-height:44px;padding:10px;border-radius:12px;background:#e8f1ff;font-size:1rem;line-height:1.5}
.customer-form input:focus,.customer-form textarea:focus {outline:2px solid var(--blue);outline-offset:-2px;border:0}
.customer-form textarea {field-sizing:content;max-height:12rem;overflow:auto}
.directory-entry {width:100%;position:relative;border:1px solid var(--blue);border-radius:16px;padding:10px 36px;font-weight:700;text-align:center;background:white}
.directory-entry span {position:absolute;right:14px}
.directory-entry+small {display:block;margin:6px 4px 0}
.match-list {display:grid;gap:8px}
.match-list:has(>.match-option,>.home-match) {gap:2px}
.match-option,.match-list>.cutoff-person {background:#f2f3f7;border-radius:12px}
.match-option,.home-match {padding:4px 10px;width:100%;min-width:0;text-align:left;color:var(--blue)}
.income-record {gap:12px}
.record-heading {display:flex;align-items:center;flex-wrap:wrap;gap:6px;min-width:0}
#page[data-page=totals] .line {flex-wrap:wrap}
#page[data-page=totals] .line>b {max-width:100%;margin-left:auto;overflow-wrap:anywhere}
.metrics.three .metric {padding:12px 9px}
.metrics.three .metric strong {font-size:clamp(1rem,4.2vw,1.125rem);line-height:1.5rem}
#page[data-page=totals] .metrics.three {grid-template-columns:repeat(auto-fit,minmax(min(6.25rem,100%),1fr))}
.line.ranked-amount {flex-wrap:wrap}
.line.ranked-amount>b {max-width:100%;margin-left:auto;overflow-wrap:anywhere}
.record-party {display:inline-flex;align-items:center;flex-wrap:wrap;gap:4px;min-width:0;max-width:100%;overflow-wrap:anywhere}
.record-party strong {min-width:0;max-width:100%}
.record-heading b {margin-left:auto;max-width:100%;text-align:right;font-size:1.4375rem}
.record-type {font-weight:700;font-size:.8125rem;background:#f2f3f7;padding:1px 8px;border-radius:7px}
.record-type.order {background:#e8f1ff;color:var(--blue)}
.record-type.repayment {background:#F0E9FA;color:#7651A8}
.record-numbers,.allocation,.income-record .note {background:#f2f3f7;border-radius:12px;padding:9px}
.record-numbers {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(5rem,100%),1fr));gap:6px}
.record-numbers small,.record-numbers strong {display:block}
.record-numbers small {font-size:.75rem}
.record-numbers strong {font-size:.9375rem}
.record-value {display:flex;justify-content:space-between;gap:6px}
.record-value strong {text-align:right}
#page[data-page=detail] .metrics {grid-template-columns:repeat(auto-fit,minmax(min(8.8rem,100%),1fr));gap:10px}
#page[data-page=detail] .metric {padding:12px}
#page[data-page=detail] .metric strong {font-size:1.125rem;line-height:1.5625rem}
#page[data-page=detail] .metric small {font-size:.8125rem}

.banner {padding:10px 13px;border-radius:12px;font-size:.875rem}
.banner.info {color:#18589e;background:#edf4ff}
.banner.warn {color:#765100;background:#fff6df}
dialog:has(.calendar) button[data-act=pick]:not(.chosen):not(.inside){color:#1c1c1e}
.stack:empty {display:none}

/* MUI-12 DATE_PICKER_RANGE and DATE_PICKER_YM_OPEN, shared date picker. */
dialog.date-calendar {
  width:min(calc(100% - 32px),28rem);max-width:none;max-height:calc(100dvh - 32px);
  padding:12px;border-radius:16px;container-type:inline-size
}
.date-calendar[open] {display:grid;align-content:start;gap:7px}
dialog.date-calendar h2,dialog.date-calendar h3 {margin:0;text-align:left}
dialog.date-calendar h2 {color:var(--blue)}
dialog.date-calendar>p {margin:0;font-size:.875rem;color:var(--muted);line-height:1.25rem}
.date-calendar .line {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;text-align:center}
.date-calendar .line button {white-space:nowrap}
.date-calendar .line:has([data-act=chooseYM]) {grid-template-columns:44px 1fr 44px}
.date-calendar .year-grid,.date-calendar .month-grid {gap:7px 8px}
.date-calendar .calendar {gap:7px 2px}
.date-calendar .calendar small {line-height:1.5rem}
.date-calendar :is(.year-grid,.month-grid,.calendar) button {font-size:.875rem;min-height:44px;border-radius:8px}
.date-calendar :is(.year-grid,.month-grid) button {background:white;color:#1c1c1e}
.date-calendar :is(.year-grid,.month-grid,.calendar) button.chosen {background:var(--blue);color:white}
.date-calendar .actions {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,4.75em),1fr));gap:8px;margin:0}
.date-calendar .actions button {white-space:nowrap}
@container (max-width:18em){
  .date-calendar .line:has([data-act=prevYears]) {grid-template-columns:1fr 1fr}
  .date-calendar .line:has([data-act=prevYears]) small {grid-column:1/-1;grid-row:1}
}



.compact-entry {display:grid;gap:8px}
.compact-entry .card {padding:0}
.compact-entry input[inputmode=decimal],.compact-entry label[data-formatted]::after {font-size:1.0625rem;line-height:2.25rem;font-weight:500}
.compact-entry input[inputmode=decimal]:focus-visible {outline:none;background:#d7e9ff;box-shadow:inset 4px 0 var(--blue)}
.compact-entry input[inputmode=decimal][aria-invalid=true]:focus-visible {box-shadow:inset 0 0 0 1px var(--error),inset 4px 0 var(--blue)}
#capacity .line {flex-wrap:wrap}

.cutoff-person {width:100%;text-align:left;color:var(--blue)}
.cutoff-person strong {color:#1c1c1e}

/* Interactive planes share the app viewport. OS safe areas stay with the viewport. */
body:has(.back-moving) {overflow-x:clip}
.back-plane {position:fixed;inset:0;margin:auto;max-width:48rem;height:100dvh;overflow:hidden;pointer-events:none;background:var(--paper);isolation:isolate}
.back-plane * {pointer-events:none!important}
.back-parent-title {position:absolute;left:16px;top:calc(env(safe-area-inset-top) + 64px);transform:translateX(var(--title-offset,0))}
#shell.back-moving {position:relative;z-index:1;background:var(--paper);will-change:transform}
.back-moving header,.back-moving #tabs {position:relative;z-index:2}
.back-moving header {background:var(--paper)}
.back-moving #notice:not(:empty) {position:relative;z-index:3}
.back-parent-title::after {content:'正在读取…';display:block;margin-top:12px;font-size:1rem;font-weight:400;color:var(--muted)}
.back-settling #page,.back-masked {visibility:hidden}
.back-departure {position:absolute;z-index:1;background:transparent}
#shell.back-waiting {background:transparent;will-change:auto}


.file-select:has(input:disabled),[data-backup-busy] :is(.file-select,button:not([data-act=cancelFile])) {opacity:.55;cursor:default}

.dialog-object small {color:var(--muted);margin-bottom:3px}
.dialog-object+.dialog-object {margin-top:8px}
