.context-bar{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:12px;align-items:end;margin:18px 0}
.context-bar>div{min-width:0}.context-bar label{margin-bottom:6px}.context-bar .hint{padding-bottom:12px}
.record-summary{grid-template-columns:repeat(3,minmax(0,1fr))}.record-summary strong{overflow-wrap:anywhere;font-size:var(--font-card-title)}
.record-editor{margin-top:26px}.record-editor .section-head{margin:0 0 12px}.record-editor .hint{margin:0 0 14px}
.record-editor .form-actions{flex-wrap:wrap}.record-editor .form-actions .primary{width:auto;min-width:150px;padding:0 20px}
.record-editor fieldset{min-width:0}
.entry-choices{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.entry-choices legend{padding:0;font-size:var(--font-secondary);font-weight:600;margin-bottom:7px}
.segmented{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px}
.record-editor .segmented label{position:relative;min-width:0;margin:0;cursor:pointer}
.segmented input[type=radio]{position:absolute;inset:0;width:100%;height:100%;min-height:0;margin:0;padding:0;border:0;opacity:0;cursor:pointer}
.segmented span{display:flex;align-items:center;justify-content:center;min-height:44px;padding:4px;border:1px solid var(--rule);border-radius:var(--radius-control);background:var(--surface);color:var(--ink);font-size:var(--font-caption)}
.segmented input:checked+span{background:var(--accent-soft);color:var(--accent);border-color:var(--accent)}
#sign input[value="+"]:checked+span{background:var(--good-soft);color:var(--good);border-color:var(--good)}
#sign input[value="-"]:checked+span{background:var(--error-soft);color:var(--error);border-color:var(--error)}
.segmented input:focus-visible+span{outline:var(--focus-ring);outline-offset:var(--focus-offset)}
.segmented input:disabled{cursor:default}.segmented input:disabled+span{opacity:.55}
.group-toggle{display:flex;align-items:center;gap:8px;min-height:44px;margin:0;cursor:pointer}
.group-toggle input[type=checkbox]{width:20px;height:20px;min-height:20px;flex:none}
#participants{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));gap:6px 12px;margin-top:8px}
#participants label{display:flex;align-items:center;gap:8px;font-weight:400;margin:0;min-width:0;min-height:var(--target);overflow-wrap:anywhere}
#participants input[type=checkbox]{width:20px;height:20px;min-height:20px;flex:none}
.record-actions,.indicate-actions,.notice-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.record-actions button,.indicate-actions button,.notice-actions button{padding:8px 12px;min-height:var(--target);font-size:var(--font-secondary)}
.indicate-actions button:disabled,.notice-actions button:disabled{color:var(--ink2);background:var(--soft);cursor:default}
.record-actions .danger{color:var(--error)}.record-meta{color:var(--ink2);font-size:12px;line-height:1.6;overflow-wrap:anywhere}
.notice-details{margin-top:8px}.notice-details summary{cursor:pointer;font-size:12px;color:var(--ink2)}
.notice-text{white-space:pre-wrap;font-size:12px;line-height:1.6;margin:8px 0 0;padding:10px;border:1px solid var(--rule);border-radius:var(--radius-control);background:var(--soft);overflow-wrap:anywhere}
.record-row.withdrawn{background:var(--soft)}.record-row.withdrawn .row-title{color:var(--ink2)}
#draft-panel{margin-top:18px}#draft-panel .entry-toolbar{justify-content:flex-start;flex-wrap:wrap}
#summary-detail,#updated-at,#context-note,#opening-stale{margin:8px 0;line-height:1.7}
#opening-stale{font-size:12px;overflow-wrap:anywhere}
.opening-tools{margin:18px 0}.opening-tools summary{cursor:pointer;font-weight:700}.opening-tools .hint{margin:12px 0}.opening-tools form{margin-top:12px}.opening-tools .opening-check{display:flex;align-items:center;gap:8px}.opening-tools .opening-check input{width:20px;min-height:20px}.opening-toolbar{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}.opening-history-row{border-top:1px solid var(--rule);padding:9px 0}.opening-history-row p{margin:3px 0}
@media(max-width:390px){.record-summary small{font-size:var(--font-caption)}.record-summary>div{padding:10px 8px}.record-editor{padding:16px}.record-editor .field-grid{grid-template-columns:minmax(0,1fr);gap:12px}.duration-fields{gap:6px}.duration-fields span{font-size:var(--font-caption)}}
body[data-role=owner] .balance-breakdown{margin:12px 0}
body[data-role=owner] .balance-breakdown small{font-size:12px;color:var(--ink2)}
body[data-role=owner] #summary-detail:empty{display:none}
@media(max-width:999px){
html.admin-shell body[data-role=owner] #record-content:not([hidden]){display:flex;flex-direction:column}
html.admin-shell body[data-role=owner] #record-content>*{width:100%;min-width:0;box-sizing:border-box}
html.admin-shell body[data-role=owner] #record-content>.record-editor{order:1;position:static}
}
/* The owner's record page is a desk page (owner 2026-10-06): on a wide screen the records keep the left and the form stays
   in view on the right. The staff page (no data-role=owner) is unchanged, and so is every narrower screen. */
@media(min-width:1000px){
body[data-role=owner] main{max-width:1120px}
body[data-role=owner] .topbar{padding-left:max(24px,calc((100vw - 1072px)/2));padding-right:max(24px,calc((100vw - 1072px)/2))}
/* Seven short rows above the list, then the list takes what the form's height leaves: a spanning item must not stretch the short rows. */
body[data-role=owner] #record-content:not([hidden]){display:grid;grid-template-columns:minmax(0,1fr) 400px;grid-template-rows:repeat(9,auto) 1fr;column-gap:28px;align-items:start}
body[data-role=owner] #record-content>*{grid-column:1}
body[data-role=owner] #record-content>#entries{grid-row:10}
body[data-role=owner] #record-content>.record-editor{grid-column:2;grid-row:1/-1;position:sticky;top:12px;margin-top:0;max-height:calc(100vh - 24px);overflow:auto}
}
.topbar h1.brand{margin:0}

/* Approved D staff page: balance, monthly records and a native modal sheet. */
.time-unit{font-size:max(12px,.6em);font-weight:400;color:var(--ink2)}
.staff-page .balance-card{padding:16px;background:var(--accent-soft);border:1px solid var(--rule);border-radius:var(--radius-card)}
.balance-main{display:flex;align-items:end;justify-content:space-between;gap:12px;margin:8px 0 14px}
.staff-page .balance-card #balance{font-size:clamp(24px,7.5vw,32px);font-weight:800;color:var(--accent);line-height:1.5}
.balance-main>strong{min-width:0;flex:1;overflow-wrap:anywhere}
.balance-dsoa{flex:0 1 35%;min-width:0;text-align:right}.balance-dsoa strong{display:block;font-size:16px;white-space:nowrap}
.balance-card small,.balance-meta{font-size:12px;color:var(--ink2)}
.balance-breakdown{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;padding-top:12px;border-top:1px solid var(--rule)}
.balance-breakdown strong{display:block;font-size:15px;white-space:nowrap}
.balance-breakdown .time-unit,.balance-dsoa .time-unit{font-size:11px}
.positive{color:var(--good)}
.negative{color:var(--error)}
.balance-meta{display:flex;flex-wrap:wrap;justify-content:space-between;gap:6px;margin-top:10px}
.future-chip{display:inline-block;margin-top:10px;padding:6px 8px;border:1px solid var(--rule);border-radius:var(--radius-control);background:var(--surface);font-size:12px;color:var(--accent)}
.staff-page #new-record{margin-top:16px}
.staff-page #save-status:empty,.staff-page #context-note:empty,.staff-page #summary-detail:empty{display:none}
.staff-page #entries{display:grid;gap:20px}
.record-month{display:grid;gap:8px}.month-heading{display:flex;justify-content:space-between;align-items:center;gap:8px;color:var(--ink2);font-size:12px}
.staff-page .record-row{display:grid;grid-template-columns:36px minmax(0,1fr);gap:6px 10px;padding:12px;border:1px solid var(--rule);border-radius:var(--radius-card);background:var(--surface)}
.staff-page .record-row>*{grid-column:2;min-width:0;margin:0;overflow-wrap:anywhere}
.staff-page .record-row .record-day{grid-column:1;grid-row:1/span 6;border-right:1px solid var(--rule);font-size:24px;font-weight:700;color:var(--accent)}
.staff-page .record-row .row-title{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:12px}
.record-tag{padding:3px 6px;border-radius:var(--radius-control);background:var(--good-soft);color:var(--good);font-size:12px;white-space:nowrap}
.record-amount{font-size:18px;font-weight:700;margin:6px 0}.record-reason{overflow-wrap:anywhere}
.staff-page .record-reason{font-size:14px}.staff-page .record-actions{margin-top:6px}
.staff-page .record-actions button{flex:1 1 100px;border:1px solid var(--accent);background:var(--surface);color:var(--accent);font-size:12px}
.staff-page .record-actions .danger{border-color:var(--error-soft);background:var(--error-soft);color:var(--error)}
.staff-page .record-row.withdrawn{background:var(--ground);color:var(--ink2)}
.staff-page .withdrawn .record-day{color:var(--ink2)}.staff-page .withdrawn .record-tag{background:var(--rule);color:var(--ink2)}
.record-excluded{font-size:12px;color:var(--ink2)}
body.sheet-open{overflow:hidden}
#record-sheet{position:fixed;inset:auto 0 0;width:min(100%,640px);max-width:100%;max-height:calc(100dvh - 20px);margin:0 auto;padding:12px 20px calc(24px + env(safe-area-inset-bottom));overflow:auto;overscroll-behavior:contain;border:1px solid var(--rule);border-bottom:0;border-radius:24px 24px 0 0;background:var(--surface);color:var(--ink)}
#record-sheet::backdrop{background:rgb(32 60 67 / 28%)}
.sheet-handle{width:36px;height:4px;margin:0 auto 12px;border-radius:var(--radius-pill);background:var(--rule)}
#record-sheet .section-head{margin:0 0 16px;flex-wrap:nowrap}
#close-sheet{width:44px;height:44px;min-width:44px;border-radius:50%;font-size:20px}
#record-sheet .field-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:16px 10px}
#record-sheet .wide{grid-column:1/-1}
#record-sheet legend,#record-sheet label{font-size:12px}
#record-sheet .entry-choices{gap:10px}
#record-sheet .form-actions{display:grid;grid-template-columns:1fr 2fr;gap:10px}
#record-sheet .form-actions .primary{grid-column:2;grid-row:1;min-width:0;width:100%;padding:10px}
#record-sheet .form-actions .quiet{grid-column:1;grid-row:1;min-width:0}
#duration-edit{background:var(--ground);border-radius:var(--radius-control)}
#duration-edit summary{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:44px;padding:10px;font-size:12px;list-style:none}
#duration-edit summary::-webkit-details-marker{display:none}
#duration-edit summary::before{content:none}
#duration-edit .duration-fields{padding:0 10px 10px}
.duration-change{color:var(--accent);text-decoration:underline;flex:none}
#record-sheet #participant-count{display:block;font-size:12px}
#record-sheet .group-toggle{padding:8px;background:var(--accent-soft);border-radius:var(--radius-control)}
body[data-role=owner] #new-record{display:none;width:auto;min-width:0;padding:10px 14px}
body[data-role=owner] #owner-record-sheet{position:fixed;inset:auto 0 0;width:min(100%,640px);max-width:100%;max-height:calc(100dvh - 20px);margin:0 auto;padding:12px 20px calc(24px + env(safe-area-inset-bottom));overflow:auto;overscroll-behavior:contain;border:1px solid var(--rule);border-bottom:0;border-radius:24px 24px 0 0;background:var(--surface);color:var(--ink)}
body[data-role=owner] #owner-record-sheet::backdrop{background:rgb(32 60 67 / 28%)}
body[data-role=owner] #owner-record-sheet>.section-head{justify-content:flex-end;margin:0 0 12px}
body[data-role=owner] #owner-record-sheet .record-editor{margin:0;padding:0;border:0;box-shadow:none}
body[data-role=owner] #owner-record-sheet .field-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:16px 10px}
body[data-role=owner] #owner-record-sheet .wide{grid-column:1/-1}
@media(max-width:899px){
body[data-role=owner] #new-record{display:inline-flex}
body[data-role=owner] #record-content:not([hidden]){display:flex;flex-direction:column}
body[data-role=owner] #record-content>#opening-tools{order:1}
}

/* Compact records share the existing action controls and editor. */
#entries .record-month{display:block;margin-bottom:12px}
#entries .month-heading{justify-content:flex-start;min-height:44px;gap:8px;cursor:pointer}
#entries .month-heading h3{margin:0;font-size:14px}
#entries .month-heading small{font-size:12px}
#entries .record-row{display:block;margin:6px 0;padding:0;border:1px solid var(--rule);border-radius:var(--radius-card);background:var(--surface)}
#entries .record-row.withdrawn{background:var(--soft)}
#entries .record-toggle{display:grid;grid-template-columns:36px minmax(0,1fr) auto;gap:4px 10px;width:100%;min-width:0;margin:0;padding:10px 12px;border:0;border-radius:var(--radius-card);background:transparent;color:inherit;text-align:left;font:inherit;cursor:pointer}
#entries .record-toggle:hover{background:var(--accent-soft)}
#entries .record-toggle:focus-visible{outline:var(--focus-ring);outline-offset:-3px}
#entries .record-toggle>*{min-width:0}
#entries .record-toggle .record-day{grid-column:1;grid-row:1/span 3;border-right:1px solid var(--rule);font-size:24px;font-weight:700;color:var(--accent)}
#entries .record-toggle .row-title{grid-column:2/-1;display:flex;justify-content:space-between;align-items:center;gap:8px;margin:0;font-size:12px}
#entries .record-toggle .record-amount{grid-column:2/-1;margin:0;font-size:14px;font-weight:700;font-variant-numeric:tabular-nums}
#entries .record-preview{grid-column:2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}
#entries .record-group{grid-column:3;align-self:center;font-size:12px;white-space:nowrap;color:var(--ink2)}
#entries .record-detail{padding:12px;border-top:1px solid var(--rule)}
#entries .record-detail[hidden]{display:none}
#entries .record-detail .record-reason{margin:0 0 8px;white-space:pre-wrap}
#entries .record-detail .record-meta{margin:6px 0}
body[data-role=owner] #entries .record-toggle{grid-template-columns:minmax(0,1fr) auto}
body[data-role=owner] #entries .record-toggle .row-title{grid-column:1/-1}
body[data-role=owner] #entries .record-toggle .record-amount{grid-column:1/-1}
body[data-role=owner] #entries .record-preview{grid-column:1/-1}
body[data-role=owner] #entries .record-group{grid-column:1;grid-row:4}
body[data-role=owner] #entries .record-notice{grid-column:2;grid-row:4;justify-self:end;max-width:100%;padding:3px 6px;border-radius:var(--radius-control);background:var(--soft);color:var(--ink2);font-size:12px;overflow-wrap:anywhere}
/* 上期餘額 on the left; this cycle's 賺取 above 消耗 on the right, so the add and the minus read as one column. */
.staff-page .balance-breakdown{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.staff-page .balance-breakdown>div:nth-child(3){grid-column:2}
.staff-page .balance-breakdown>div{min-width:0}
.staff-page .balance-breakdown strong{white-space:nowrap;line-height:1.6;font-variant-numeric:tabular-nums}
/* Desk: two short lines per record so the list scans like a ledger; the form stays on the right. */
@media(min-width:1000px){
body[data-role=owner] #entries .record-row{margin:3px 0}
body[data-role=owner] #entries .record-toggle{grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:2px 14px;padding:7px 12px}
body[data-role=owner] #entries .record-toggle .row-title{grid-column:1;grid-row:1;justify-content:flex-start}
body[data-role=owner] #entries .record-toggle .record-amount{grid-column:2;grid-row:1;white-space:nowrap}
body[data-role=owner] #entries .record-group{grid-column:3;grid-row:1}
body[data-role=owner] #entries .record-preview{grid-column:1/3;grid-row:2;color:var(--ink2)}
body[data-role=owner] #entries .record-notice{grid-column:3;grid-row:2;white-space:nowrap}
}
