:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", sans-serif;
  color: #182620;
  background: #f5f7f2;
  font-size: 100%;
  --paper: #fff;
  --ink: #182620;
  --muted: #59685e;
  --line: #dfe7dc;
  --green: #24583e;
  --green-dark: #163b2c;
  --lime: #e3f396;
  --danger: #a23d32;
  --radius: 18px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, select { font: inherit; }
h1, h2, h3, p { margin: 0; }
ul { padding: 0; margin: 0; list-style: none; }
a { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 3px solid #72a872; outline-offset: 3px; }

.shell { width: min(100% - 64px, 1120px); margin-inline: auto; }
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner { height: 71px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-size: 1.06rem; font-weight: 750; }
.brand-icon { width: 38px; height: 38px; position: relative; display: grid; place-items: center; border-radius: 11px; background: #24533d; color: #eaf6ab; }
.brand-icon::before { content: ""; width: 16px; height: 19px; border: 1.5px solid currentColor; border-radius: 2px; position: absolute; transform: rotate(-12deg); }
.brand-icon i { width: 16px; height: 19px; border: 1.5px solid currentColor; background: #24533d; border-radius: 2px; position: relative; transform: translate(3px, 1px) rotate(8deg); }
.brand-icon i::after { content: ""; position: absolute; top: 5px; left: 3px; right: 3px; height: 5px; border-top: 1px solid currentColor; border-bottom: 1px solid currentColor; }
.header-actions { display: flex; gap: 15px; align-items: center; }
.mobile-add { display: none !important; }
.connection { font-size: .875rem; color: var(--muted); }
.dashboard { padding-block: 42px 60px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 27px; }
h1 { font-size: clamp(1.65rem, 3.5vw, 2.6rem); line-height: 1.24; font-weight: 790; letter-spacing: -.04em; }
.page-heading p, .gate-card > p:first-of-type { margin-top: 10px; color: var(--muted); line-height: 1.6; }
.term-field, .select-field { position: relative; display: block; }
.term-field .icon { position: absolute; top: 14px; left: 13px; pointer-events: none; }
.term-field::after, .select-field::after { content: ""; border: solid #547062; border-width: 0 1.5px 1.5px 0; width: 7px; height: 7px; position: absolute; right: 17px; top: calc(50% - 6px); transform: rotate(45deg); pointer-events: none; }
select { appearance: none; padding-right: 35px !important; }
.term-field select { font-weight: 650; height: 46px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
.ledger { display: grid; gap: 23px; min-width: 0; }

.summary { position: relative; overflow: hidden; isolation: isolate; color: #fff; background: #153b2d; border-radius: var(--radius); padding: 27px 29px 24px; }
.summary::before { position: absolute; content: ""; z-index: -1; inset: 0 0 0 27%; pointer-events: none; opacity: .65; background: radial-gradient(ellipse at 88% 6%, #40744b 1%, transparent 69%), repeating-linear-gradient(90deg, transparent 0 47px, #87af8a26 47px 48px), repeating-linear-gradient(0deg, transparent 0 47px, #87af8a26 47px 48px); mask-image: linear-gradient(86deg, transparent, black 42%); }
.summary-top { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.summary h2 { font-size: .9375rem; font-weight: 600; color: #d7e8d9; }
.summary-total { display: flex; gap: 5px; margin-block: 6px 23px; align-items: baseline; color: var(--lime); font-size: clamp(2.1rem, 5.5vw, 3.7rem); line-height: 1.14; font-weight: 720; font-variant-numeric: tabular-nums; letter-spacing: -.06em; overflow-wrap: anywhere; }
.summary-total > span:first-child { font-size: .55em; font-weight: 620; }
.summary-metrics { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 12px; padding-top: 17px; border-top: 1px solid #e0f3dd36; }
.summary-metrics > div { display: grid; gap: 5px; }
.summary-metrics > div > span { color: #d7e8d9; font-size: .875rem; }
.summary-metrics strong { font-size: 1rem; font-variant-numeric: tabular-nums; font-weight: 700; overflow-wrap: anywhere; }
.summary-metrics small { font-size: .875rem; font-weight: 500; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 41px; padding: 8px 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 670; font-size: .9375rem; line-height: 1.3; }
.summary-button { background: var(--lime); color: #213d23; white-space: nowrap; }
.summary-button:hover { background: #effbb3; }
.primary { background: var(--green); color: #fff; }
.primary:hover { background: #1b4531; }
.subtle { background: #f3f7f0; color: #264f38; border-color: #dce7d9; }
.subtle:hover { background: #e7f1e3; }
.text-button { background: transparent; color: #496255; padding-inline: 10px; }
.text-button:hover { background: #edf4ec; }
.danger { background: #9b382d; color: #fff; }
.danger:hover { background: #7e291f; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2, .form-heading h2, .settlement-heading h3 { font-size: 1.12rem; font-weight: 750; }
.section-heading > span { color: var(--muted); font-size: .875rem; }
.members { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.member { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 11px 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 13px; }
.avatar { display: grid; flex: 0 0 32px; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: #e7f1e2; color: #315e42; font-weight: 730; font-size: .875rem; }
.tone-1 { background: #e8efdc; color: #495e33; }
.tone-2 { background: #e0eef3; color: #335d70; }
.tone-3 { background: #f3eade; color: #735431; }
.member-details { min-width: 0; }
.member-details strong { display: block; font-size: .875rem; font-weight: 700; }
.member-details small { display: block; margin-top: 3px; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.activity, .form-card, .gate-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.tab-list { display: flex; gap: 20px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.tab { position: relative; padding: 16px 3px 14px; color: var(--muted); border: 0; background: transparent; font-weight: 680; }
.tab[aria-selected="true"] { color: var(--green); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; border-bottom: 3px solid #438052; border-radius: 3px; }
#entries-panel, #settlement-panel { padding: 18px 22px; }
.empty { min-height: 216px; display: grid; place-items: center; align-content: center; padding: 13px 6px; text-align: center; }
.empty-icon, .upload-icon, .gate-icon { display: grid; place-items: center; color: #42674e; background: #eaf3e6; }
.empty-icon { width: 45px; height: 45px; border-radius: 13px; margin-bottom: 11px; }
.empty h3 { font-size: 1rem; }
.empty p { color: var(--muted); font-size: .875rem; line-height: 1.65; margin: 6px 0 12px; }
.entries { display: grid; }
.entry { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding-block: 10px; }
.entry + .entry { border-top: 1px solid var(--line); }
.photo-trigger { width: 43px; height: 43px; display: grid; place-items: center; border: 1px solid #dce8dc; border-radius: 10px; background: #eef5ec; color: #365d44; }
.photo-trigger:hover { background: #e4f0df; }
.entry-name { font-size: 1rem; font-weight: 690; overflow-wrap: anywhere; }
.entry-meta { color: var(--muted); font-size: .875rem; margin-top: 3px; }
.entry-shares { color: var(--muted); font-size: .875rem; margin-top: 3px; line-height: 1.45; }
.entry-end { text-align: right; }
.entry-amount { white-space: nowrap; font-weight: 730; font-variant-numeric: tabular-nums; }
.entry-actions { display: flex; justify-content: end; }
.entry-actions button { min-height: 29px; padding: 4px 6px; font-size: .875rem; }

.form-card { padding: 23px; box-shadow: 0 5px 18px #223b2810; scroll-margin-top: 14px; }
.form-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.form-heading p { color: var(--muted); font-size: .875rem; margin-top: 4px; }
.form-icon { display: grid; flex: 0 0 42px; place-items: center; height: 42px; border-radius: 12px; background: #eaf3e6; color: var(--green); font-size: 1.55rem; line-height: 1; font-weight: 500; }
.expense-form, .gate-form { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field > label, .gate-form label, .share-field legend { font-size: .925rem; font-weight: 690; }
.share-field { min-width: 0; padding: 0; border: 0; margin: 0; }
.share-field legend { margin-bottom: 8px; padding: 0; }
.participants { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.participant { display: flex; align-items: center; gap: 7px; padding: 7px 9px; min-height: 39px; border: 1px solid #d5dfd4; border-radius: 9px; font-size: .875rem; cursor: pointer; }
.participant:has(input:checked) { border-color: #b7cfb6; background: #f0f7ed; }
.participant input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; accent-color: var(--green); }
.field-help { font-size: .875rem; line-height: 1.45; color: var(--muted); }
.field input:not([type="file"], [type="checkbox"]), .field select, .term-field select, .gate-form input { width: 100%; color: var(--ink); background: #fff; border: 1px solid #d5dfd4; border-radius: 10px; min-height: 44px; padding: 9px 11px; }
.term-field select { width: 190px; padding-left: 39px; }
.field input::placeholder, .gate-form input::placeholder { color: #6b786f; }
.field select:invalid { color: #6b786f; }
.field select option { color: var(--ink); }
.amount-field { display: flex; align-items: center; border: 1px solid #d5dfd4; border-radius: 10px; background: #fff; padding-inline: 11px; color: #4b6656; }
.amount-field:focus-within { outline: 3px solid #72a872; outline-offset: 3px; }
.amount-field input:not([type="file"]) { border: 0; outline: none; min-width: 0; }
.required-note { margin-left: 4px; color: #875526; font-size: .875rem; font-weight: 610; }
.upload-box { display: flex; gap: 11px; align-items: center; min-height: 74px; padding: 12px; border: 1px dashed #9bb49d; border-radius: 11px; background: #f7faf5; cursor: pointer; }
.upload-box:hover { border-color: #4c8158; background: #ecf5e9; }
.photo-input:focus-visible + .upload-box { outline: 3px solid #72a872; outline-offset: 3px; }
.upload-icon { flex: 0 0 35px; width: 35px; height: 35px; border-radius: 9px; }
.upload-box strong, .upload-box small { display: block; }
.upload-box strong { color: var(--green); font-size: .925rem; }
.upload-box small { margin-top: 4px; font-size: .875rem; color: var(--muted); line-height: 1.45; }
.file-preview { display: flex; align-items: center; gap: 8px; padding-top: 9px; }
.file-preview img { width: 44px; height: 42px; border: 1px solid var(--line); border-radius: 8px; object-fit: cover; }
.file-preview span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .875rem; }
.form-actions { display: grid; gap: 8px; }
.form-actions .primary, .gate-form .primary { min-height: 46px; }
.message { font-size: .875rem; line-height: 1.55; color: var(--danger); }
.loading-state { padding: 80px 0; color: var(--muted); text-align: center; }

.settlement-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pill { color: var(--green); background: #eaf3e6; padding: 4px 9px; border-radius: 999px; font-size: .875rem; font-weight: 620; white-space: nowrap; }
.empty-settlement { padding: 30px 0; text-align: center; color: var(--muted); line-height: 1.6; }
.transfers { display: grid; gap: 7px; margin-top: 13px; }
.transfer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; border: 1px solid #dfeadf; background: #f4f8f2; border-radius: 10px; }
.transfer strong { font-variant-numeric: tabular-nums; color: var(--green); white-space: nowrap; }
.balance-table { margin-top: 20px; overflow-x: auto; }
.balance-table table { border-collapse: collapse; width: 100%; font-size: .875rem; }
.balance-table caption { text-align: left; font-weight: 700; margin-bottom: 6px; }
.balance-table td, .balance-table th { padding: 9px 3px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.balance-table :is(td, th):first-child { text-align: left; }
.balance-table thead th { color: var(--muted); font-weight: 620; }
.balance-in { color: #286344; }
.balance-out { color: #884c2a; }
.rounding-note { margin-top: 12px; color: var(--muted); font-size: .875rem; line-height: 1.6; }

.gate { padding-block: clamp(42px, 10vw, 100px); display: grid; justify-items: center; }
.gate-card { width: min(100%, 448px); padding: 30px; box-shadow: 0 18px 50px #1d3c2912; }
.gate-card h1 { font-size: 1.8rem; }
.gate-icon { width: 47px; height: 47px; border-radius: 13px; margin-bottom: 17px; }
.gate-form { margin-top: 23px; gap: 9px; }
.gate-form .primary { margin-top: 6px; }
.gate-card .message, #retry { margin-top: 12px; }
.modal { width: min(100% - 36px, 660px); color: var(--ink); padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); }
.modal::backdrop { background: #101f19b3; }
.modal-heading, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal h2 { font-size: 1.1rem; }
.modal p { margin-top: 10px; line-height: 1.55; overflow-wrap: anywhere; }
.modal-actions { margin-top: 16px; justify-content: flex-end; }
.confirmation { max-width: 390px; }
.full-photo { display: block; max-width: 100%; max-height: 73vh; margin: 12px auto 0; object-fit: contain; border-radius: 9px; }
.toast { position: fixed; right: max(18px, calc((100vw - 1120px) / 2)); bottom: 20px; z-index: 2; max-width: calc(100% - 36px); border-radius: 10px; padding: 11px 16px; background: #163b2c; color: #fff; box-shadow: 0 6px 24px #193d3040; font-size: .925rem; }

.icon { width: 17px; height: 17px; box-sizing: border-box; position: relative; display: inline-block; border: 1.5px solid currentColor; border-radius: 3px; }
.icon::before, .icon::after { content: ""; position: absolute; box-sizing: border-box; }
.calendar::before { inset: 4px 0 auto; border-top: 1.5px solid currentColor; }
.calendar::after { top: -3px; left: 3px; width: 8px; height: 4px; border: solid currentColor; border-width: 0 1.5px; }
.receipt { height: 20px; width: 16px; }
.receipt::before { inset: 5px 3px; border-block: 1.5px solid currentColor; }
.image-icon::before { width: 4px; height: 4px; border-radius: 50%; background: currentColor; left: 2px; top: 2px; }
.image-icon::after { width: 8px; height: 8px; border: solid currentColor; border-width: 1.5px 0 0 1.5px; transform: rotate(45deg); right: 0; bottom: -1px; }
.lock { width: 15px; height: 12px; margin-top: 5px; }
.lock::before { width: 9px; height: 8px; left: 1.5px; bottom: 100%; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 7px 7px 0 0; }
.lock::after { top: 3px; left: 5px; height: 4px; border-left: 1.5px solid currentColor; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 1010px) {
  .member { align-items: flex-start; padding: 9px 6px; gap: 5px; }
  .avatar { flex-basis: 26px; width: 26px; height: 26px; border-radius: 8px; }
}
@media (max-width: 860px) and (min-width: 741px) {
  .members { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 740px) {
  .shell { width: calc(100% - 32px); }
  .header-inner { height: 60px; }
  .header-actions { gap: 5px; }
  .mobile-add { display: inline-flex !important; min-height: 36px; }
  .header-actions .connection { display: none; }
  .dashboard { padding-top: 24px; }
  .page-heading { align-items: start; gap: 10px; margin-bottom: 17px; }
  .page-heading p { margin-top: 5px; font-size: .875rem; }
  .term-field select { width: 153px; height: 42px; min-height: 42px; padding-left: 30px; padding-right: 22px !important; font-size: .875rem; }
  .term-field .icon { left: 9px; top: 13px; width: 15px; height: 15px; }
  .term-field::after { right: 10px; }
  .layout { grid-template-columns: minmax(0, 1fr); row-gap: 18px; }
  .ledger { gap: 17px; }
  .summary { padding: 19px 16px 17px; }
  .summary-total { margin-bottom: 15px; }
  .summary-metrics { grid-template-columns: 1.45fr 1fr .92fr; padding-top: 13px; }
  .form-card { padding: 17px; }
  .gate-card { padding: 24px; }
}
@media (max-width: 420px) {
  .page-heading h1 { font-size: 1.43rem; }
  .member { gap: 7px; padding: 8px; }
  .members { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #entries-panel, #settlement-panel { padding-inline: 13px; }
  .tab-list { padding-inline: 13px; }
  .entry { column-gap: 7px; }
  .entry-meta { font-size: .8125rem; }
}
@media (max-width: 340px) {
  .shell { width: calc(100% - 24px); }
  .page-heading { flex-wrap: wrap; }
  .summary-metrics { gap: 7px; }
}
