/* 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; }
    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; }
    .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; }
    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 { 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; }
    .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 { 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; }
    th:nth-child(1) { width: 22%; }
    th:nth-child(2) { width: 18%; }
    th:nth-child(3) { width: 9%; }
    th:nth-child(4) { width: 23%; }
    th:nth-child(5) { width: 28%; }
    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; }
    .row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
    .row-actions a { min-height: 44px; display: inline-flex; align-items: center; padding: 8px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
    .row-actions a:hover { background: #dbeafe; text-decoration: none; }
    .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; }

    /* 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) { grid-column: 1 / -1; }
    .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; }
    .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; }
    .customer-table th:nth-child(n) { width: auto; }
    .company-customer-table th:nth-child(n) { width: auto; }
    .relationship-table th:nth-child(n) { width: auto; }
    .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; }
    .contact-table th:nth-child(n) { width: auto; }
    .settlement-account-table th:nth-child(n) { width: auto; }
    .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); }
    .inline-choice { min-width: 190px; margin: 0; font-size: 12px; font-weight: 600; }
    .inline-choice select { margin-top: 4px; }
    .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; }
    .announcement-section h2 { margin-bottom: 16px; }
    .announcement-card { border-top: 1px solid var(--border); padding: 16px 0; overflow-wrap: anywhere; }
    .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-history-table th:nth-child(n) { width: auto; }
    .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
    .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; }
    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; }
    .trip-total { color: var(--success); background: var(--success-bg); border-radius: 8px; padding: 6px 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); }
    .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)); }
    .flight-lookup { margin: -8px 0 16px; }
    .flight-lookup-actions { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; padding-top: 30px; }
    .flight-lookup-status { display: block; margin: 0 0 4px; }
    .flight-lookup-status:empty { display: none; }
    .flight-candidate { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
    .flight-candidate span { min-width: 0; overflow-wrap: anywhere; }
    .flight-candidate small { display: block; color: var(--muted); }
    .subsection { border-top: 1px solid var(--border); padding-top: 20px; }
    .subsection > legend { float: left; width: 100%; font-size: 16px; margin-bottom: 12px; }
    .subsection > legend + * { clear: both; }
    .subsection > legend + .hint { margin: -8px 0 16px; }
    .address-list { display: grid; gap: 8px; }
    .address-row { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 8px; }
    .address-row > span { width: 28px; height: 28px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); border-radius: 50%; font-weight: 700; }
    .item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 16px; }
    .surcharge-list { display: grid; gap: 8px; margin-bottom: 12px; }
    .surcharge-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(120px, .7fr) auto; gap: 12px; align-items: end; }
    .surcharge-row .field { margin: 0; }
    .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); }
    .sheet-wrap { max-height: calc(100vh - 160px); overflow: auto; }
    .order-sheet { width: 100%; min-width: 0; table-layout: auto; font-size: 13px; }
    .order-sheet th:nth-child(n):not(.sheet-no) { width: auto; }
    .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; text-align: left; }
    .order-sheet .sheet-notes { min-width: 80px; text-align: left; white-space: pre-wrap; }
    .order-sheet .sheet-nowrap { white-space: nowrap; overflow-wrap: normal; }
    .order-sheet .sheet-location { min-width: 84px; }
    .order-sheet .sheet-vendor { min-width: 40px; }
    .order-sheet .sheet-muted { color: var(--muted); font-size: 12px; }
    .order-sheet .sheet-amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
    .order-sheet form { margin: 0; }
    .order-sheet .sheet-pdf-button { min-height: 0; padding: 3px 10px; font-size: 12px; }
    /* The detail link sits in the sticky number column so it stays in reach while scrolling sideways. */
    .order-sheet .sheet-detail-button { display: flex; min-height: 0; margin-top: 4px; padding: 3px 6px; font-size: 12px; color: 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; }
    .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; }
    .order-sheet .sheet-mark { white-space: nowrap; }
    .order-sheet .sheet-mark form { margin: 0; }
    .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-addresses { margin: 0; padding-left: 20px; }
    .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-card { padding: 20px; display: grid; grid-template-columns: minmax(220px, 1fr) minmax(360px, 2fr) auto; gap: 20px; align-items: center; }
    .vendor-order-card h2 { margin: 2px 0 4px; }
    .vendor-order-card p { color: var(--muted); margin: 0; }
    .vendor-order-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
    .vendor-order-meta span { min-width: 0; overflow-wrap: anywhere; }
    .vendor-order-meta b { display: block; color: var(--muted); font-size: 12px; }
    .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 th:nth-child(n) { width: auto; }
    .settlement-table .amount, .settlement-table th.amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
    .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-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%; }
        .announcement-columns { grid-template-columns: 1fr; }
        .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-open .drawer-backdrop { display: block; position: fixed; z-index: 10; inset: 0; background: rgb(15 23 42 / 45%); }
        .menu-toggle { display: block; }
        .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 { grid-template-columns: 1fr; }
        .flight-lookup-actions { padding-top: 0; }
        .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .field-grid > .choice-row { margin: 0 0 24px; }
        .order-draft-form > .form-actions { position: static; padding: 0; background: transparent; border: 0; box-shadow: none; }
        .order-section > .section-heading { align-items: flex-start; }
        .surcharge-row { grid-template-columns: 1fr; }
        .flight-candidate { grid-template-columns: 1fr; }
        .flight-lookup-actions .secondary-button { width: 100%; }
        .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-card, .vendor-order-layout { grid-template-columns: 1fr; }
        .vendor-order-card .secondary-button { width: 100%; }
        .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-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 { display: none; }
        .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; }
        .order-sheet .sheet-no::before { display: none; }
        .order-sheet .sheet-notes { white-space: pre-wrap; }
    }
    .suggest { position: relative; }
    .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 { 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; }
    }
    @media (prefers-reduced-motion: reduce) {
        *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
    }
}
