/* 旅行帳本 (#6 redesign). Shared rules only set looks in em and the --trip-* sizes; each layout sets those sizes,
   the dialog size and its grids inside its own query (phone: big and low-density; desktop: a centred card). */
.trip-records-dialog{max-width:none;padding:0;border:0;background:#f5fbfe;color:#082f49;line-height:1.45}
.trip-records-dialog::backdrop{background:#082f49a8}
.trip-records-card{display:flex;flex-direction:column;gap:var(--trip-gap);overflow:auto;overscroll-behavior:contain;box-sizing:border-box}
.trip-records-header{position:sticky;top:0;z-index:4;display:flex;align-items:center;gap:8px;background:#f5fbfe}
.trip-records-tabs{display:flex;flex:1;gap:6px;min-width:0}
.trip-records-tabs [role=tab]{flex:1;min-width:0;min-height:var(--trip-tap);border:2px solid #bae6fd;border-radius:12px;background:#fff;color:#075985;font:inherit;font-size:1.05em;font-weight:900}
.trip-records-tabs [role=tab][aria-selected=true]{border-color:#0369a1;background:#0369a1;color:#fff}
.trip-records-close{flex:0 0 auto;width:var(--trip-tap);height:var(--trip-tap);border:0;border-radius:12px;background:transparent;color:#334155;font:inherit;font-size:1.9em;line-height:1}
.trip-visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.trip-records-panel,.trip-view,.trip-form-body{display:grid;gap:var(--trip-gap);min-width:0}
.trip-card{min-width:0;padding:14px;border:1px solid #d5e8f0;border-radius:16px;background:#fff}
.trip-card h3,.trip-review h3,.trip-doc-group h3{margin:0 0 8px;color:#082f49;font-size:1.1em}
.trip-doc-group h3{margin:4px 0 0}
.trip-card h4{margin:12px 0 6px;color:#334155;font-size:1em}
.trip-card p{margin:0 0 8px}
.trip-records-dialog :where(input:not([type=radio]):not([type=checkbox]):not([type=file]),textarea){box-sizing:border-box;width:100%;min-height:var(--trip-tap);padding:6px 12px;border:2px solid #cbdde5;border-radius:10px;background:#fff;color:#082f49;font:inherit}
.trip-records-dialog textarea{resize:vertical}
.trip-records-dialog button{cursor:pointer}
.trip-records-dialog button:disabled{border-color:#cbd5e1;background:#f1f5f9;color:#64748b;cursor:not-allowed}
.trip-records-dialog :is(button,input,textarea,summary,[tabindex]):focus-visible,.trip-records-dialog input:focus-visible+span{outline:3px solid #f59e0b;outline-offset:2px}
.trip-primary-button,.trip-secondary-button,.trip-danger-button{min-height:var(--trip-tap);padding:0 16px;border-radius:12px;font:inherit;font-weight:900}
.trip-primary-button{border:2px solid #0369a1;background:#0369a1;color:#fff}
.trip-secondary-button{border:2px solid #bae6fd;background:#fff;color:#075985}
.trip-danger-button{border:2px solid #fecaca;background:#fff;color:#b91c1c}
.trip-confirm .trip-danger-button{border-color:#b91c1c;background:#b91c1c;color:#fff}
.trip-text-button{min-height:var(--trip-tap);padding:0 10px;border:0;background:transparent;color:#075985;font:inherit;font-weight:800;text-decoration:underline}
.trip-big-button{width:100%;min-height:calc(var(--trip-tap) + 10px);border:0;border-radius:16px;background:#ea580c;color:#fff;font:inherit;font-size:1.2em;font-weight:900;box-shadow:0 6px 16px #ea580c40}
.trip-inline-message{margin:0;color:#075985;font-weight:800}
.trip-inline-message:empty,.trip-sync-line:empty{display:none}
.trip-field-error,.trip-row-message.trip-row-refusal{margin:0;color:#b91c1c;font-weight:800}
.trip-sync-line{margin:0;color:#526575;font-size:.85em}
.trip-sync-line[data-state=error],.trip-sync-line[data-state=offline]{color:#9a3412;font-weight:700}
.trip-empty{padding:14px;border:2px dashed #cbdde5;border-radius:14px;color:#526575;list-style:none}
.trip-subtabs{display:grid;grid-template-columns:1fr 1fr;gap:4px;padding:4px;border-radius:14px;background:#e0f2fe}
.trip-subtabs button{min-height:calc(var(--trip-tap) - 6px);border:0;border-radius:10px;background:transparent;color:#075985;font:inherit;font-weight:800}
.trip-subtabs button[aria-pressed=true]{background:#fff;color:#082f49;box-shadow:0 1px 4px #082f4926}
.trip-name-chips,.trip-expense-list,.trip-doc-list,.trip-bucket-list,.trip-category-totals,.trip-balances,.trip-transfers,.trip-settings-list,.trip-bucket-detail,.trip-legend{display:grid;gap:8px;margin:0;padding:0;list-style:none}
.trip-name-chips,.trip-legend{display:flex;flex-wrap:wrap;gap:6px 12px;margin-bottom:8px}
.trip-name-chips li{padding:6px 12px;border-radius:999px;background:#e0f2fe;color:#075985;font-weight:800}
.trip-inline-field{display:flex;gap:8px;margin-bottom:8px}
.trip-inline-field button{flex:0 0 auto}
.trip-day-chips{display:grid;gap:6px}
.trip-day-chip{display:flex;flex-direction:column;align-items:center;justify-content:center;min-width:0;min-height:calc(var(--trip-tap) + 4px);padding:2px;border:2px solid #cbdde5;border-radius:12px;background:#fff;color:#0c4a6e;font:inherit;font-weight:900;line-height:1.15}
.trip-day-chip small{font-size:.78em;font-weight:700;color:inherit}
.trip-day-chip[aria-pressed=true]{border-color:#0369a1;background:#0369a1;color:#fff}
.trip-day-total{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 8px;margin:0;color:#334155;font-weight:700}
.trip-day-total strong{color:#082f49;font-size:1.25em}
.trip-plus{color:#94a3b8}
.trip-expense-row,.trip-doc-row{display:flex;align-items:center;gap:10px;box-sizing:border-box;width:100%;min-height:calc(var(--trip-tap) + 14px);padding:10px 12px;border:1px solid #d5e8f0;border-radius:14px;background:#fff;color:inherit;font:inherit;text-align:left}
.trip-expense-text,.trip-doc-text{display:grid;flex:1;min-width:0;gap:2px}
.trip-expense-text strong,.trip-doc-text strong{overflow-wrap:anywhere;font-size:1.05em}
.trip-expense-text small,.trip-doc-text small{color:#526575;font-size:.85em;overflow-wrap:anywhere}
.trip-expense-amount{flex:0 0 auto;color:#075985;font-size:1.15em;white-space:nowrap}
.trip-badge{justify-self:start;padding:2px 8px;border-radius:999px;background:#fef3c7;color:#92400e;font-size:.8em;font-weight:800}
.just-saved>.trip-expense-row,.just-saved>.trip-doc-row{border-color:#16a34a;box-shadow:0 0 0 3px #bbf7d0}
.trip-row-message{margin:6px 4px 0;color:#166534;font-weight:900}
.trip-row-notice{padding:10px 12px;border-radius:12px;background:#ecfdf5;color:#166534;font-weight:900;list-style:none}
.trip-who-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-bottom:8px}
.trip-person-button{min-height:calc(var(--trip-tap) + 20px);border:2px solid #0369a1;border-radius:16px;background:#fff;color:#075985;font:inherit;font-size:1.25em;font-weight:900}
.trip-form-head{display:flex;align-items:center;gap:8px}
.trip-form-head h3{margin:0;font-size:1.2em}
.trip-form-day{flex:1;min-width:0;color:#526575;font-weight:800}
.trip-form-head .trip-text-button{margin-left:auto}
.trip-amount-row{display:flex;align-items:center;gap:10px}
.trip-amount-row label,.trip-amount-unit{flex:0 0 auto;font-weight:900}
#tripExpenseAmount{min-height:calc(var(--trip-tap) + 8px);padding:0 12px;font-size:1.5em;font-weight:900}
.trip-segmented,.trip-choice-group{min-width:0;margin:0;padding:0;border:0}
.trip-choice-group legend{padding:0;margin-bottom:4px;color:#334155;font-weight:900}
.trip-segmented{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:6px}
.trip-choice-group{display:grid;gap:6px}
:is(.trip-segmented,.trip-choice-group,.trip-person-row) label{position:relative;display:block;min-width:0}
:is(.trip-segmented,.trip-choice-group,.trip-person-row) input[type=radio]{position:absolute;top:0;left:0;width:1px;height:1px;margin:0;opacity:0;pointer-events:none}
:is(.trip-segmented,.trip-choice-group,.trip-person-row) input[type=radio]+span{display:flex;flex-direction:column;align-items:center;justify-content:center;box-sizing:border-box;min-height:var(--trip-tap);height:100%;padding:2px 6px;border:2px solid #cbdde5;border-radius:12px;background:#fff;color:#0c4a6e;font-weight:900;line-height:1.15;text-align:center;cursor:pointer}
:is(.trip-segmented,.trip-choice-group,.trip-person-row) input[type=radio]:checked+span{border-color:#0369a1;background:#0369a1;color:#fff}
.trip-choice-group small{font-size:.78em;font-weight:700}
.trip-person-row{display:flex;flex-wrap:wrap;gap:8px}
.trip-person-row>label,.trip-person-toggle{flex:1 1 5em}
.trip-person-toggle{min-height:var(--trip-tap);border:2px solid #cbdde5;border-radius:12px;background:#fff;color:#0c4a6e;font:inherit;font-weight:900}
.trip-person-toggle[aria-pressed=true]{border-color:#0369a1;background:#e0f2fe;color:#075985}
.trip-person-toggle[aria-pressed=true]::before{content:"✓ "}
.trip-split-row{display:flex;align-items:center;gap:8px}
.trip-split-label{font-weight:900}
.trip-split-row strong{flex:1;min-width:0;color:#082f49}
.trip-split-panel{display:grid;gap:8px;padding:10px;border-radius:14px;background:#e0f2fe}
.trip-split-quick{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.trip-split-quick button{min-height:var(--trip-tap);border:2px solid #0369a1;border-radius:12px;background:#fff;color:#075985;font:inherit;font-weight:900}
.trip-split-quick button[aria-pressed=true]{background:#0369a1;color:#fff}
.trip-field{display:grid;gap:4px;font-weight:900;color:#334155}
.trip-more{border-radius:12px;background:#fff;border:1px solid #d5e8f0}
.trip-more summary{min-height:var(--trip-tap);display:flex;align-items:center;padding:0 12px;color:#075985;font-weight:800;cursor:pointer}
.trip-more[open]{display:grid;gap:8px;padding-bottom:12px}
.trip-more .trip-field{padding:0 12px}
.trip-form-actions{position:sticky;bottom:0;z-index:2;display:grid;gap:6px;padding:8px 0 2px;background:linear-gradient(#f5fbfe00,#f5fbfe 10px)}
.trip-form-buttons{display:flex;gap:8px}
.trip-form-buttons .trip-primary-button{flex:1;font-size:1.1em}
.trip-confirm{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:10px;border:2px solid #fecaca;border-radius:14px;background:#fff1f2;color:#7f1d1d;font-weight:800}
.trip-confirm span{flex:1 1 100%}
.trip-confirm button{flex:1}
.trip-rate-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:8px;font-weight:800}
.trip-records-dialog .trip-rate-row input[data-rate-input]{width:7em;flex:0 0 auto}
.trip-rate-ask{color:#9a3412;font-weight:800}
.trip-review-big{margin:0;color:#075985;font-size:1.8em;font-weight:900}
.trip-review-note{color:#526575;font-size:.92em}
.trip-review-raw{display:flex;flex-wrap:wrap;gap:4px 14px;color:#334155;font-weight:800}
.trip-review-group{display:grid;gap:var(--trip-gap)}
.trip-group-title{margin:6px 0 0}
.trip-legend{font-size:.88em}
.trip-legend i,.trip-bucket-detail i,.trip-category-totals i{display:inline-block;width:.8em;height:.8em;margin-right:5px;border-radius:3px;vertical-align:-1px}
.trip-bucket-row{display:grid;grid-template-columns:1fr auto;align-items:center;gap:6px 10px;box-sizing:border-box;width:100%;min-height:var(--trip-tap);padding:8px 10px;border:1px solid #d5e8f0;border-radius:12px;background:#fff;color:#082f49;font:inherit;text-align:left}
.trip-records-dialog .trip-bucket-row:disabled{border-color:#e2e8f0;background:#f8fafc;color:#64748b;cursor:default}
.trip-bucket-name{font-weight:800}
.trip-stack{grid-column:1/-1;display:flex;height:12px;overflow:hidden;border-radius:6px;background:#e2eef3}
.trip-stack i,.trip-bar i{display:block;height:100%}
.trip-bucket-detail{gap:4px;padding:6px 12px 2px}
.trip-bucket-detail li,.trip-transfers li{display:flex;justify-content:space-between;gap:10px}
.trip-category-totals li{display:grid;grid-template-columns:1fr auto 3em;align-items:center;gap:2px 8px}
.trip-category-totals small{color:#526575;text-align:right}
.trip-bar{grid-column:1/-1;display:block;height:8px;overflow:hidden;border-radius:4px;background:#e2eef3}
.trip-balances li{display:grid;gap:2px 10px;padding:8px 10px;border-radius:12px;background:#f8fcfe}
.trip-balances span{color:#526575;font-size:.9em}
.trip-balances b.is-receive{color:#166534}
.trip-balances b.is-pay{color:#b91c1c}
.trip-transfers li{padding:10px 12px;border-radius:12px;background:#fff7ed;color:#7c2d12;font-size:1.05em;font-weight:900}
.trip-settings summary{min-height:var(--trip-tap);display:flex;align-items:center;color:#075985;font-weight:900;cursor:pointer}
.trip-settings-list{margin-bottom:8px}
.trip-settings-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.trip-settings-name{flex:1;min-width:6em;font-weight:900}
.trip-records-dialog .trip-settings-list input[data-rename-input]{flex:1 1 8em;width:auto}
.trip-doc-group{display:grid;gap:8px}
.trip-doc-icon{display:grid;place-items:center;flex:0 0 auto;width:2.2em;height:2.2em;border-radius:12px;background:#e0f2fe;color:#075985}
.trip-doc-icon svg{width:1.3em;height:1.3em;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.trip-doc-status{flex:0 0 auto;padding:4px 10px;border-radius:999px;background:#f1f5f9;color:#475569;font-size:.82em;font-weight:900;white-space:nowrap}
.trip-doc-status[data-status=cached]{background:#dcfce7;color:#166534}
.trip-doc-status[data-status=loading]{background:#e0f2fe;color:#075985}
.trip-doc-status[data-status=network]{background:#fef3c7;color:#92400e}
.trip-file-pick{display:grid;gap:6px;padding:12px;border:2px dashed #7ab7d1;border-radius:14px;background:#f0f9ff;color:#075985;font-weight:900}
.trip-file-pick input{min-height:var(--trip-tap);max-width:100%;font:inherit;font-size:max(16px,.9em)}
.trip-file-pick input::file-selector-button{min-height:var(--trip-tap);margin-right:10px;padding:0 16px;border:2px solid #0369a1;border-radius:12px;background:#0369a1;color:#fff;font:inherit;font-weight:900}
.trip-viewer-head{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:10px;padding:4px 0;background:#f5fbfe}
.trip-viewer-head h3{flex:1;min-width:0;margin:0;font-size:1.1em;overflow-wrap:anywhere}
.trip-back-button{flex:0 0 auto;min-height:calc(var(--trip-tap) + 4px);padding:0 18px;border:2px solid #0369a1;border-radius:14px;background:#0369a1;color:#fff;font:inherit;font-size:1.1em;font-weight:900}
.trip-viewer-content{min-width:0;min-height:12em;padding:8px;border-radius:14px;background:#fff;border:1px solid #d5e8f0}
.trip-viewer-image{overflow:hidden;border-radius:8px;cursor:zoom-in}
.trip-viewer-image img{display:block;width:100%;height:auto}
.trip-viewer-image.actual-size{width:max-content;overflow:visible;cursor:grab}
.trip-viewer-image.actual-size img{width:auto;max-width:none}
.trip-viewer-hint{margin:6px 0 0;color:#526575;font-size:.85em;text-align:center}
.trip-pdf-page{display:block;width:100%;height:auto;margin:0 0 10px;box-shadow:0 1px 6px #082f4933;cursor:zoom-in}
.trip-viewer-content.is-zoomed{touch-action:pan-x pan-y pinch-zoom}
.trip-pdf-zoomed .trip-pdf-page{width:200%;cursor:grab}
.trip-viewer-text{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;font:inherit}
.trip-viewer-empty{margin:24px 8px;color:#526575;font-weight:800;text-align:center}
.trip-viewer-footer{display:grid;gap:6px;padding:8px 0 2px}
.trip-viewer-actions{display:grid;grid-template-columns:1.3fr 1fr 1fr;gap:8px}
@media (max-width: 760px), (max-width: 1000px) and (max-height: 600px){
  /* 收據 kept with an expense (2026-10-03): a thumbnail row in 記一筆 and a 收據 button under the expense row. */
  .trip-receipt-preview:not([hidden]){display:flex;align-items:center;gap:10px;padding:6px 8px;border:1px solid #bae6fd;border-radius:12px;background:#f0f9ff}
  .trip-receipt-preview img{width:44px;height:56px;object-fit:cover;border-radius:6px;background:#fff}
  .trip-receipt-label{display:grid;flex:1;min-width:0}
  .trip-receipt-label small{color:#526575}
  .trip-receipt-chip{min-height:44px;margin:4px 0 0;padding:0 16px;border:1px solid #7dd3fc;border-radius:999px;background:#fff;color:#075985;font:inherit;font-weight:800}
  /* The document viewer fills the card: only the document scrolls (both ways once zoomed) and the 存到手機／修改／刪除
     row sits below it, never over the document (owner report 2026-10-03). */
  .trip-records-dialog[data-view=documents-viewer] .trip-records-card{overflow:hidden}
  .trip-records-dialog[data-view=documents-viewer] .trip-records-panel:not([hidden]){display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
  .trip-viewer:not([hidden]){display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
  .trip-viewer-content:not([hidden]){flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain}
  .trip-viewer .trip-document-edit:not([hidden]){flex:1 1 auto;min-height:0;overflow:auto}
  /* Reference rates sit on their own line under the rate field (owner request 2026-10-03). */
  .trip-rate-ref{flex:1 0 100%;color:#526575;font-weight:700;font-size:.9em}
  .trip-rate-source{margin:0 0 8px;color:#526575;font-size:.8em;font-weight:600}
  .trip-rate-source [data-rate-notice]{display:block;color:#075985;font-weight:800}
  .trip-link-button{display:inline-flex;align-items:center;min-height:44px;margin-left:8px;padding:0 4px;border:0;background:none;color:#0369a1;font:inherit;font-weight:800;text-decoration:underline}
  .trip-rate-line{margin:0 0 6px;font-weight:800}
  .trip-records-dialog{--trip-tap:52px;--trip-gap:10px;width:100vw;height:100dvh;max-height:none;margin:0;border-radius:0;font-size:18px}
  /* The card has no top padding, so the sticky tabs sit flush with the top and nothing shows through above them
     (#6 review P2-4); the header carries the safe-area spacing instead. */
  .trip-records-card{height:100%;padding:0 12px calc(14px + env(safe-area-inset-bottom))}
  .trip-records-header{margin:0 -12px;padding:calc(8px + env(safe-area-inset-top)) 12px 6px}
  .trip-records-dialog[data-view=documents-viewer] .trip-viewer-head{margin:0 -12px;padding:calc(8px + env(safe-area-inset-top)) 12px 6px}
  /* In a form only the fields scroll; 儲存 sits below them and never covers a field (#6 review P2-5). */
  .trip-records-dialog:is([data-view=expenses-form],[data-view=documents-form]) .trip-records-card{overflow:hidden}
  .trip-records-dialog:is([data-view=expenses-form],[data-view=documents-form]) .trip-records-panel:not([hidden]){display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
  .trip-records-dialog :is(.trip-expense-form,.trip-document-form):not([hidden]){display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
  .trip-form-body{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;margin:0 -12px;padding:4px 12px 8px}
  .trip-form-actions{position:static;padding:4px 0 0;background:none}
  .trip-day-chips{grid-template-columns:repeat(4,minmax(0,1fr))}
  .trip-category-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
  .trip-doc-category-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .trip-date-chips{grid-template-columns:repeat(4,minmax(0,1fr))}
  .trip-balances li{grid-template-columns:1fr auto}
  .trip-balances span{grid-row:2}
  .trip-viewer-footer{margin:0 -12px;padding:8px 12px 2px}
  /* The document viewer takes the whole phone screen; its own 返回 leads back. */
  .trip-records-dialog[data-view=documents-viewer] .trip-records-header{display:none}
  /* 這天的票券 on the 行程 tab: full-width buttons at least 48px tall. */
  .day-documents:not([hidden]){display:grid;gap:8px;margin:0 0 12px;padding:12px;border:2px solid #fdba74;border-radius:16px;background:#fff7ed}
  .day-documents h3{margin:0;color:#7c2d12;font-size:1rem}
  .workspace.plan-view .planner-scroll-content>.day-documents{order:2}
  .day-documents-list{display:grid;gap:8px}
  .day-document-button{display:flex;align-items:center;gap:10px;box-sizing:border-box;width:100%;min-height:52px;padding:6px 12px;border:2px solid #fb923c;border-radius:14px;background:#fff;color:#7c2d12;font:inherit;font-size:1.05rem;font-weight:900;text-align:left}
  .day-document-button .trip-doc-icon{background:#ffedd5;color:#9a3412}
  /* The bottom nav has 帳本; the header ledger and 旅程設定 buttons are desktop-only; phones keep the settings fold. */
  .top-actions .trip-records-open,.top-actions .trip-settings-open{display:none}
  .trip-records-dialog .trip-config-link{display:none}
}
@media (max-width: 1000px) and (max-height: 600px){
  /* Landscape phones are short: slightly smaller controls, and the form puts amount beside currency and payer beside 分攤. */
  .trip-records-dialog{--trip-tap:46px;--trip-gap:8px;font-size:16px}
  .trip-expense-form .trip-form-body{grid-template-columns:minmax(0,1fr) minmax(0,1fr);column-gap:12px}
  .trip-expense-form .trip-form-body>*{grid-column:1/-1}
  .trip-expense-form .trip-form-body>:is(.trip-amount-row,.trip-segmented,.trip-payer-row,.trip-split-row){grid-column:auto;align-self:end}
  .trip-day-chips,.trip-category-grid,.trip-date-chips{grid-template-columns:repeat(8,minmax(0,1fr))}
  .trip-doc-category-grid{grid-template-columns:repeat(5,minmax(0,1fr))}
}
@media (min-width: 1001px), (min-width: 761px) and (min-height: 601px){
  /* 收據 kept with an expense (2026-10-03): a thumbnail row in 記一筆 and a 收據 button under the expense row. */
  .trip-receipt-preview:not([hidden]){display:flex;align-items:center;gap:12px;padding:6px 10px;border:1px solid #bae6fd;border-radius:12px;background:#f0f9ff}
  .trip-receipt-preview img{width:40px;height:52px;object-fit:cover;border-radius:6px;background:#fff}
  .trip-receipt-label{display:grid;flex:1;min-width:0}
  .trip-receipt-label small{color:#526575}
  .trip-receipt-chip{min-height:34px;margin:4px 0 0;padding:0 14px;border:1px solid #7dd3fc;border-radius:999px;background:#fff;color:#075985;font:inherit;font-weight:800;cursor:pointer}
  /* The document viewer fills the card: only the document scrolls (both ways once zoomed) and the 存到手機／修改／刪除
     row sits below it, never over the document (owner report 2026-10-03). */
  .trip-records-dialog[data-view=documents-viewer] .trip-records-card{overflow:hidden}
  .trip-records-dialog[data-view=documents-viewer] .trip-records-panel:not([hidden]){display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
  .trip-viewer:not([hidden]){display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
  .trip-viewer-content:not([hidden]){flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain}
  .trip-viewer .trip-document-edit:not([hidden]){flex:1 1 auto;min-height:0;overflow:auto}
  .trip-records-dialog[data-view=documents-viewer]{height:min(900px,calc(100dvh - 48px))}
  .trip-records-dialog[data-view=documents-viewer] .trip-records-card{height:100%}
  /* A zoomed document pans by dragging with the mouse. */
  .trip-viewer-content.is-dragging{cursor:grabbing;user-select:none}
  .trip-viewer-content.is-dragging :is(.trip-pdf-page,.trip-viewer-image){cursor:grabbing}
  /* Reference rates follow the rate field on the same line (owner request 2026-10-03). */
  .trip-rate-ref{color:#526575;font-weight:700;font-size:.9em}
  .trip-rate-source{margin:0 0 8px;color:#526575;font-size:.8em;font-weight:600}
  .trip-rate-source [data-rate-notice]{margin-left:8px;color:#075985;font-weight:800}
  .trip-link-button{margin-left:8px;padding:2px 4px;border:0;background:none;color:#0369a1;font:inherit;font-weight:800;text-decoration:underline;cursor:pointer}
  .trip-rate-line{margin:0 0 6px;font-weight:800}
  .trip-currency-add{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:10px 0;font-weight:800}
  .trip-currency-add select{min-height:40px;max-width:min(320px,100%);font:inherit;font-weight:600}
  .trip-records-dialog{--trip-tap:44px;--trip-gap:12px;width:min(820px,calc(100vw - 48px));height:auto;min-height:min(560px,calc(100dvh - 48px));max-height:min(900px,calc(100dvh - 48px));border-radius:20px;font-size:15px;box-shadow:0 22px 70px #082f4933}
  .trip-records-card{max-height:min(900px,calc(100dvh - 48px));padding:0 28px 24px}
  .trip-records-header{padding:16px 0 8px}
  .trip-records-tabs{max-width:420px}
  .trip-records-close{margin-left:auto}
  .trip-day-chips{grid-template-columns:repeat(7,minmax(0,1fr))}
  .trip-category-grid,.trip-date-chips{grid-template-columns:repeat(8,minmax(0,1fr))}
  .trip-doc-category-grid{grid-template-columns:repeat(5,minmax(0,1fr))}
  .trip-who-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
  .trip-balances li{grid-template-columns:1fr 1fr 1fr 1.2fr;align-items:center}
  .trip-big-button{max-width:360px}
  .trip-viewer-actions{grid-template-columns:repeat(3,max-content);justify-content:end}
  .trip-viewer-actions button{padding:0 20px}
  /* The tabs stay on top on desktop, so the viewer's own 返回 row scrolls with the document. */
  .trip-viewer-head{position:static}
  /* Desktop edits travellers, currencies and rates in 旅程設定; the ledger links there instead of its fold. */
  #tripLedgerSettings{display:none}
  .trip-config-dialog{width:min(640px,calc(100vw - 48px));min-height:0}
  .trip-config-dialog .trip-records-header h2{flex:1;margin:0;font-size:1.35em}
  .trip-config-link{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px}
  .trip-config-link p{margin:0}
  .trip-currency-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px 14px;padding:6px 0;border-bottom:1px solid #e2eef3}
  .trip-check{display:inline-flex;align-items:center;gap:8px;min-width:6em;min-height:var(--trip-tap);font-weight:900;cursor:pointer}
  .trip-check input{width:20px;height:20px;margin:0;accent-color:#0369a1}
  .trip-currency-note{color:#526575}
  .trip-currency-rate{display:inline-flex;align-items:center;gap:8px;font-weight:800}
  .trip-records-dialog .trip-currency-rate input[data-config-rate]{width:7em}
  /* 這天的票券 in the sidebar: one compact row of chips. */
  .day-documents:not([hidden]){display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;margin:0 0 10px}
  .day-documents h3{margin:0;color:#7c2d12;font-size:.78rem}
  .day-documents-list{display:flex;flex-wrap:wrap;gap:6px;min-width:0}
  .day-document-button{display:inline-flex;align-items:center;gap:6px;max-width:100%;min-height:34px;padding:2px 12px 2px 4px;border:1px solid #fdba74;border-radius:999px;background:#fff7ed;color:#7c2d12;font:inherit;font-size:.8rem;font-weight:800;cursor:pointer}
  .day-document-button .trip-doc-icon{width:26px;height:26px;border-radius:999px;background:#ffedd5;color:#9a3412}
  .day-document-button span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
}
.trip-records-dialog [hidden][hidden]{display:none}
