:root {
  font-family: "DM Sans","Segoe UI","Microsoft YaHei",system-ui,sans-serif;
  color: #1e302b; background: #f5f7f6; font-synthesis: none;
  --green: #145943; --line: #dbe3df; --muted: #566b63;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button, summary { cursor: pointer; }
button, input, select, summary { outline-offset: 3px; }
:focus-visible { outline: 2px solid #347c64; }
input, select { min-width: 0; width: 100%; padding: .62rem .75rem; border: 1px solid #bdccc4; border-radius: 7px; color: inherit; background: #fff; }
input::placeholder { color: #73847a; }
label { display: grid; gap: .35rem; font-size: .9rem; font-weight: 550; }
label input, label select { font-size: 1rem; font-weight: 400; }
button { color: inherit; }
.btn { background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: .57rem .85rem; font-size: .9rem; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #edf3ef; }
.primary { background: var(--green); border-color: var(--green); color: white; }
.primary:hover { background: #104734; }
.text { border: 0; color: var(--green); background: transparent; padding: .35rem .25rem; }
small, .hint, .page-head p, .empty { color: var(--muted); }
small { font-size: .84rem; }
p { line-height: 1.6; }
h1, h2, p, ul, dl { margin: 0; }
h1 { font-size: clamp(1.55rem, 3vw, 2.05rem); letter-spacing: -.04em; }
h2 { font-size: 1.1rem; }
.mast { background: #fff; border-bottom: 1px solid var(--line); }
.mast-inner, main { max-width: 1160px; margin: auto; padding: 0 clamp(1rem, 4vw, 3rem); }
.mast-inner { display: flex; align-items: center; gap: 2rem; min-height: 4.3rem; }
.wordmark { display: flex; align-items: center; gap: .65rem; font-size: 1.12rem; font-weight: 700; white-space: nowrap; }
.wordmark b { background: var(--green); color: #fff; width: 2.1rem; height: 2.1rem; display: grid; place-items: center; border-radius: 8px; }
nav { display: flex; align-self: stretch; gap: .85rem; }
nav button { border: 0; padding: .6rem .35rem; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-size: .94rem; white-space: nowrap; }
nav button[aria-current] { border-color: var(--green); color: var(--green); font-weight: 650; }
.identity, .actions, .panel-title, .form-foot, .setting-row { display: flex; gap: .7rem; align-items: center; }
.identity { margin-left: auto; font-size: .9rem; }
main { padding-top: 2rem; padding-bottom: 3rem; }
.page-head, .panel-title, .form-foot, .setting-row { justify-content: space-between; }
.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.3rem; }
.page-head p { margin-top: .25rem; font-size: .9rem; }
.actions { flex-wrap: wrap; }
.actions select { width: auto; max-width: 100%; }
.panel { background: white; border: 1px solid var(--line); border-radius: 14px; padding: clamp(1rem, 2vw, 1.55rem); min-width: 0; }
.panel h2, .panel-title { margin-bottom: 1rem; }
.panel-title h2 { margin: 0; }
.overview, .breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.overview { align-items: stretch; }
.breakdown, .below { margin-top: 1rem; }
.summary-card { display: flex; flex-direction: column; color: #f8fffa; background: #174b3d; border-color: #174b3d; }
.summary-card .panel-title { align-items: flex-start; }
.summary-card h2 { font-size: 1rem; font-weight: 500; color: #deeee4; }
.summary-card .badge { background: #32604f; color: #eefaf2; }
.big-money, .num, dd, .payer-grid strong { font-variant-numeric: tabular-nums; }
.big-money { margin: .7rem 0 .35rem; font-size: clamp(2rem, 4.8vw, 3.65rem); line-height: 1.15; font-weight: 650; letter-spacing: -.05em; overflow-wrap: anywhere; }
.big-money span { font-size: .54em; margin-right: .23em; }
.summary-card small, .payer-grid span { color: #c8dbd1; }
.payer-grid { border-top: 1px solid #547c6b; padding-top: 1rem; margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.summary-card > small { padding-bottom: 1.5rem; }
.payer-grid div, .row-text { display: grid; gap: .35rem; min-width: 0; }
.payer-grid span { font-size: .87rem; }
.payer-grid strong { font-size: clamp(1rem, 2.5vw, 1.38rem); overflow-wrap: anywhere; }
.stack { display: grid; gap: .8rem; }
.amount-fields, .fields { display: grid; gap: .8rem; grid-template-columns: repeat(2, minmax(0,1fr)); }
.amount-fields input { font-size: 1.15rem; font-weight: 600; }
.amount-fields select { height: 100%; }
.details, .editor { max-width: 750px; }
.more { border-top: 1px solid var(--line); }
summary { padding: .65rem 0; font-size: .9rem; color: var(--green); font-weight: 550; }
.more[open] > :last-child { margin: .3rem 0 .6rem; }
.badge { background: #edf1ef; color: #43594d; padding: .24rem .55rem; border-radius: 6px; font-size: .81rem; white-space: nowrap; }
.needs_reconfirmation { background: #fff1d8; color: #804614; }
.confirmed, .settled { background: #e6f3ea; }
.cost-list { list-style: none; padding: 0; }
.cost-list li, .setting-row { border-top: 1px solid var(--line); padding: .8rem 0; }
.cost-list li { display: flex; align-items: center; gap: .7rem; }
.cost-list li:first-child, .setting-row:first-child { border-top: 0; }
.row-text { margin-right: auto; overflow-wrap: anywhere; }
.row-tools { display: flex; gap: .3rem; }
.num { white-space: nowrap; }
.group-row { display: grid; grid-template-columns: 1fr auto; gap: .4rem 1rem; padding: .55rem 0; overflow-wrap: anywhere; }
meter { grid-column: 1/-1; width: 100%; height: .42rem; border: 0; appearance: none; background: #edf2ef; border-radius: 8px; }
meter::-webkit-meter-bar { height: 100%; border: 0; background: #edf2ef; border-radius: 8px; }
meter::-webkit-meter-optimum-value, meter::-moz-meter-bar { background: #62947a; }
meter::-webkit-meter-optimum-value { background: #62947a; border-radius: 8px; }
.toolbar { display: flex; gap: .65rem; margin-bottom: .6rem; }
.toolbar select { max-width: 8rem; }
.readings { margin-bottom: 1rem; }
.readings div { display: flex; justify-content: space-between; gap: .7rem; padding: .55rem 0; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 600; }
.empty { padding: 1rem 0; font-size: .94rem; }
.setting-row small, .audit small { display: block; }
.audit { border-bottom: 1px solid var(--line); }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85rem; background: #f5f7f6; padding: .75rem; }
.toast { position: fixed; z-index: 5; bottom: 1rem; left: 50%; transform: translateX(-50%); width: max-content; max-width: 92vw; border-radius: 9px; padding: .75rem 1rem; background: #183f34; color: #fff; }
.toast.error { background: #81392d; }
.auth { max-width: 440px; padding-top: min(15vh,8rem); }
.auth h1 { margin: 1.5rem 0 1rem; font-size: 1.55rem; }
.timeline { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.timeline table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.timeline th, .timeline td { text-align: left; padding: .95rem 1.2rem; overflow-wrap: anywhere; }
.timeline th { background: #edf3ef; font-size: .91rem; color: #3a5147; }
.timeline th:first-child { width: 31%; }
.timeline th:nth-child(2) { width: 22%; }
.timeline th small, .timeline td small { font-weight: 400; }
.timeline .num { text-align: right; font-weight: 650; white-space: normal; }
.timeline td { border-top: 1px solid #e6ece8; font-size: 1rem; }
.timeline td time { font-variant-numeric: tabular-nums; color: #485d53; }
.timeline td:last-child, .timeline th:last-child { padding-left: clamp(.7rem, 4vw, 3rem); }
.timeline .empty { padding: 2.2rem 1.2rem; text-align: center; }
.missing { color: #87968d; }
.pager, .dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: .7rem; padding-top: .4rem; }
.pager { border-top: 1px solid var(--line); padding: .6rem 1rem; }
dialog { width: min(390px,92vw); padding: 1.4rem; color: inherit; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 54px #183f3429; }
dialog::backdrop { background: #122e255c; }
dialog form { gap: 1rem !important; }
dialog input[name="amount"] { font-size: 1.35rem; }
.sg-dialog { width: min(480px,94vw); max-height: 88vh; }
.sg-dialog h2 { margin-bottom: 1rem; }
.sg-dialog [hidden] { display: none; }
.sg-choices { overflow: auto; max-height: min(48vh,420px); }
.sg-choices label { display: flex; align-items: center; gap: .65rem; padding: .5rem .3rem; }
.sg-choices input { width: auto; }
.sg-scroll { overflow-x: auto; }
.sg-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sg-table td, .sg-table th { text-align: left; border-bottom: 1px solid var(--line); padding: .65rem .4rem; }
.sg-table th { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.sg-table td:first-child { width: 18%; }
.sg-table td:last-child { text-align: right; }
.sg-table small { display: block; overflow-wrap: anywhere; }
#sgFilter { width: auto; }
.sg-totals { display: flex; flex-wrap: wrap; gap: 1rem; padding-top: 1rem; color: var(--green); }
@media(max-width:760px) {
  .sg-table { font-size: .88rem; }
  nav { overflow-x:auto; }
}
@media(max-width:560px) {
  .timeline td, .timeline th { padding: .72rem .55rem; }
  .timeline td { font-size: .9rem; }
  .timeline th small { display: block; }
  .timeline th:first-child { width: 37%; }
  .timeline th:nth-child(2) { width: 24%; }
}
@media(max-width: 760px) {
  .mast-inner { flex-wrap: wrap; gap: .3rem; padding-top: .7rem; }
  nav { order: 3; width: 100%; justify-content: space-between; gap: .3rem; }
  nav button { padding: .7rem 0; }
  .overview, .breakdown { grid-template-columns: 1fr; }
  main { padding-top: 1rem; }
  .page-head { align-items: flex-start; flex-wrap: wrap; }
  .big-money { font-size: 2.65rem; }
  .summary-card > small { padding-bottom: 1rem; }
  .panel { padding: 1rem; }
  .cost-list li { flex-wrap: wrap; }
  .row-tools { margin-left: auto; }
  .identity { gap: .35rem; }
}
@media(max-width: 420px) {
  .fields { grid-template-columns: 1fr; }
  nav button, .btn { font-size: .86rem; }
}

