/* Shared back-office and login styles; no selectors escape this scope. */
.ats-ui {
    --nav: #13203a;
    --nav-deep: #0c1526;
    --page: #f3f5f9;
    --surface: #fff;
    --ink: #1b2537;
    --muted: #556176;
    --border: #e3e8ef;
    --field-border: #d3dae5;
    --blue: #3656d6;
    --blue-dark: #2a45b8;
    --blue-soft: #eef2ff;
    --ring: rgb(54 86 214 / 18%);
    --success: #15803d;
    --success-bg: #ecfdf3;
    --warning: #b45309;
    --warning-bg: #fff7ed;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --radius: 12px;

    margin: 0;
    box-sizing: border-box;
    color: var(--ink);
    background: var(--page);
    font: 14px/1.6 "Segoe UI", "Microsoft JhengHei", sans-serif;
    letter-spacing: 0;

    *, *::before, *::after { box-sizing: border-box; }
    /* hidden 屬性一律隱藏：按鈕等元件自帶 display（inline-flex 等）會蓋過瀏覽器預設的 [hidden]，
       例如提示視窗隱藏「取消」後仍顯示（共用確認視窗的 notice 模式）。 */
    [hidden] { display: none !important; }
    a { color: var(--blue); text-decoration: none; }
    a:hover { text-decoration: underline; }
    :focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
    button, input, select, textarea { font: inherit; }
    button { cursor: pointer; }
    h1 { font-size: 28px; line-height: 1.25; margin: 0 0 8px; }
    h2 { font-size: 18px; margin: 0 0 8px; }

    .app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
    .sidebar { position: sticky; top: 0; height: 100vh; background: linear-gradient(180deg, var(--nav) 0%, var(--nav-deep) 100%); color: #b9c4d8; padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / 18%) transparent; }
    .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
    .sidebar-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
    .brand { color: white; font-size: 18px; font-weight: 700; line-height: 1.35; display: block; padding: 0 12px; }
    .nav-label { color: #8492ab; font-size: 13px; font-weight: 600; line-height: 20px; padding: 16px 12px 4px; margin-top: 8px; border-top: 1px solid rgb(255 255 255 / 7%); }
    .nav-label:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
    .nav-link { display: flex; align-items: center; min-height: 44px; padding: 8px 12px; border-radius: 8px; color: #b9c4d8; transition: background-color .15s ease, color .15s ease; }
    .nav-link:hover { color: white; background: rgb(255 255 255 / 6%); text-decoration: none; }
    .nav-link[aria-current="page"] { color: white; background: rgb(106 137 255 / 18%); box-shadow: inset 3px 0 0 #8aa4ff; font-weight: 600; text-decoration: none; }
    .sidebar :focus-visible { outline-color: #93c5fd; }
    /* 測試環境（SiteAppearance:IsStaging）：左側選單改為綠色，一眼區分 staging 與正式環境。
       綠底上的分類標題與連結另調顏色，維持 4.5:1 以上對比。 */
    &.env-staging {
        --nav: #14532d;
        --nav-deep: #052e16;
        .nav-label { color: #a3c9b1; }
        .nav-link { color: #cfe3d6; }
        .nav-link:hover, .nav-link[aria-current="page"] { color: white; }
        .nav-link[aria-current="page"] { background: rgb(74 222 128 / 18%); box-shadow: inset 3px 0 0 #86efac; }
        .sidebar :focus-visible { outline-color: #86efac; }
    }
    .main-area { min-width: 0; }
    .topbar { min-height: 68px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 1px 2px rgb(16 24 40 / 4%); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 32px; }
    .context { flex-shrink: 0; }
    .context strong { font-weight: 600; }
    .account-bar { min-width: 0; display: flex; align-items: center; gap: 16px; color: var(--muted); }
    .account-name { overflow-wrap: anywhere; }
    .logout-button { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--blue); padding: 8px 0; }
    .menu-toggle { display: none; flex-shrink: 0; border: 1px solid var(--border); background: white; border-radius: 8px; width: 44px; height: 44px; padding: 10px; color: var(--ink); }
    .menu-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
    .sidebar .menu-toggle { color: white; background: rgb(255 255 255 / 8%); border-color: rgb(255 255 255 / 16%); }
    .drawer-backdrop { display: none; }
    .sidebar .collapse-toggle { display: block; }
    &.nav-collapsed .topbar .menu-toggle { display: block; }
    &.nav-collapsed .app-shell { grid-template-columns: minmax(0, 1fr); }
    &.nav-collapsed .sidebar { display: none; }
    main { margin: 0 auto; padding: 24px; }

    .breadcrumbs { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
    .breadcrumbs span { margin: 0 4px; }
    .breadcrumbs a { text-decoration: underline; text-underline-offset: 3px; }
    .page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 24px; }
    .page-heading p { color: var(--muted); margin: 0; }
    .primary-button, .secondary-button, .danger-button { min-height: 44px; border-radius: 8px; padding: 8px 16px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
    .primary-button { color: white; background: var(--blue); box-shadow: 0 1px 2px rgb(54 86 214 / 30%); }
    .primary-button:hover { background: var(--blue-dark); text-decoration: none; }
    .secondary-button { color: var(--ink); background: white; border-color: var(--border); }
    .secondary-button:hover { background: #f6f8fb; border-color: var(--field-border); text-decoration: none; }
    .danger-button { background: var(--danger); color: white; }
    .danger-button:hover { background: #912018; }
    [aria-disabled="true"] { cursor: wait; }
    .surface { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgb(16 24 40 / 4%), 0 4px 12px rgb(16 24 40 / 4%); }

    .toolbar { padding: 16px; margin-bottom: 16px; display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
    .toolbar .field { min-width: 0; flex: 1 1 220px; margin: 0; }
    .field { margin: 0 0 24px; }
    label, legend, .field-label { color: var(--ink); font-weight: 600; display: block; margin-bottom: 8px; }
    legend { padding: 0; }
    input:not([type="checkbox"]):not([type="radio"]), select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--field-border); border-radius: 8px; background: white; color: var(--ink); transition: border-color .15s ease, box-shadow .15s ease; }
    input:not([type="checkbox"]):not([type="radio"]):hover, select:hover, textarea:hover { border-color: #b7c1d1; }
    input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 0; box-shadow: 0 0 0 3px var(--ring); }
    ::placeholder { color: #8a95a8; }
    input[type="checkbox"], input[type="radio"] { flex-shrink: 0; width: 18px; height: 18px; accent-color: var(--blue); }
    .hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
    .phone-legacy-warning { display: block; color: var(--warning); }
    .phone-legacy-warning[hidden] { display: none; }
    .required, .required-note { display: inline-flex; align-items: center; margin: 0 0 8px; padding: 0 8px; border-radius: 999px; color: var(--danger); background: var(--danger-bg); font-size: 12px; font-weight: 600; line-height: 20px; }
    label > .required, legend > .required { margin: 0 0 0 4px; vertical-align: 1px; }
    .field:has(> .required, > .required-note) { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; column-gap: 8px; }
    .field:has(> .required, > .required-note) > * { flex: 0 0 100%; }
    .field:has(> .required, > .required-note) > label, .field > .required, .field > .required-note { flex: 0 0 auto; }
    .validation { color: var(--danger); }
    .validation-summary-valid { display: none; }
    .validation-summary-errors { background: var(--danger-bg); border: 1px solid #fecaca; border-radius: 8px; padding: 12px 16px; margin-bottom: 24px; }
    .success { color: var(--success); background: var(--success-bg); border: 1px solid #bbf7d0; border-radius: 8px; padding: 12px 16px; }
    .result-meta { color: var(--muted); margin: 16px 0; }

    .table-wrap { position: relative; overflow-x: auto; }
    .audit-metadata { padding: 20px; overflow-wrap: anywhere; }
    .audit-metadata dt { font-weight: 600; color: var(--muted); }
    .audit-metadata dd { margin: 0 0 12px; }
    .audit-links { margin: 20px 0; flex-wrap: wrap; }
    .audit-table thead th { width: 20%; }
    .audit-diff { min-width: 650px; }
    .audit-diff th:first-child { width: 22%; }
    .audit-diff th:nth-child(2), .audit-diff th:nth-child(3) { width: 39%; }
    .audit-diff td { white-space: pre-wrap; }
    /* 列表表格共用：撐滿 .table-wrap 並在窄螢幕水平捲動。欄寬百分比只放在各表格專屬 class（#477），沒有 class 的表格在
       table-layout: fixed 下平均分欄。 */
    table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 900px; }
    th, td { padding: 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
    th { color: var(--muted); font-size: 12px; background: #f8fafc; }
    td { overflow-wrap: anywhere; }
    td:first-child { font-weight: 600; }
    tbody tr:hover { background: #f8fafc; }
    tbody tr:last-child td { border-bottom: 0; }
    .badge { display: inline-flex; align-items: center; max-width: 100%; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
    .badge-active { color: var(--success); background: var(--success-bg); }
    .badge-inactive { color: var(--warning); background: var(--warning-bg); }
    .badge-primary { color: #1e40af; background: #dbeafe; }
    .role-list { display: flex; flex-wrap: wrap; gap: 4px; }
    .role-badge { color: #1e40af; background: #eff6ff; }
    /* 帳號管理的公司／車行帳號頁籤（#351）。 */
    .user-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); overflow-x: auto; }
    .user-tabs a { flex: none; min-height: 40px; display: inline-flex; align-items: center; padding: 8px 16px; color: #3c4043; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
    .user-tabs a:hover { text-decoration: none; background: #f1f3f4; }
    .user-tabs a[aria-current="page"] { color: #107c41; border-bottom-color: #107c41; }
    .row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
    .row-actions a, .row-actions .text-action { min-height: 44px; display: inline-flex; align-items: center; padding: 8px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
    .row-actions a:hover, .row-actions .text-action:hover { background: #dbeafe; text-decoration: none; }
    /* Status / export buttons sit in their own forms; align them with the links beside them. */
    .row-actions form { display: inline-flex; }
    .row-actions .text-action { margin-top: 0; }
    /* In table cells, pull the 44px targets back by half the gap to one text line so labels share the row's first baseline. */
    td > .row-actions { margin-block: calc((1.6em - 44px) / 2); }
    .row-actions .status-action { color: var(--danger); }
    .empty-state { padding: 32px 24px; text-align: center; }
    .empty-state p { color: var(--muted); margin: 4px 0 16px; }
    .pagination { display: flex; gap: 8px; margin-top: 16px; }
    .pagination a { min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: white; }
    .sheet-pager { flex-wrap: wrap; align-items: center; justify-content: center; }
    .sheet-pager a, .sheet-pager span { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 12px; }
    .sheet-pager span[aria-current="page"] { border-radius: 8px; background: var(--blue); color: white; font-weight: 700; }
    .sheet-pager span[aria-disabled="true"] { color: var(--muted); border: 1px solid var(--border); border-radius: 8px; opacity: .6; }
    .sheet-pager .sheet-pager-gap { min-width: 0; padding: 8px 2px; color: var(--muted); }

    /* Forms use the full content width: fields flow into as many columns as fit, everything else spans the row. */
    .form-panel { width: 100%; padding: 24px; }
    .form-panel:not(.payment-panel) { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); column-gap: 20px; align-items: start; }
    .form-panel:not(.payment-panel) > :not(.field), .form-panel > .field:has(textarea), .form-panel > .field-wide { grid-column: 1 / -1; }
    /* 表單最上方的整列說明與第一個欄位標籤保持間距（例如預設備註）。 */
    .form-panel > .hint { margin: 0 0 16px; }
    .customer-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 0 20px; }
    .customer-form-grid .field-wide { grid-column: 1 / -1; }
    /* 車行欄顏色：勾選框與兩個小色塊同一組，色塊維持控制項高度的方形，不拉滿欄寬。 */
    .vendor-color-group { margin-bottom: 24px; }
    .vendor-color-group .checkbox-row { margin-bottom: 12px; }
    .vendor-color-pickers { display: flex; flex-wrap: wrap; gap: 0 24px; }
    .vendor-color-pickers .field { margin-bottom: 8px; }
    .vendor-color-pickers input[type="color"] { width: 72px; height: 44px; padding: 4px; cursor: pointer; }
    .form-section { border-top: 1px solid var(--border); padding-top: 16px; margin: 8px 0 24px; }
    .form-section summary, .details-section summary { cursor: pointer; font-size: 17px; font-weight: 700; margin-bottom: 16px; }
    .date-default-button, .text-action { margin-top: 8px; border: 0; padding: 4px 0; color: var(--blue); background: transparent; cursor: pointer; }
    .text-action { min-height: 44px; }
    .duplicate-warning { margin: 24px 0; padding: 16px; color: var(--warning); background: var(--warning-bg); border: 1px solid #fed7aa; border-radius: 8px; }
    .duplicate-warning h2 { font-size: 17px; }
    .search-note { margin: -8px 0 16px; }
    .relationship-table { min-width: 680px; }
    .details-section { padding: 20px; margin-bottom: 16px; }
    .details-section h2 { font-size: 18px; margin-bottom: 16px; }
    .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
    .order-section > .section-heading { align-items: center; padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
    .section-heading h2 { margin-bottom: 4px; }
    /* Keeps "bank code-account number" on one line; the bank name may still wrap before it. */
    .contact-account-code { white-space: nowrap; }
    /* #307：點帳號只複製帳號本身，右側短暫顯示結果標籤（同總表順序編號的提示）。 */
    .copy-account-number { position: relative; padding: 0; font: inherit; color: inherit; background: none; border: 0; text-decoration: underline dotted; text-underline-offset: 3px; cursor: copy; }
    .copy-account-number:hover { color: var(--blue); }
    .copy-account-number:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
    .copy-account-number[data-copied]::after { content: attr(data-copied); position: absolute; top: 50%; left: calc(100% + 6px); z-index: 5; transform: translateY(-50%); padding: 2px 6px; color: #fff; background: var(--ink); border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }
    .settlement-account-table th:last-child { min-width: 250px; }
    .account-number { font-family: Consolas, "Courier New", monospace; letter-spacing: .04em; overflow-wrap: anywhere; }
    .status-stack { display: flex; flex-wrap: wrap; gap: 6px; }
    .payment-facts { margin: 14px 0 0; display: grid; gap: 8px; }
    .payment-facts div { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 12px; }
    .payment-facts dt { color: var(--muted); font-size: 13px; font-weight: 700; }
    .payment-facts dd { margin: 0; overflow-wrap: anywhere; }
    .payment-panel { display: grid; gap: 20px; }
    .payment-panel form { display: grid; gap: 18px; }
    .payment-summary { display: grid; gap: 4px; padding: 16px; border-radius: 10px; background: #eff6ff; }
    .payment-summary span, .payment-summary small { color: var(--muted); }
    .payment-summary small, .collector-options small { font-size: 12px; }
    .payment-summary strong { color: var(--blue); font-size: 24px; }
    .collector-options { display: grid; gap: 10px; }
    .collector-options .choice { align-items: flex-start; }
    .collector-options .choice span { display: grid; gap: 2px; }
    .collector-options small { color: var(--muted); }
    .checkbox-row { display: flex; align-items: center; gap: 10px; margin: 0 0 24px; }
    .notice { color: var(--warning); background: var(--warning-bg); border: 1px solid #fed7aa; border-radius: 8px; padding: 12px 16px; }
    .tab-links { display: flex; gap: 8px; margin: 0 0 16px; }
    .tab-links a { min-height: 44px; padding: 8px 16px; display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: white; font-weight: 600; }
    .tab-links a.active { color: white; background: var(--blue); border-color: var(--blue); text-decoration: none; }
    .table-scroll-hint { display: none; }
    .details-grid { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr); gap: 8px 16px; margin: 0; }
    .details-grid dt { color: var(--muted); font-weight: 600; }
    .details-grid dd { margin: 0; overflow-wrap: anywhere; }
    .pre-wrap { white-space: pre-wrap; }
    .announcement-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
    .announcement-section { padding: 20px; min-width: 0; container-type: inline-size; }
    .announcement-section h2 { margin-bottom: 16px; }
    .announcement-card { overflow-wrap: anywhere; }
    .announcement-section > .announcement-card { border-top: 1px solid var(--border); padding: 16px 0; }
    .announcement-section > .announcement-card:first-of-type { border-top: 0; padding-top: 0; }
    .announcement-card h3 { font-size: 16px; margin: 0 0 8px; }
    .announcement-meta { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
    .announcement-columns .announcement-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
    .announcement-columns .announcement-card:only-child { grid-column: 1 / -1; }
    @container (max-width: 640px) { .announcement-columns { grid-template-columns: 1fr; } }
    .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
    /* #289 請款單設定：三個區塊上下排列，印章預覽比照 PDF 上約 3.9 × 3.8 cm 的大小。 */
    .company-settings-message { margin: 0 0 16px; }
    .company-settings-section { border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 20px; }
    .company-settings-section h2 { font-size: 18px; margin-bottom: 4px; }
    .company-settings-section > .hint { margin: 0 0 16px; }
    .company-stamp { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px; }
    .company-stamp .field { flex: 1 1 260px; }
    .company-stamp-preview { width: 148px; height: 144px; object-fit: contain; border: 1px dashed var(--field-border); border-radius: 8px; background: white; }
    .company-stamp-empty { display: grid; place-items: center; color: var(--muted); font-size: 13px; }
    .identity { color: var(--muted); margin: 0 0 24px; overflow-wrap: anywhere; }
    fieldset { border: 0; padding: 0; margin: 0 0 24px; }
    .choice-list { display: grid; gap: 12px; margin-top: 12px; }
    .choice { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-weight: 400; margin: 0; }
    .choice span { min-width: 0; overflow-wrap: anywhere; }
    .choice:has(input:checked) { border-color: #93c5fd; background: #eff6ff; }
    .login-page { min-height: 100vh; max-width: none; width: 100%; display: grid; place-items: center; padding: 24px; }
    .login-panel { width: min(100%, 420px); padding: 32px; }
    .login-brand { color: var(--nav); font-size: 20px; font-weight: 700; margin-bottom: 32px; }
    .login-panel h1 { font-size: 26px; }
    .login-description { margin: 8px 0 24px; }
    .login-panel .primary-button { width: 100%; margin-top: 8px; }
    /* 驗證碼：輸入框、圖片與「換一張」同列；窄螢幕放不下時圖片與按鈕一起換到下一列。 */
    .captcha-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
    .captcha-row input { flex: 1 1 120px; min-width: 0; }
    .captcha-visual { flex: none; display: flex; align-items: center; gap: 8px; }
    .captcha-image { flex: none; width: 132px; height: 44px; border: 1px solid var(--border); border-radius: 8px; background: white; }
    .captcha-refresh { flex: none; padding: 8px 12px; }
    /* 登入頁最下方的網站製作公司連結。 */
    .login-page:has(> .login-credit) { grid-template-rows: 1fr auto; }
    .login-credit { color: var(--muted); font-size: 13px; padding-top: 24px; }
    .login-credit a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
    dialog { width: min(480px, calc(100% - 32px)); border: 1px solid var(--border); border-radius: 12px; padding: 24px; color: var(--ink); }
    dialog::backdrop { background: rgb(15 23 42 / 45%); }
    .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .skip-link { position: fixed; z-index: 50; top: 8px; left: 8px; padding: 12px; background: white; transform: translateY(-150%); }
    .skip-link:focus { transform: translateY(0); }
    .is-hidden { display: none !important; }
    .order-draft-form { width: 100%; display: grid; gap: 20px; }
    .order-section { padding: 24px; }
    .section-kicker { display: block; color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
    .status-chip { color: var(--warning); background: var(--warning-bg); border-radius: 999px; padding: 4px 10px; font-weight: 700; }
    .field-grid { display: grid; gap: 0 20px; }
    .field-grid.two-columns, .field-grid.three-columns { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
    .choice-row { display: flex; align-items: flex-start; gap: 12px; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin: 0; background: #f8fafc; cursor: pointer; }
    .choice-row:hover { border-color: #cbd5e1; }
    .choice-row:has(input:checked) { border-color: #a9b8f5; background: var(--blue-soft); }
    /* #348：舉牌、用餐、寵物的內容欄放在勾選框右側同一列；寬度不足時內容欄換到勾選框正下方，不產生水平捲動。 */
    .sign-board-fields { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 16px; }
    /* 並列時剩餘寬度幾乎全給內容欄；換行後勾選框獨占一列並撐滿寬度。 */
    .sign-board-fields > .choice-row { flex: 1 1 260px; max-width: 100%; }
    .sign-board-fields > .field { flex: 999 1 260px; min-width: 0; }
    /* 訂單表單的舉牌、用餐、寵物並排三欄：勾選卡片在上、內容欄在下，以 subgrid 讓三組卡片與輸入框各自同列對齊。 */
    .extra-service-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; margin-top: 20px; }
    .extra-service-grid > .sign-board-fields { display: grid; grid-row: span 2; grid-template-rows: subgrid; gap: 10px 0; }
    .field-grid > .choice-row { align-self: start; margin-top: 30px; }
    .choice-row input { margin-top: 5px; }
    .choice-row small { display: block; color: var(--muted); font-weight: 400; }
    .field-grid.field-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    /* 預設備註頁各類型的備註1、備註2（2026-11-15）各佔一半寬度，長文字不被截斷。 */
    .field-grid.field-row-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* #309：訂單表單每趟第一列（承辦業務／客戶來源／同業業務／服務類型）四欄；第二列起（乘車日期、上車時間、車型、人數及依服務類型顯示的機場／航班欄）同為四欄。 */
    .field-grid.field-row-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    @media (max-width: 1100px) { .field-grid.field-row-four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
    .subsection { border-top: 1px solid var(--border); padding-top: 20px; }
    /* 訂單表單趟次以底色分段：粉紅色＝承辦業務至人數等行程基本欄位；綠色＝地址至兒童座椅、舉牌、用餐與寵物；藍色＝金額至內部備註。輸入框維持白底。 */
    /* 底部內距由最後一列欄位的 margin-bottom（24px）提供；flow-root 讓該 margin 留在色塊內，不穿出底部。 */
    .trip-block { display: flow-root; margin-top: 20px; padding: 20px 20px 0; border-radius: var(--radius); }
    .trip-block-pink { background: #f4cccc; }
    .trip-block-green { background: #b6d7a8; }
    .trip-block-blue { background: #cfe2f3; }
    /* #565 新增車輛：每台車一個區塊（只有綠、藍色塊），下方為「新增車輛」按鈕列。 */
    .vehicle-list { display: grid; gap: 20px; }
    .vehicle-list:empty { display: none; }
    .vehicle-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 16px 24px; }
    .vehicle-actions .hint { flex: 1 1 320px; margin: 0; }
    .trip-block > .subsection:first-child { border-top: 0; padding-top: 0; }
    .trip-block > fieldset:last-child { margin-bottom: 0; }
    .trip-block .subsection { border-top-color: rgb(15 23 42 / 15%); }
    .subsection > legend { float: left; width: 100%; font-size: 16px; margin-bottom: 12px; }
    .subsection > legend + * { clear: both; }
    .subsection > legend + .hint { margin: -8px 0 16px; }
    .stop-list { display: grid; gap: 8px; margin-bottom: 12px; }
    /* #564：地址、人數、大名、電話；人數欄只需數字寬度。 */
    .stop-row { display: grid; grid-template-columns: 32px minmax(0, 2fr) minmax(64px, 88px) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
    .stop-row .field { margin: 0; }
    .stop-number { width: 28px; height: 28px; margin-bottom: 8px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); border-radius: 50%; font-weight: 700; }
    .stop-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
    .stop-drag-handle { padding: 0 4px; color: var(--muted); font-size: 20px; line-height: 1; cursor: grab; user-select: none; }
    /* 機場／港口／航廈列表的排序欄（2026-11-15）：只放 ↑／↓ 按鈕；表格為 table-layout: fixed，給兩顆按鈕加內距的固定寬度，不平均分欄。 */
    .transport-sort { width: 112px; white-space: nowrap; }
    .transport-sort .stop-actions { flex-wrap: nowrap; }
    .stop-row.is-dragging { opacity: .5; }
    .item-grid .baggage-notes { grid-column: span 2; }
    /* 金額四欄等寬（與 field-row-four 相同斷點）；請款單勾選以 order 排到金額欄下方獨占一列，DOM 順序不變。 */
    .field-grid.price-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    @media (max-width: 1100px) { .field-grid.price-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
    .field-grid.price-grid > .billing-document-choice { order: 1; grid-column: 1 / -1; justify-self: start; margin: 0; }
    .sheet-stop-contact { display: block; font-weight: 400; }
    .sheet-contact-line { display: block; }
    .sheet-baggage-notes { display: inline-block; min-width: 4em; max-width: 12em; white-space: normal; font-weight: 400; }
    /* 總表與派車表的行李備註放在備註欄、原備註下一列。 */
    .sheet-notes .sheet-baggage-notes { display: block; min-width: 0; max-width: none; white-space: pre-wrap; }
    /* 備註1、備註2（#567）：客戶可見備註，在總表備註欄內部備註下方各占一列。 */
    .sheet-notes .sheet-customer-remark { display: block; white-space: pre-wrap; }
    /* 備註、備註1、備註2 的 [紅]文字[/紅]（2026-11-15 起訂單總表與訂單明細也支援，與訂車單相同的 CustomerOrderRemarkMarkup）。 */
    .sheet-notes .co-remark-red, .order-detail .trip-notes .co-remark-red { color: #e00; }
    .item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 16px; }
    .child-seat-list { display: grid; gap: 8px; margin-bottom: 12px; }
    .child-seat-row { display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)) auto; gap: 12px; align-items: end; }
    .child-seat-row .field { margin: 0; }
    /* #347：已填一種座椅時其他種類鎖住，以灰底與禁止游標標示。 */
    .child-seat-row input:disabled { background: #f1f5f9; color: var(--muted); cursor: not-allowed; }
    .child-seat-error { grid-column: 1 / -1; }
    .child-seat-error:empty { display: none; }
    .compact { min-height: 44px; padding-inline: 12px; }
    .order-draft-form > .form-actions { position: sticky; bottom: 0; z-index: 5; padding: 12px 24px; background: rgb(255 255 255 / 94%); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 -4px 16px rgb(15 23 42 / 6%); }
    .order-delete { width: 100%; margin-top: 24px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
    .order-delete p { margin: 4px 0 0; }
    .order-filter .field { flex-basis: 180px; }
    .view-tabs { display: flex; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
    .view-tabs a { padding: 10px 16px; margin-bottom: -1px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; }
    .view-tabs a:hover { text-decoration: none; color: var(--ink); }
    .view-tabs a[aria-current="page"] { color: var(--blue); border-bottom-color: var(--blue); }
    /* Month tabs sit under the sheet like a workbook's sheet tabs and stay in view while scrolling a long page.
       訂單總表的頁籤放在 main 之後（版面 AfterMain 區段），桌面版固定在捲動區域下方。 */
    .sheet-month-tabs { position: sticky; bottom: 0; z-index: 4; display: flex; gap: 2px; padding: 0 8px; overflow-x: auto; background: #f1f3f4; border-top: 1px solid var(--border); }
    .sheet-month-tabs a { flex: none; min-height: 40px; display: inline-flex; align-items: center; padding: 8px 16px; color: #3c4043; font-size: 14px; white-space: nowrap; border-bottom: 3px solid transparent; }
    .sheet-month-tabs a:hover { text-decoration: none; background: #e3e5e8; }
    .sheet-month-tabs a[aria-current="page"] { background: white; color: #107c41; font-weight: 700; border-bottom-color: #107c41; box-shadow: 1px 0 0 var(--border), -1px 0 0 var(--border); }
    /* The workbook's monthly vendor footer ("D400趟+P400趟"); wraps on phones instead of widening the page. */
    .sheet-vendor-summary { margin: 0; padding: 10px 12px; background: white; border: 1px solid var(--border); border-top: 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
    .sheet-vendor-summary-label { color: var(--muted); font-weight: 600; }
    /* Sheets are paged (100 trips a page) instead of scrolling inside the table, so the header sticks to the page
       （訂單總表桌面版則黏在 main 捲動區域的頂端）. */
    .sheet-wrap { overflow: visible; }
    .order-sheet { width: 100%; min-width: 0; table-layout: auto; font-size: 13px; }
    .order-sheet th, .order-sheet td { padding: 6px; border: 1px solid var(--border); text-align: center; vertical-align: middle; overflow-wrap: anywhere; }
    .order-sheet thead th { position: sticky; top: 0; z-index: 2; white-space: nowrap; }
    .order-sheet tbody tr:hover td { background: #f8fafc; }
    .order-sheet .sheet-no, .order-sheet .sheet-date, .order-sheet .sheet-time { white-space: nowrap; }
    .order-sheet .sheet-source { min-width: 72px; }
    .order-sheet .sheet-contact { white-space: nowrap; }
    .order-sheet .sheet-address { min-width: 120px; }
    .order-sheet .sheet-notes { min-width: 80px; white-space: pre-wrap; }
    /* Only body cells take their own alignment; every header stays centred like the rest of the sheet's header row. */
    .order-sheet td.sheet-address, .order-sheet td.sheet-notes { text-align: left; }
    .order-sheet .sheet-nowrap { white-space: nowrap; overflow-wrap: normal; }
    /* Sign-board text is free text up to 100 characters, so it wraps under the 舉牌 label instead of widening the column. */
    .sheet-seat-line { display: block; white-space: nowrap; }
    /* #349：舉牌、用餐、寵物同一格，每項各自一段。 */
    .sheet-extra { display: block; }
    .sheet-extra + .sheet-extra { margin-top: 4px; }
    .sheet-sign-text { display: block; min-width: 6em; max-width: 14em; margin-top: 2px; white-space: normal; overflow-wrap: anywhere; text-align: left; font-weight: 600; }
    .order-sheet .sheet-location { min-width: 84px; }
    /* #238: an alerted vendor row blinks with a tint over its own cell colours (an animation outranks the Excel palette),
       and always carries a text label so the alert never relies on colour or motion alone. */
    .order-sheet .sheet-ack form { margin-top: 4px; }
    .order-sheet .sheet-ack-button { min-height: 0; padding: 3px 12px; font-size: 12px; white-space: nowrap; }
    .order-sheet .sheet-ack-button:disabled { opacity: .45; cursor: not-allowed; }
    .vendor-change-label { display: block; color: var(--danger); font-weight: 700; white-space: nowrap; }
    .order-sheet tr.vendor-change-alert > td, .order-sheet tr.sheet-change-alert > td { animation: vendor-change-blink 1s steps(1, end) infinite; }
    .order-sheet .sheet-vendor { min-width: 40px; }
    /* 總表車行欄的下拉選單（#259，#559 曾改為雙擊視窗後恢復）：沿用格子的車行底色與字色。 */
    .order-sheet .sheet-vendor-select { width: auto; min-width: 56px; min-height: 0; padding: 2px 4px; border-color: currentColor; background: transparent; color: inherit; font-weight: inherit; cursor: pointer; }
    .order-sheet .sheet-vendor-select option { background: white; color: var(--ink); }
    .order-sheet .sheet-vendor-form[aria-busy="true"] .sheet-vendor-select { opacity: .6; pointer-events: none; }
    .order-sheet .sheet-muted { color: var(--muted); font-size: 12px; }
    .order-sheet .sheet-amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
    .order-sheet td.sheet-amount { text-align: right; }
    .order-sheet form { margin: 0; }
    .order-sheet .sheet-pdf-button { min-height: 0; padding: 3px 10px; font-size: 12px; }
    /* Editable cells open a one-field dialog on double-click (replacing the old detail button); the hover frame shows which. */
    .order-sheet tr[data-sheet-edit-url] td[data-sheet-field] { cursor: cell; touch-action: manipulation; }
    .order-sheet tr[data-sheet-edit-url] td[data-sheet-field]:hover { box-shadow: inset 0 0 0 2px var(--blue); }
    .order-sheet :is(td[data-sheet-payment-url], td[data-sheet-dialog-url]) { cursor: cell; touch-action: manipulation; }
    .order-sheet :is(td[data-sheet-payment-url], td[data-sheet-dialog-url]):hover { box-shadow: inset 0 0 0 2px var(--blue); }
    .order-sheet tbody td.sheet-no, .order-sheet tbody td.sheet-source { position: sticky; z-index: 1; background: var(--surface); }
    .order-sheet thead th.sheet-no, .order-sheet thead th.sheet-source { z-index: 3; }
    .order-sheet .sheet-no { left: 0; width: 56px; min-width: 56px; max-width: 56px; }
    .order-sheet .sheet-source { left: 56px; }
    .order-sheet th.sheet-no, .order-sheet th.sheet-source { position: sticky; }
    .order-sheet .sheet-dropoff { color: var(--danger); font-weight: 600; }
    /* The dispatch sheet carries seven more columns than the order sheet, so it packs tighter to fit desktop width. */
    .dispatch-sheet { font-size: 12px; }
    .dispatch-sheet th, .dispatch-sheet td { padding: 4px 3px; }
    .dispatch-sheet thead th { white-space: normal; word-break: keep-all; }
    .dispatch-sheet .sheet-source { min-width: 48px; }
    .dispatch-sheet .sheet-location { min-width: 0; }
    .dispatch-sheet .sheet-address { min-width: 72px; }
    .dispatch-sheet .sheet-notes { min-width: 56px; }
    .dispatch-sheet .sheet-no { width: 40px; min-width: 40px; max-width: 40px; }
    .dispatch-sheet .sheet-source { left: 40px; }
    /* The overview keeps its detail button under the row number, so its first column stays wider. */
    .overview-sheet .sheet-no { width: 48px; min-width: 48px; max-width: 48px; }
    .overview-sheet .sheet-source { left: 48px; }
    /* #258：「選取」欄位於編號與來源欄之間，與兩者一起固定在左側。 */
    .order-sheet .sheet-pick { left: 48px; width: 40px; min-width: 40px; max-width: 40px; }
    .order-sheet tbody td.sheet-pick { position: sticky; z-index: 1; background: var(--surface); }
    .order-sheet th.sheet-pick { position: sticky; z-index: 3; }
    .order-sheet th.sheet-pick .sheet-select input, .order-sheet td.sheet-pick input.sheet-select { margin: 0; }
    /* 車行訂單的編號欄沿用派車總表的 40px，選取欄緊接其後。 */
    .vendor-sheet .sheet-pick { left: 40px; }
    .dispatch-sheet .sheet-date { white-space: normal; }
    .dispatch-sheet .mark-toggle { width: 26px; height: 26px; font-size: 15px; }
    .order-sheet td.sheet-pending { background: var(--warning-bg); color: var(--warning); font-weight: 700; }
    /* Trips still awaiting review stand out so reviewers can spot them while scanning the sheet. */
    .order-sheet td.sheet-review-pending { background: var(--warning-bg); color: var(--danger); font-weight: 700; }
    .order-sheet .sheet-last-five { font-variant-numeric: tabular-nums; }
    /* 總表頁首「新增暫存訂單」：預設收合，展開時由上往下滑開；展開完成後才解除裁切，讓底部按鈕列可以 sticky。 */
    .sheet-new-draft { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows .32s ease, visibility 0s linear .32s; }
    .sheet-new-draft.is-open { grid-template-rows: 1fr; visibility: visible; transition: grid-template-rows .32s ease; }
    .sheet-new-draft-inner { min-height: 0; overflow: hidden; }
    .sheet-new-draft.is-open.is-settled .sheet-new-draft-inner { overflow: visible; }
    .sheet-new-draft.is-open .sheet-new-draft-inner { padding-bottom: 24px; }
    .sheet-new-draft-heading h2 { margin: 0 0 4px; }
    .sheet-new-draft-heading { margin-bottom: 16px; }
    /* Batch button bar (#248)；各列勾選框在獨立的「選取」欄（#258）。 */
    .sheet-batch { align-items: center; }
    .sheet-batch-count { margin-right: auto; color: var(--muted); }
    /* #315：訂單總表按鈕分兩組，左側調度（產生類、取消），右側會計（審核、刪除）；窄螢幕時各組在自己範圍內換行，右組換到下一行時仍靠右。 */
    .sheet-batch-group { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-width: 0; }
    #sheet-batch .sheet-batch-count { margin-right: 0; }
    .sheet-batch-accounting { margin-left: auto; justify-content: flex-end; }
    .sheet-batch-count strong { color: var(--ink); font-variant-numeric: tabular-nums; }
    .sheet-batch-result p { margin: 0; }
    .sheet-batch-result ul { margin: 8px 0 0; padding-left: 20px; }
    /* 未勾選時按鈕列的按鈕已停用（admin.js），外觀要看得出來，滑過也不變色。 */
    .sheet-batch button:disabled { opacity: .45; cursor: not-allowed; }
    .sheet-batch .primary-button:disabled { background: var(--blue); }
    .sheet-batch .secondary-button:disabled { background: white; border-color: var(--border); }
    .sheet-batch .danger-button:disabled { background: var(--danger); }
    /* 車行訂單批次指派司機：標籤與下拉選單同一行，窄螢幕時下拉選單佔滿剩餘寬度。 */
    .vendor-current-driver .sheet-muted { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
    .vendor-driver-batch-field { display: flex; align-items: center; gap: 8px; flex: 0 1 420px; min-width: 0; }
    .vendor-driver-batch-field label { margin: 0; white-space: nowrap; font-weight: 600; }
    .vendor-driver-batch-field select { flex: 1 1 auto; min-width: 0; width: auto; }
    .order-sheet .sheet-select { display: inline-flex; align-items: center; gap: 4px; margin: 0; cursor: pointer; }
    .order-sheet input.sheet-select, .order-sheet .sheet-select input { width: 18px; height: 18px; margin: 0 4px 0 0; cursor: pointer; }
    /* #258：點順序編號複製「業務-日期-航班-流水號」，編號右側短暫顯示結果標籤。
       固定欄各自形成堆疊層，標籤會被右側同層級的「選取」／「來源」格蓋住，所以顯示期間把編號格提高一層。 */
    .order-sheet tbody td.sheet-no:has(> .sheet-copy-number[data-copied]) { z-index: 2; }
    .order-sheet .sheet-copy-number { position: relative; padding: 0; font: inherit; font-weight: inherit; color: inherit; background: none; border: 0; text-decoration: underline dotted; text-underline-offset: 3px; cursor: copy; }
    .order-sheet .sheet-copy-number:hover { color: var(--blue); }
    .order-sheet .sheet-copy-number:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
    .order-sheet .sheet-copy-number[data-copied]::after { content: attr(data-copied); position: absolute; top: 50%; left: calc(100% + 6px); z-index: 5; transform: translateY(-50%); padding: 2px 6px; color: #fff; background: var(--ink); border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }
    /* #561：單擊司機欄複製派車通知；結果標籤疊在格子中央，不會被相鄰欄位或捲動區域裁切。
       加上 tbody 提高權重，窄螢幕空白格的「—」（#559）不會蓋掉結果標籤。 */
    .order-sheet td[data-sheet-notice] { position: relative; cursor: copy; }
    .order-sheet tbody td[data-sheet-notice][data-copied]::after { content: attr(data-copied); position: absolute; top: 50%; left: 50%; z-index: 5; transform: translate(-50%, -50%); padding: 2px 6px; color: #fff; background: var(--ink); border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }
    .order-sheet .sheet-header-button { padding: 0; font: inherit; font-weight: inherit; color: inherit; background: none; border: 0; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
    .order-sheet .sheet-header-button:hover { color: var(--blue); }
    .order-sheet .sheet-header-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
    .sheet-address-summary-button { display: none; }
    dialog.sheet-address-summary h2 { margin: 0 0 4px; font-size: 18px; }
    dialog.sheet-address-summary p { margin: 0 0 12px; }
    dialog.sheet-address-summary p:empty { display: none; }
    dialog.sheet-address-summary textarea { width: 100%; min-height: 160px; margin-bottom: 16px; font-variant-numeric: tabular-nums; resize: vertical; }
    /* #567 產生多台的集合時間對話框。 */
    dialog.sheet-multi-vehicle-dialog h2 { margin: 0 0 4px; font-size: 18px; }
    dialog.sheet-multi-vehicle-dialog > p { margin: 0 0 16px; }
    /* #275 產生請款單的設定對話框：備註版本單選與是否顯示印章。 */
    dialog.sheet-receivable-statement h2 { margin: 0 0 4px; font-size: 18px; }
    dialog.sheet-receivable-statement p { margin: 0 0 16px; }
    dialog.sheet-receivable-statement fieldset { margin: 0 0 12px; }
    dialog.sheet-receivable-statement legend { margin-bottom: 8px; font-weight: 600; }
    dialog.sheet-receivable-statement label { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; cursor: pointer; }
    dialog.sheet-receivable-statement .sheet-receivable-stamp { margin-bottom: 20px; }
    /* #547 直客請款對象：文字欄位標籤在上、欄位全寬。 */
    dialog.sheet-receivable-statement .sheet-receivable-direct p { margin-bottom: 8px; }
    dialog.sheet-receivable-statement .sheet-receivable-field { flex-direction: column; align-items: stretch; gap: 4px; cursor: default; }
    dialog.sheet-receivable-statement .sheet-receivable-direct-panel input[type="search"],
    dialog.sheet-receivable-statement .sheet-receivable-direct-panel input[type="text"],
    dialog.sheet-receivable-statement .sheet-receivable-direct-panel input[type="tel"] { width: 100%; }
    /* #477 批次操作與改派的確認／提示視窗：訊息保留換行；notice 模式隱藏取消鈕。 */
    dialog.sheet-confirm-dialog h2 { margin: 0 0 12px; font-size: 18px; }
    dialog.sheet-confirm-dialog p { margin: 0 0 20px; white-space: pre-line; }
    /* The field dialog reuses the order form's rows (stops, seats), so it is wider than the confirm dialogs. */
    dialog.sheet-field-dialog { width: min(760px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto; }
    /* 聯絡人與地址、地點視窗的站點列一列放地址、人數、大名、電話與排序鈕，760px 會截斷電話，因此加寬（2026-11-15）。 */
    dialog.sheet-field-dialog:has(.stop-row) { width: min(1120px, calc(100% - 32px)); }
    dialog.sheet-field-dialog h2 { margin: 0 0 4px; font-size: 18px; }
    dialog.sheet-field-dialog .sheet-field-heading { margin: 0 0 16px; }
    dialog.sheet-field-dialog .field { margin-bottom: 16px; }
    /* 站點、兒童座椅列以底部對齊刪除鈕與序號；列內欄位不留下邊距，否則按鈕會比輸入框低。 */
    dialog.sheet-field-dialog :is(.stop-row, .child-seat-row) .field { margin: 0; }
    dialog.sheet-field-dialog .subsection { margin: 0 0 16px; padding: 0; border: 0; }
    dialog.sheet-field-dialog .sheet-field-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
    dialog.sheet-field-dialog .form-actions { margin-top: 8px; }
    /* #318 修改紀錄：summary 外觀同次要按鈕，展開後為新到舊的表格；多行內容（地址、座椅）保留換行。 */
    dialog.sheet-field-dialog .sheet-field-history-toggle { margin-top: 12px; }
    dialog.sheet-field-dialog .sheet-field-history-toggle > summary { list-style: none; cursor: pointer; }
    dialog.sheet-field-dialog .sheet-field-history-toggle > summary::-webkit-details-marker { display: none; }
    dialog.sheet-field-dialog [data-sheet-field-history-panel] { margin-top: 12px; }
    dialog.sheet-field-dialog .sheet-field-history-table { min-width: 0; table-layout: auto; font-size: 13px; }
    dialog.sheet-field-dialog .sheet-field-history-table :is(th, td) { width: auto; padding: 8px; font-weight: 400; }
    dialog.sheet-field-dialog .sheet-field-history-table .sheet-nowrap { white-space: nowrap; }
    dialog.sheet-field-dialog .sheet-field-history-value { white-space: pre-line; }
    /* Trips cancelled from the sheet stay listed on a grey background until deleted; the tag keeps it readable without colour. */
    .order-sheet tbody tr.sheet-cancelled td { background: #d9d9d9 !important; color: #5f6368 !important; }
    .order-sheet .sheet-cancelled-tag { display: block; margin-top: 2px; color: #3c4043; font-size: 11px; font-weight: 700; white-space: nowrap; }
    /* #334 代轉：售價紅色＋「代轉」文字（紅色不是唯一辨識方式）；訂單表單與總表金額視窗勾選時客戶售價與總價同為紅色。 */
    .order-sheet td.sheet-billing-document { color: var(--danger); font-weight: 700; }
    .order-sheet .sheet-billing-document-tag { display: block; margin-top: 2px; font-size: 11px; font-weight: 700; white-space: nowrap; }
    :is([data-order-trip], [data-sheet-field-form]):has([data-billing-document]:checked) :is(input[data-customer-price], [data-trip-total]) { color: var(--danger); font-weight: 700; }
    .order-sheet .sheet-change-tag { display: block; margin-top: 2px; color: var(--danger); font-size: 11px; font-weight: 700; white-space: nowrap; }
    .order-sheet .sheet-mark { white-space: nowrap; }
    .order-sheet .sheet-mark form { margin: 0; }
    /* 日期之間以純黑橫條分隔（不再畫白色虛線），車行訂單沿用此規則；列印保留底色。 */
    .order-sheet tbody tr.sheet-day-divider td { height: 14px; padding: 0; background: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    /* #407 訂單總表（總表、暫存、歷史頁籤）與派車總表的分隔列（sheet-day-band）為黑底，以白色粗體顯示當日各車行趟數（#344）；
       文字黏在表格左側，橫向捲動時仍看得到；列印時保留底色。歷史頁籤原本 #343 的淺色分隔列已改為與總表相同。 */
    .order-sheet tbody tr.sheet-day-band td { background: #000; border-top: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .order-sheet tbody tr.sheet-day-band td.sheet-day-counts { height: auto; padding: 2px 8px; color: #fff; font-size: 12px; font-weight: 700; line-height: 1.4; text-align: left; white-space: nowrap; font-variant-numeric: tabular-nums; }
    .order-sheet tr.sheet-day-band .sheet-day-counts-text { position: sticky; left: 8px; display: inline-block; }
    /* #265 訂車單預覽：獨立視窗，A4 紙面捲動時上方操作列保持可見。 */
    &.customer-document-page { min-height: 100vh; }
    .customer-document-bar { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 1px 2px rgb(16 24 40 / 6%); }
    .customer-document-bar h1 { margin: 0; font-size: 20px; }
    .customer-document-bar p { margin: 0; color: var(--muted); }
    .customer-document-main { padding: 16px 24px 32px; }
    .customer-document-main > .notice { margin: 0 0 16px; }
    .customer-document-main .notice[hidden], .customer-document-status:empty { display: none; }
    .customer-document-status { margin: 0 0 16px; color: var(--success); font-weight: 600; }
    .customer-document-unavailable { max-width: 720px; margin: 48px auto; padding: 0 16px; }
    .customer-document-unavailable ul { margin: 12px 0 24px; padding-left: 20px; }
    /* The order overview mirrors the dispatchers' Excel sheet: black header, colour-banded columns and red drop-off rows. */
    @media screen and (min-width: 1280px) {
        .sheet-wrap:has(> .excel-sheet) { border-radius: 0; }
        .excel-sheet { --xl-cream: #fff2cc; --xl-pink: #f4cccc; --xl-sky: #cfe2f3; --xl-green: #93c47d; color: #000; }
        /* Separate borders drawn per cell: collapsed borders stay behind when the header sticks, leaving a gap above it. */
        .excel-sheet { border-collapse: separate; border-spacing: 0; }
        .excel-sheet th, .excel-sheet td, .excel-sheet tbody tr:last-child td { border: 0; border-right: 1px solid #5f6368; border-bottom: 1px solid #5f6368; }
        .excel-sheet th:first-child, .excel-sheet td:first-child, .excel-sheet tbody tr:last-child td:first-child { border-left: 1px solid #5f6368; }
        .excel-sheet thead th { border-top: 1px solid #000; }
        .excel-sheet thead th { background: #000; color: #fff; font-size: 14px; font-weight: 700; }
        .excel-sheet tbody td { font-weight: 600; }
        .excel-sheet tbody td.sheet-no, .excel-sheet tbody td.sheet-pick { background: #efefef; }
        .excel-sheet tbody td.sheet-source, .excel-sheet td.sheet-sales, .excel-sheet td.sheet-date, .excel-sheet td.sheet-time,
        .excel-sheet td.sheet-direction, .excel-sheet td.sheet-flight { background: var(--xl-cream); }
        .excel-sheet tbody td.sheet-source { font-weight: 700; }
        .excel-sheet td.sheet-location, .excel-sheet td.sheet-amount, .excel-sheet tbody td:last-child { background: var(--xl-sky); }
        .excel-sheet td.sheet-contact, .excel-sheet td.sheet-counts { background: var(--xl-pink); }
        .excel-sheet td.sheet-vehicle, .excel-sheet td.sheet-address, .excel-sheet td.sheet-notes,
        .excel-sheet td.sheet-sign, .excel-sheet td.sheet-seats { background: var(--xl-green); }
        .excel-sheet td.sheet-address { text-align: center; font-weight: 700; }
        .excel-sheet td.sheet-notes { text-align: center; color: #1c3fd1; }
        .excel-sheet td.sheet-seats { color: #e00; font-weight: 700; }
        .excel-sheet:not(.overview-sheet) tr:has(> td[data-direction="DropOff"]) td.sheet-time, .excel-sheet:not(.overview-sheet) tr:has(> td[data-direction="DropOff"]) td.sheet-direction, .excel-sheet:not(.overview-sheet) tr:has(> td[data-direction="DropOff"]) td.sheet-flight { color: #e00; font-weight: 700; }
        .excel-sheet td.sheet-flight .sheet-muted { color: inherit; }
        /* Vendor colours come from each vendor's settings (#311) as --vendor-bg/--vendor-fg; vendors without colours stay grey. */
        .excel-sheet td.sheet-vendor { background: var(--vendor-bg, #b7b7b7); color: var(--vendor-fg, #000); font-weight: 700; }
        .excel-sheet tbody tr:hover td { filter: brightness(.94); }
        /* 滑過的列其他格子改為淺灰（.order-sheet tbody tr:hover td），車行格子保留車行底色，白字的車行代碼才不會看不見。 */
        .excel-sheet tbody tr:hover td.sheet-vendor { background: var(--vendor-bg, #b7b7b7); }
        /* Dispatch-only columns: blue-grey tick boxes and the orange driver block, pending or not. */
        .excel-sheet.dispatch-sheet thead th { font-size: 13px; }
        .excel-sheet td.sheet-mark { background: #c9daf8; }
        .excel-sheet td.sheet-driver, .excel-sheet td.sheet-pending { background: #ff9900; color: #000; }
        .excel-sheet .mark-toggle { width: 22px; height: 22px; border: 2px solid #000; border-radius: 3px; background: #fff; color: #fff; font-size: 14px; }
        .excel-sheet .mark-toggle[aria-pressed="true"] { background: #000; border-color: #000; }
    }
    /* #557 訂單總表（總表、暫存、歷史頁籤）的每日統計列：當日最後一列顯示「共 N 趟：各車行趟數」，文字置中；
       左右都黏在畫面內，表格比畫面寬時橫向捲動仍看得到。 */
    .overview-sheet tbody tr.sheet-day-total td { padding: 4px 8px; background: #efefef; color: #000; font-weight: 700; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
    .overview-sheet tr.sheet-day-total .sheet-day-total-text { position: sticky; left: 8px; right: 8px; display: inline-block; }
    /* 總表、暫存、歷史頁籤的統計列兼作隔日線（sheet-day-band）：同一列黑底白字，取代原本淺灰統計列＋分隔列兩列；列印保留底色。 */
    .overview-sheet tbody tr.sheet-day-total.sheet-day-band td { background: #000; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    /* #557 桌面版（1280px 以上）：來源～機場固定欄寬、內容換行不截斷；# 到機場水平捲動時凍結，位移由欄寬累加；所有欄位置中。 */
    @media screen and (min-width: 1280px) {
        .overview-sheet {
            --sheet-w-no: 41px; --sheet-w-pick: 0px; --sheet-w-source: 55px; --sheet-w-sales: 33px; --sheet-w-vendor: 33px;
            --sheet-w-date: 65px; --sheet-w-time: 39px; --sheet-w-direction: 44px; --sheet-w-flight: 76px; --sheet-w-location: 67px;
            --sheet-l-source: calc(var(--sheet-w-no) + var(--sheet-w-pick));
            --sheet-l-sales: calc(var(--sheet-l-source) + var(--sheet-w-source));
            --sheet-l-vendor: calc(var(--sheet-l-sales) + var(--sheet-w-sales));
            --sheet-l-date: calc(var(--sheet-l-vendor) + var(--sheet-w-vendor));
            --sheet-l-time: calc(var(--sheet-l-date) + var(--sheet-w-date));
            --sheet-l-direction: calc(var(--sheet-l-time) + var(--sheet-w-time));
            --sheet-l-flight: calc(var(--sheet-l-direction) + var(--sheet-w-direction));
            --sheet-l-location: calc(var(--sheet-l-flight) + var(--sheet-w-flight));
        }
        .overview-sheet.sheet-has-pick { --sheet-w-pick: 40px; }
        .overview-sheet :is(.sheet-source, .sheet-sales, .sheet-vendor, .sheet-date, .sheet-time, .sheet-direction, .sheet-flight, .sheet-location) { position: sticky; }
        .overview-sheet tbody td:is(.sheet-source, .sheet-sales, .sheet-vendor, .sheet-date, .sheet-time, .sheet-direction, .sheet-flight, .sheet-location) { z-index: 1; white-space: normal; overflow-wrap: anywhere; }
        .overview-sheet thead th:is(.sheet-source, .sheet-sales, .sheet-vendor, .sheet-date, .sheet-time, .sheet-direction, .sheet-flight, .sheet-location) { z-index: 3; }
        .overview-sheet .sheet-no { left: 0; width: var(--sheet-w-no); min-width: var(--sheet-w-no); max-width: var(--sheet-w-no); }
        .overview-sheet .sheet-pick { left: var(--sheet-w-no); }
        .overview-sheet .sheet-source { left: var(--sheet-l-source); width: var(--sheet-w-source); min-width: var(--sheet-w-source); max-width: var(--sheet-w-source); }
        .overview-sheet .sheet-sales { left: var(--sheet-l-sales); width: var(--sheet-w-sales); min-width: var(--sheet-w-sales); max-width: var(--sheet-w-sales); }
        .overview-sheet .sheet-vendor { left: var(--sheet-l-vendor); width: var(--sheet-w-vendor); min-width: var(--sheet-w-vendor); max-width: var(--sheet-w-vendor); }
        .overview-sheet .sheet-date { left: var(--sheet-l-date); width: var(--sheet-w-date); min-width: var(--sheet-w-date); max-width: var(--sheet-w-date); }
        .overview-sheet .sheet-time { left: var(--sheet-l-time); width: var(--sheet-w-time); min-width: var(--sheet-w-time); max-width: var(--sheet-w-time); }
        .overview-sheet .sheet-direction { left: var(--sheet-l-direction); width: var(--sheet-w-direction); min-width: var(--sheet-w-direction); max-width: var(--sheet-w-direction); }
        .overview-sheet .sheet-flight { left: var(--sheet-l-flight); width: var(--sheet-w-flight); min-width: var(--sheet-w-flight); max-width: var(--sheet-w-flight); }
        .overview-sheet .sheet-location { left: var(--sheet-l-location); width: var(--sheet-w-location); min-width: var(--sheet-w-location); max-width: var(--sheet-w-location); }
        /* 聯絡人～兒童座椅依 2026 年 10 月的排版固定欄寬，不再隨當月資料（較長的聯絡人、已派司機）互相擠壓；
           聯絡人欄比 10 月的 130px 稍寬，讓「N.三字姓名 手機」一行放得下，不在電話號碼中間斷行；更長時才在格內換行。
           地點欄 220px，約九成的地址一行放得下。「車行專用人/托/登」表頭分兩行。司機以後的欄位仍依內容調整。 */
        .overview-sheet td.sheet-contact { width: 136px; min-width: 136px; max-width: 136px; white-space: normal; }
        .overview-sheet td.sheet-counts { width: 58px; min-width: 58px; max-width: 58px; }
        .overview-sheet td.sheet-vendor-counts { width: 64px; min-width: 64px; max-width: 64px; }
        .overview-sheet td.sheet-vehicle { width: 32px; min-width: 32px; max-width: 32px; }
        .overview-sheet td.sheet-address { width: 220px; min-width: 220px; max-width: 220px; }
        .overview-sheet td.sheet-notes { width: 110px; min-width: 110px; max-width: 110px; }
        .overview-sheet td.sheet-sign { width: 90px; min-width: 90px; max-width: 90px; }
        .overview-sheet td.sheet-seats { width: 58px; min-width: 58px; max-width: 58px; }
        /* 車行欄的下拉選單外觀同格子文字：蓋滿整個格子（凍結欄的格子是 sticky，可作為定位基準），點格子任何位置都會展開選項；
           置中、不畫框線與箭頭，滑過或以鍵盤聚焦時以外框提示。 */
        .overview-sheet .sheet-vendor-select { position: absolute; inset: 0; width: 100%; height: 100%; min-width: 0; padding: 0; border: 0; border-radius: 0; appearance: none; text-align: center; text-align-last: center; }
        .overview-sheet .sheet-vendor-select:focus { box-shadow: none; }
        .overview-sheet .sheet-vendor-select:is(:hover, :focus-visible) { outline: 1px solid currentColor; outline-offset: -1px; }
        .overview-sheet td, .overview-sheet td:is(.sheet-address, .sheet-notes, .sheet-amount) { text-align: center; }
        .overview-sheet .sheet-sign-text { margin-inline: auto; text-align: center; }
        /* 像 Excel 的工作表：有訂單總表（含暫存、歷史）時由 main 區域上下左右捲動，上方導覽列與左側選單不動、整頁不再橫向捲動；
           月份頁籤由版面的 AfterMain 區段放在 main 之後，橫向卷軸就在頁籤正上方。凍結的表頭與欄位停在捲動區域的
           內距邊界，所以 main 不留上左右內距，改由各區塊的外距留白，凍結時才會貼齊捲動區域邊緣。
           表格外框不留左外距與左框線、直接貼齊左側選單，橫向捲動時 # 欄一開始就在凍結位置，不會先移動才凍結。 */
        .main-area:has(> main .overview-sheet) { height: 100vh; display: flex; flex-direction: column; }
        .main-area:has(> main .overview-sheet) > :is(.topbar, .sheet-month-tabs) { flex: none; }
        .main-area:has(> main .overview-sheet) > main { flex: 1 1 auto; min-height: 0; width: 100%; margin: 0; padding: 0 0 24px; overflow: auto; }
        .main-area:has(> main .overview-sheet) > main > :not(dialog) { margin-inline: 24px; }
        .main-area:has(> main .overview-sheet) > main > :first-child { margin-top: 24px; }
        .main-area:has(> main .overview-sheet) > main > .sheet-wrap { margin-left: 0; border-left: 0; }
    }
    /* #557 手機卡片版面：統計列為一條淺灰列，排列同其他卡片之間的分隔列。 */
    @media screen and (max-width: 1279px) {
        .overview-sheet tr.sheet-day-total { display: block; margin-bottom: 12px; padding: 6px 12px; background: #efefef; border: 1px solid var(--border); border-radius: 10px; box-shadow: none; }
        .overview-sheet tbody tr.sheet-day-total td { display: block; padding: 0; text-align: left; white-space: normal; background: transparent; }
        .overview-sheet tr.sheet-day-total td::before { display: none; }
        .overview-sheet tr.sheet-day-total .sheet-day-total-text { position: static; }
        .overview-sheet tr.sheet-day-total.sheet-day-band { border: 0; border-radius: 0; background: #000; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    }
    .mark-toggle { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--blue); font-size: 18px; font-weight: 700; line-height: 1; cursor: pointer; }
    .mark-toggle:hover { border-color: var(--blue); }
    .mark-toggle[aria-pressed="true"] { background: #eff6ff; border-color: var(--blue); }
    .mark-readonly { color: var(--muted); font-weight: 700; }
    .order-groups { display: grid; gap: 16px; }
    .order-group { overflow: clip; }
    .order-group > summary { min-height: 64px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; list-style-position: inside; }
    .order-group > summary:hover { background: #f8fafc; }
    .status-chip-formal { color: var(--success); background: var(--success-bg); }
    .order-group-meta { color: var(--muted); font-size: 13px; }
    .order-group-body { border-top: 1px solid var(--border); padding: 20px; }
    .order-group-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 16px; color: var(--muted); }
    .order-group-summary strong { color: var(--ink); margin-left: auto; }
    .trip-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
    .trip-card { min-width: 0; border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: white; }
    .trip-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
    .trip-card h2 { font-size: 16px; margin: 2px 0 0; overflow-wrap: anywhere; }
    .trip-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin-bottom: 16px; }
    .trip-facts span { min-width: 0; overflow-wrap: anywhere; }
    .trip-facts b { display: block; color: var(--muted); font-size: 12px; }
    .status-stack .badge:not(.badge-primary):not(.badge-inactive) { color: var(--muted); background: #f1f5f9; }
    .order-history { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
    .order-history li { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
    .order-history li:last-child { border-bottom: 0; padding-bottom: 0; }
    .order-history span { color: var(--muted); }
    /* Order details: summary strip over trips (main) and order facts / actions / history (aside). */
    .order-detail .order-detail-title { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
    .order-detail .order-detail-title h1 { margin: 0; }
    .order-detail .order-detail-title .badge { font-size: 13px; padding: 4px 10px; }
    .order-detail .badge-danger { color: var(--danger); background: var(--danger-bg); }
    .order-detail .order-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; padding: 0; }
    .order-detail .order-summary > div { display: grid; gap: 2px; min-width: 0; padding: 16px 20px; border-left: 1px solid var(--border); }
    .order-detail .order-summary > div:first-child { border-left: 0; }
    .order-detail .order-summary span, .order-detail .order-summary small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
    .order-detail .order-summary span { font-weight: 700; }
    .order-detail .order-summary strong { font-size: 18px; overflow-wrap: anywhere; }
    .order-detail .order-detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 20px; align-items: start; }
    .order-detail .order-detail-main { display: grid; gap: 16px; min-width: 0; }
    .order-detail .order-detail-main > .section-heading { margin-bottom: 0; }
    .order-detail .trip-card { padding: 20px; display: grid; gap: 16px; border-radius: var(--radius); }
    .order-detail .trip-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 0; }
    .order-detail .trip-card-head h2 { font-size: 17px; margin: 2px 0 0; overflow-wrap: anywhere; }
    .order-detail .trip-direction { font-size: 13px; padding: 4px 12px; }
    .order-detail .trip-direction.is-dropoff { color: var(--danger); background: var(--danger-bg); }
    .order-detail .trip-direction.is-pickup { color: var(--success); background: var(--success-bg); }
    .order-detail .trip-when { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; padding: 12px 16px; border-radius: 10px; background: var(--blue-soft); }
    .order-detail .trip-when strong { font-size: 16px; }
    .order-detail .trip-time { font-size: 22px; font-weight: 700; color: var(--blue-dark); font-variant-numeric: tabular-nums; }
    .order-detail .trip-flight { color: var(--ink); font-weight: 600; }
    .order-detail .trip-sections { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; }
    .order-detail .trip-sections h3 { margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); color: var(--ink); font-size: 13px; font-weight: 700; }
    .order-detail .trip-notes h3 { margin: 0 0 6px; color: var(--warning); font-size: 13px; font-weight: 700; }
    .order-detail .trip-dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin: 0; }
    .order-detail .trip-dl .trip-dl-wide { grid-column: 1 / -1; }
    .order-detail .trip-dl dt { color: var(--muted); font-size: 12px; }
    .order-detail .trip-dl dd { margin: 0; overflow-wrap: anywhere; }
    .order-detail .trip-muted { color: var(--muted); font-size: 13px; }
    .order-detail .trip-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
    .order-detail .trip-chip { display: inline-block; margin: 2px 0 0 6px; padding: 1px 8px; border-radius: 999px; background: #f1f5f9; font-size: 12px; }
    .order-detail .trip-chip:first-child { margin-left: 0; }
    .order-detail .trip-sign-text { display: block; margin-top: 4px; overflow-wrap: anywhere; font-weight: 600; }
    .order-detail .trip-addresses { margin: 0; padding-left: 20px; }
    .order-detail .trip-stop-contact, .order-detail .trip-baggage-notes { display: block; }
    .order-detail .trip-notes { padding: 12px 16px; border-radius: 10px; background: var(--warning-bg); }
    .order-detail .trip-notes p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
    .order-detail .payment-facts { margin: 0; padding-top: 16px; border-top: 1px solid var(--border); }
    .order-detail .trip-card-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
    .order-detail .trip-log .hint { margin: 0; }
    .order-detail .trip-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
    .order-detail .trip-actions form { margin: 0; }
    .order-detail .trip-actions a, .order-detail .trip-actions button { min-height: 38px; padding: 6px 14px; }
    .order-detail .order-detail-aside { display: grid; gap: 16px; min-width: 0; }
    .order-detail .aside-card { padding: 18px 20px; }
    .order-detail .aside-card h2 { font-size: 16px; margin: 0 0 12px; }
    .order-detail .aside-facts { display: grid; gap: 8px; margin: 0; }
    .order-detail .aside-facts div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; }
    .order-detail .aside-facts dt { color: var(--muted); font-size: 13px; }
    .order-detail .aside-facts dd { margin: 0; overflow-wrap: anywhere; }
    .order-detail .aside-form { display: grid; gap: 10px; margin: 0; }
    .order-detail .aside-form + .aside-form { margin-top: 16px; }
    .order-detail .aside-form .field { margin: 0; }
    .order-detail .aside-form textarea { width: 100%; }
    .order-detail .aside-form button { width: 100%; }
    .order-detail .danger-zone { padding: 12px; border: 1px solid #fecaca; border-radius: 10px; background: var(--danger-bg); }
    .order-detail .order-timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: grid; gap: 12px; }
    .order-detail .order-timeline li { position: relative; display: grid; gap: 2px; }
    .order-detail .order-timeline li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--blue); }
    .order-detail .order-timeline strong { font-size: 14px; }
    .order-detail .order-timeline span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
    @media (max-width: 1100px) {
        .order-detail .order-detail-layout { grid-template-columns: 1fr; }
        .order-detail .trip-sections { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (max-width: 800px) {
        .order-detail .order-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .order-detail .order-summary > div:nth-child(3) { border-left: 0; }
        .order-detail .order-summary > div:nth-child(n + 3) { border-top: 1px solid var(--border); }
        .order-detail .trip-sections { grid-template-columns: 1fr; }
        .order-detail .trip-actions { width: 100%; margin-left: 0; }
        .order-detail .trip-actions > *, .order-detail .trip-actions button { flex: 1 1 auto; }
    }
    .assignment-summary { margin-bottom: 24px; }
    .vendor-order-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); gap: 16px; align-items: start; }
    .cost-value { color: var(--success); font-size: 18px; font-weight: 700; }
    .address-history { margin: 0 0 20px; padding-left: 24px; }
    .item-summary { display: flex; flex-wrap: wrap; gap: 8px; }
    .item-summary span { padding: 5px 9px; border-radius: 999px; color: var(--muted); background: #f1f5f9; }
    .settlement-month-form { align-items: flex-end; }
    .settlement-table .amount, .settlement-table th.amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
    /* 月結單逐趟明細為固定欄寬：「方向」只有兩字，多留給「收款者」，避免「NT$ 1,500」被折到兩行。 */
    .settlement-lines-table th:nth-child(3) { width: 80px; }
    .settlement-lines-table th:nth-child(5) { width: 260px; }
    /* 車單管理：6 欄依內容分配寬度（第 6 欄為操作與勾選）。 */
    .vendor-order-release-table th:nth-child(1) { width: 8%; }
    .vendor-order-release-table th:nth-child(2) { width: 14%; }
    .vendor-order-release-table th:nth-child(3), .vendor-order-release-table th:nth-child(4) { width: 12%; }
    .vendor-order-release-table th:nth-child(5) { width: 14%; }
    .vendor-order-release-table th:nth-child(6) { width: 40%; }
    /* 帳號管理同為 6 欄：第 6 欄（操作：編輯、啟停用、角色、所屬車行）最寬。 */
    .user-table th:nth-child(1) { width: 18%; }
    .user-table th:nth-child(2) { width: 16%; }
    .user-table th:nth-child(3), .user-table th:nth-child(4) { width: 10%; }
    .user-table th:nth-child(5) { width: 18%; }
    .user-table th:nth-child(6) { width: 28%; }
    .vendor-order-release-table td { vertical-align: middle; }
    .vendor-order-release-table .amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
    /* 空白的未勾選按鈕會對齊文字基線而多出行高；以 flex 排版讓勾選前後列高一致。 */
    .vendor-order-release-table .sheet-mark form { margin: 0; display: flex; align-items: center; }
    .net-positive { color: var(--success); font-weight: 700; }
    .net-negative { color: var(--danger); font-weight: 700; }
    .net-zero { color: var(--muted); font-weight: 700; }
    .settlement-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; margin: 0; }
    .settlement-totals > div { display: grid; gap: 4px; padding: 12px 16px; border-radius: 10px; background: #eff6ff; }
    .settlement-totals strong, .settlement-totals dd { margin: 0; font-size: 22px; font-variant-numeric: tabular-nums; }
    .settlement-totals.compact strong, .settlement-totals.compact dd { font-size: 18px; }
    .settlement-totals > p { grid-column: 1 / -1; margin: 0; }
    .settlement-account-choice { margin-top: 20px; display: grid; gap: 8px; }
    .settlement-account-choice h3 { font-size: 16px; }
    .settlement-account-choice .field { max-width: 720px; }
    .settlement-export-actions { display: flex; flex-wrap: wrap; gap: 8px; }
    .settlement-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 16px 0 0; border-bottom: 2px solid var(--border); }
    .settlement-tab { padding: 10px 18px; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; color: inherit; font-weight: 600; text-decoration: none; margin-bottom: -2px; }
    .settlement-tab[aria-current="page"] { border-color: var(--border); border-bottom: 2px solid var(--surface, #fff); background: var(--surface, #fff); color: #1d4ed8; }
    .settlement-tab:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
    .settlement-vendor-form { align-items: flex-end; margin-bottom: 16px; }
    .settlement-vendor-form .field { flex: 0 1 360px; }
    .settlement-vendor-detail { display: grid; gap: 8px; margin-bottom: 20px; }
    .settlement-vendor-detail h3, .settlement-subheading { font-size: 16px; margin: 4px 0; }
    .reconciliation-table { table-layout: auto; }
    .reconciliation-table th, .reconciliation-table td { text-align: center; vertical-align: middle; font-weight: 600; border: 1px solid #000; }
    .reconciliation-table thead th { background: #000; color: #fff; }
    .reconciliation-table .reconciliation-schedule { background: #fff2cc; white-space: nowrap; }
    .reconciliation-table .reconciliation-contact { background: #f8d7d3; white-space: nowrap; }
    .reconciliation-table .reconciliation-contact span { display: block; }
    .reconciliation-table .amount, .reconciliation-table th.amount { text-align: center; }
    .reconciliation-table .reconciliation-amount { background: #ddebf7; }
    .reconciliation-table .reconciliation-early { color: #e00000; }
    .reconciliation-table tfoot th, .reconciliation-table tfoot td { background: #e2e8f0; }
    .settlement-counterparties { display: grid; gap: 16px; }
    .settlement-counterparty { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; }
    .settlement-counterparty header h3 { font-size: 18px; margin: 2px 0; }
    .settlement-counterparty .field { margin: 0; max-width: 720px; }

    @media (max-width: 800px) {
        .settlement-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .settlement-month-form { flex-direction: column; align-items: stretch; }
        .settlement-month-form .field { flex-basis: auto; }
        .settlement-month-form .primary-button, .settlement-month-form .secondary-button { width: 100%; }
        .settlement-vendor-form { flex-direction: column; align-items: stretch; }
        .settlement-vendor-form .field { flex-basis: auto; }
        .settlement-tab { flex: 1 1 0; text-align: center; padding: 10px 8px; }
        .app-shell { display: block; }
        .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; height: auto; width: min(280px, calc(100% - 32px)); transform: translateX(-100%); transition: transform .2s ease; }
        &.nav-open { overflow: hidden; }
        &.nav-open .sidebar { transform: translateX(0); }
        &.nav-collapsed .sidebar { display: flex; }
        &.nav-open .drawer-backdrop { display: block; position: fixed; z-index: 10; inset: 0; background: rgb(15 23 42 / 45%); }
        .menu-toggle { display: block; }
        .sidebar .collapse-toggle { display: none; }
        .topbar { gap: 8px; padding: 12px 16px; }
        .account-bar { gap: 8px; }
        .account-name { max-width: 110px; }
        main { padding: 24px 16px; }
        .page-heading { flex-direction: column; gap: 16px; }
        .page-heading .primary-button { width: 100%; }
        .page-heading .form-actions, .page-heading .form-actions form, .page-heading .form-actions .secondary-button { width: 100%; }
        .section-heading { flex-direction: column; }
        .section-heading .primary-button { width: 100%; }
        .table-scroll-hint { display: block; margin-bottom: 8px; }
        .login-panel { padding: 24px; }
        h1 { font-size: 26px; }
        .customer-form-grid, .details-grid { grid-template-columns: 1fr; }
        .payment-facts div { grid-template-columns: 1fr; gap: 2px; }
        .field-grid.two-columns, .field-grid.three-columns, .field-grid.field-row, .field-grid.field-row-two, .field-grid.field-row-four { grid-template-columns: 1fr; }
        .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .field-grid > .choice-row { margin: 0 0 24px; }
        .extra-service-grid, .field-grid.price-grid { grid-template-columns: 1fr; }
        .trip-block { padding: 16px 12px 0; }
        .order-draft-form > .form-actions { position: static; padding: 0; background: transparent; border: 0; box-shadow: none; }
        .order-section > .section-heading { align-items: flex-start; }
        .child-seat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .child-seat-row > .field:first-child { grid-column: 1 / -1; }
        .stop-row { grid-template-columns: 32px minmax(0, 1fr); }
        .stop-row > .field, .stop-row > button, .stop-row > .stop-actions { grid-column: 2; }
        .item-grid .baggage-notes { grid-column: 1 / -1; }
        .order-delete { align-items: stretch; flex-direction: column; }
        .order-delete .danger-button { width: 100%; }
        .order-group > summary, .order-history li { align-items: flex-start; flex-direction: column; }
        .order-group-summary strong { margin-left: 0; }
        .trip-grid, .trip-facts { grid-template-columns: 1fr; }
        .vendor-order-layout { grid-template-columns: 1fr; }
        .details-grid dt { margin-top: 8px; }
    }
    /* The 16 columns need ~970px; narrower screens read one card per trip instead of scrolling sideways. */
    @media screen and (max-width: 1279px) {
        .sheet-wrap { max-height: none; overflow: visible; background: transparent; border: 0; box-shadow: none; }
        .order-sheet, .order-sheet tbody, .order-sheet tr, .order-sheet td { display: block; width: 100%; }
        .order-sheet thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
        .order-sheet tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px 16px; margin-bottom: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 2px rgb(16 24 40 / 4%); }
        .order-sheet tbody tr:hover td { background: transparent; }
        .order-sheet td, .order-sheet tbody td.sheet-no, .order-sheet tbody td.sheet-pick, .order-sheet tbody td.sheet-source { position: static; min-width: 0; max-width: none; width: auto; padding: 0; border: 0; text-align: left; background: transparent; white-space: normal; }
        .order-sheet td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
        .order-sheet td:empty, .order-sheet td.sheet-pick:not(:has(input)) { display: none; }
        /* Editable rows keep their empty fields on the card, otherwise there is nothing to double-click to fill them in. */
        .order-sheet tr[data-sheet-edit-url] td[data-sheet-field]:empty { display: block; }
        .order-sheet tr[data-sheet-edit-url] td[data-sheet-field]:empty::after { content: "—"; color: var(--muted); }
        .order-sheet :is(td[data-sheet-payment-url], td[data-sheet-dialog-url]):empty { display: block; }
        .order-sheet :is(td[data-sheet-payment-url], td[data-sheet-dialog-url]):empty::after { content: "—"; color: var(--muted); }
        .order-sheet .sheet-no, .order-sheet .sheet-address, .order-sheet .sheet-notes { grid-column: 1 / -1; }
        .order-sheet .sheet-no { font-size: 15px; font-weight: 700; }
        .sheet-address-summary-button { display: inline-flex; }
        .order-sheet .sheet-no::before { display: none; }
        .order-sheet .sheet-notes { white-space: pre-wrap; }
        .order-sheet tr.sheet-day-divider { display: block; height: 14px; margin-bottom: 12px; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: #000; }
        .order-sheet tr.sheet-day-band { height: auto; min-height: 14px; background: #000; border-top: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
        .order-sheet tr.sheet-day-band td.sheet-day-counts { display: block; padding: 2px 12px; white-space: normal; }
        .order-sheet tr.sheet-day-band td.sheet-day-counts::before { display: none; }
        .order-sheet tr.vendor-change-alert, .order-sheet tr.sheet-change-alert { border: 2px solid var(--danger); animation: vendor-change-card-blink 1s steps(1, end) infinite; }
        .order-sheet tr.vendor-change-alert > td, .order-sheet tr.sheet-change-alert > td { animation: none; }
        .order-sheet .sheet-ack { grid-column: 1 / -1; }
        /* Cards: a full-width, touch-sized dropdown under the 車行 label. */
        .order-sheet .sheet-vendor-select { width: 100%; min-height: 44px; padding: 8px 12px; border-color: var(--field-border); background: white; color: var(--ink); }
    }
    .suggest { position: relative; }
    /* 訂單表單的同業業務（輸入後自動提示）以淺紅底色標示，與其他欄位區隔。 */
    .agency-contact-search { background: #f4cccc; }
    .suggest-list { position: absolute; z-index: 6; top: calc(100% + 4px); left: 0; right: 0; max-height: min(360px, 60vh); overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--field-border); border-radius: 8px; box-shadow: 0 8px 24px rgb(16 24 40 / 14%); }
    .suggest-option { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
    .suggest-option[aria-selected="true"], .suggest-option:hover { background: var(--blue-soft); }
    .suggest-value { color: var(--ink); overflow-wrap: anywhere; }
    .suggest-value mark, .suggest-detail mark { background: none; color: inherit; font-weight: 700; }
    .suggest-detail { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
    @media print {
        .sidebar, .topbar, .breadcrumbs, .view-tabs, .sheet-filter, .table-scroll-hint, .menu-toggle, .suggest-list, .sheet-pager, .sheet-month-tabs { display: none !important; }
        .app-shell { display: block; }
        main { padding: 0; }
        .sheet-wrap { max-height: none; overflow: visible; box-shadow: none; }
        .order-sheet { min-width: 0; font-size: 10px; }
        .order-sheet th, .order-sheet td { padding: 3px 4px; position: static !important; }
        .order-sheet tr { break-inside: avoid; }
        .dispatch-sheet .mark-toggle { width: auto; height: auto; border: 0; background: none; font-size: inherit; color: inherit; }
        .order-sheet td.sheet-pending { background: none; }
        .order-sheet .sheet-vendor-select { min-width: 0; padding: 0; border: 0; appearance: none; }
        .sheet-new-draft, .sheet-batch, .sheet-batch-result, .sheet-address-summary, .sheet-receivable-statement, .sheet-multi-vehicle-dialog, .order-sheet .sheet-pick { display: none !important; }
    }
    @media (prefers-reduced-motion: reduce) {
        *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
        /* Reduced motion: no blinking, a steady highlight instead. */
        .order-sheet tr.vendor-change-alert, .order-sheet tr.vendor-change-alert > td, .order-sheet tr.sheet-change-alert, .order-sheet tr.sheet-change-alert > td { animation: none !important; }
        .order-sheet tr.vendor-change-alert > td, .order-sheet tr.sheet-change-alert > td { box-shadow: inset 0 0 0 999px rgb(255 193 7 / 45%); }
    }
    @media screen and (max-width: 1279px) and (prefers-reduced-motion: reduce) {
        .order-sheet tr.vendor-change-alert, .order-sheet tr.sheet-change-alert { background-color: #fff3c4; }
        .order-sheet tr.vendor-change-alert > td, .order-sheet tr.sheet-change-alert > td { box-shadow: none; }
    }
    /* #558 訂單總表三個頁籤（桌面與手機卡片）時間／類型／航班／機場的文字顏色，依類型欄的 data-sheet-tone：
       桃園機場整列黑、非桃園機場與港口整列紅（時間／類型／航班粗體）、接駁整列藍；機場欄與黑、藍維持一般粗細。
       派車總表與車行訂單仍沿用上方送機紅字規則。已取消列的灰字（!important）不受影響。 */
    .overview-sheet tr:has(> td[data-sheet-tone="taoyuan"]) > :is(td.sheet-time, td.sheet-direction, td.sheet-flight, td.sheet-location) { color: #000; }
    .overview-sheet tr:has(> td[data-sheet-tone="other"]) > :is(td.sheet-time, td.sheet-direction, td.sheet-flight, td.sheet-location) { color: #e00; }
    .overview-sheet tr:has(> td[data-sheet-tone="other"]) > :is(td.sheet-time, td.sheet-direction, td.sheet-flight) { font-weight: 700; }
    .overview-sheet tr:has(> td[data-sheet-tone="shuttle"]) > :is(td.sheet-time, td.sheet-direction, td.sheet-flight, td.sheet-location) { color: #1c3fd1; }
}
/* #238 vendor change alert blink, also used by the order sheet's change alert; keyframes cannot live inside the nested .ats-ui rule. */
@keyframes vendor-change-blink {
    0% { box-shadow: inset 0 0 0 999px rgb(255 193 7 / 70%); }
    50% { box-shadow: inset 0 0 0 999px rgb(255 193 7 / 0%); }
}
@keyframes vendor-change-card-blink {
    0% { background-color: #fff3c4; }
    50% { background-color: #fff; }
}
/* #560 訂單總表逐欄異動告警：只有被修改的欄位閃爍（桌機為該格，手機卡片為該欄位那一行）；編號欄的「已異動」文字照舊，
   不只依賴顏色或動態。沒有欄位紀錄的舊告警仍由 tr.sheet-change-alert 整列閃爍。減少動態時改為靜態醒目底色。 */
.ats-ui .order-sheet tbody td.sheet-change-field { animation: vendor-change-blink 1s steps(1, end) infinite; }
@media screen and (max-width: 1279px) {
    .ats-ui .order-sheet tbody td.sheet-change-field { margin: -3px -6px; padding: 3px 6px; border-radius: 6px; outline: 2px solid var(--danger); outline-offset: -2px; }
}
@media screen and (prefers-reduced-motion: reduce) {
    .ats-ui .order-sheet tbody td.sheet-change-field { animation: none !important; box-shadow: inset 0 0 0 999px rgb(255 193 7 / 45%); }
}
