:root {
  --navy: #172a46;
  --navy-2: #223957;
  --teal: #1f7a75;
  --teal-dark: #17645f;
  --teal-soft: #e5f3f1;
  --orange: #e38a32;
  --orange-soft: #fff1df;
  --red: #c8544c;
  --red-soft: #fce9e7;
  --green: #34785b;
  --green-soft: #e6f3eb;
  --ink: #172333;
  --muted: #6e7b8b;
  --line: #e2e6e9;
  --canvas: #f4f6f7;
  --white: #ffffff;
  --shadow: 0 12px 32px rgba(26, 42, 63, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: "DM Sans", "Noto Sans TC", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(31,122,117,.25); outline-offset: 2px; }

.sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; background: var(--navy); color: #fff; padding: 26px 18px 20px; display: flex; flex-direction: column; z-index: 20; }
.brand { color: #fff; text-decoration: none; display: flex; gap: 11px; align-items: center; padding: 0 10px 28px; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 9px; background: var(--teal); font-weight: 700; }
.brand strong, .brand small, .sidebar-foot strong, .sidebar-foot small { display: block; }
.brand strong { font-size: 17px; letter-spacing: .08em; }
.brand small { color: #93a4b8; font-size: 9px; text-transform: uppercase; letter-spacing: .18em; margin-top: 2px; }
nav { display: grid; gap: 6px; }
.staff-entry { color: #b9d9d5; padding: 14px 13px; font-size: 13px; text-decoration: none; }
.nav-item { border: 0; background: transparent; color: #aebccd; display: flex; align-items: center; gap: 13px; padding: 12px 13px; border-radius: 8px; width: 100%; text-align: left; font-weight: 600; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { background: rgba(44, 153, 145, .2); color: #fff; box-shadow: inset 3px 0 var(--teal); }
.nav-item svg { width: 18px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 18px 5px 0; display: grid; grid-template-columns: 36px 1fr 30px; gap: 9px; align-items: center; }
.sidebar-foot .avatar { width: 36px; height: 36px; background: #d8a86d; color: var(--navy); display: grid; place-items: center; border-radius: 50%; font-weight: 700; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot small { font-size: 10px; color: #91a1b4; margin-top: 2px; }

main { margin-left: 232px; min-height: 100vh; }
.topbar { height: 96px; padding: 19px 34px; background: var(--white); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 15; }
.eyebrow { margin: 0 0 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .11em; color: var(--teal); }
h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.global-search { height: 40px; width: 244px; padding: 0 12px; background: var(--canvas); border: 1px solid transparent; border-radius: 8px; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.global-search:focus-within { border-color: var(--teal); background: white; }
.global-search input { border: 0; outline: 0; background: transparent; min-width: 0; width: 100%; font-size: 13px; }
.global-search svg { width: 17px; }
.icon-btn { position: relative; border: 0; border-radius: 8px; background: transparent; color: inherit; min-width: 36px; height: 36px; display: grid; place-items: center; }
.topbar .icon-btn { border: 1px solid var(--line); background: white; }
.icon-btn svg { width: 18px; }
.notification-btn i { width: 6px; height: 6px; background: var(--orange); border-radius: 50%; position: absolute; top: 8px; right: 8px; }
.primary-btn, .secondary-btn, .ghost-btn { border: 0; border-radius: 8px; height: 40px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.primary-btn { background: var(--teal); color: white; box-shadow: 0 7px 16px rgba(31,122,117,.16); }
.primary-btn:hover { background: var(--teal-dark); }
.secondary-btn { background: var(--navy); color: white; }
.ghost-btn { background: white; color: var(--ink); border: 1px solid var(--line); }
.danger-btn { color: var(--red); }
.primary-btn svg, .secondary-btn svg, .ghost-btn svg { width: 16px; }
.page { padding: 30px 34px 44px; max-width: 1540px; margin: 0 auto; }

.welcome-row, .section-head, .toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.welcome-row { margin-bottom: 22px; }
.welcome-row h2, .section-head h2 { margin: 0; font-size: 20px; }
.welcome-row p, .section-head p { color: var(--muted); margin: 5px 0 0; font-size: 13px; }
.date-chip { font-size: 12px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 17px 18px; display: grid; grid-template-columns: 1fr auto; align-items: start; min-width: 0; }
.stat-card .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-card strong { font-size: 26px; display: block; margin-top: 8px; letter-spacing: -.03em; }
.stat-card .delta { margin-top: 7px; font-size: 10px; color: var(--green); }
.stat-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; background: var(--teal-soft); color: var(--teal); }
.stat-icon.orange { background: var(--orange-soft); color: var(--orange); }
.stat-icon.navy { background: #e8edf3; color: var(--navy); }
.stat-icon svg { width: 18px; }
.content-grid { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(280px,.75fr); gap: 20px; }
.card { background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 8px rgba(22,40,64,.02); overflow: hidden; }
.card-head { padding: 17px 19px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-head h3 { margin: 0; font-size: 14px; }
.text-link { border: 0; background: transparent; color: var(--teal); font-size: 12px; font-weight: 700; }
.job-list { padding: 3px 19px; }
.job-row { display: grid; grid-template-columns: 38px minmax(0,1.2fr) minmax(0,.8fr) 100px; gap: 13px; align-items: center; padding: 14px 0; border-bottom: 1px solid #edf0f2; }
.job-row:last-child { border-bottom: 0; }
.time-tile { background: var(--canvas); padding: 6px 4px; border-radius: 7px; text-align: center; font-size: 10px; color: var(--muted); }
.time-tile strong { font-size: 14px; color: var(--navy); display: block; }
.job-main strong, .job-meta strong { display: block; font-size: 12px; overflow-wrap: anywhere; }
.job-main span, .job-meta span { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 99px; font-size: 10px; font-weight: 700; padding: 5px 9px; white-space: nowrap; }
.badge.green { color: var(--green); background: var(--green-soft); }
.badge.orange { color: #a6611f; background: var(--orange-soft); }
.badge.blue { color: #37668d; background: #e6f0f8; }
.badge.gray { color: #667280; background: #edf0f2; }
.badge.red { color: var(--red); background: var(--red-soft); }
.progress-wrap { padding: 18px 19px 5px; }
.progress-title { display: flex; justify-content: space-between; align-items: baseline; }
.progress-title strong { font-size: 13px; }
.progress-title span { font-size: 10px; color: var(--muted); }
.progress { height: 7px; background: #edf0f2; border-radius: 10px; margin: 9px 0 20px; overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--teal); }
.quick-actions { padding: 10px 19px 19px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.quick-action { border: 1px solid var(--line); background: white; border-radius: 9px; padding: 12px 8px; display: grid; gap: 7px; justify-items: center; color: var(--ink); font-size: 11px; font-weight: 600; }
.quick-action:hover { border-color: var(--teal); color: var(--teal); }
.quick-action svg { width: 18px; }

.section-head { margin-bottom: 20px; }
.toolbar { align-items: center; margin-bottom: 14px; }
.toolbar .global-search { background: white; width: min(360px,100%); }
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn { border: 1px solid var(--line); background: white; border-radius: 7px; padding: 8px 11px; font-size: 11px; color: var(--muted); }
.filter-btn.active { color: var(--teal); border-color: #8cc3bd; background: var(--teal-soft); font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th { background: #f9fafb; color: var(--muted); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; text-align: left; padding: 11px 15px; border-bottom: 1px solid var(--line); }
td { padding: 13px 15px; font-size: 12px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.cell-title { font-weight: 700; display: block; }
.cell-sub { color: var(--muted); font-size: 10px; display: block; margin-top: 3px; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.row-actions button { border: 1px solid var(--line); background: white; width: 31px; height: 31px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); }
.row-actions button:hover { color: var(--teal); border-color: #8cc3bd; }
.row-actions svg { width: 15px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .stat-icon { margin: 0 auto 12px; }
.empty strong { display: block; color: var(--ink); margin-bottom: 5px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(11, 24, 40, .52); backdrop-filter: blur(3px); z-index: 40; display: grid; place-items: center; padding: 20px; }
.modal { width: min(720px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; background: white; border-radius: 14px; box-shadow: 0 28px 70px rgba(0,0,0,.24); }
.modal.wide { width: min(900px,100%); }
.modal-head { padding: 19px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.modal-head .icon-btn { border: 1px solid var(--line); color: var(--muted); }
.modal-body { padding: 22px; }
.modal-foot { padding: 15px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; position: sticky; bottom: 0; background: white; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.pump-count-field[hidden] { display: none; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11px; font-weight: 700; color: #4d5967; }
.required::after { content: " *"; color: var(--red); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #d7dde1; border-radius: 8px; padding: 10px 11px; color: var(--ink); background: white; }
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); outline: 3px solid rgba(31,122,117,.1); }
.field .error { color: var(--red); font-size: 10px; min-height: 13px; }
.field-help { color: var(--muted); font-size: 9px; line-height: 1.5; }
.map-settings-status { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 9px; background: #f7f9fa; padding: 12px; display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.map-settings-status strong { color: var(--ink); }
.map-settings-status.connected { border-color: #92cfc4; background: var(--teal-soft); }
.map-settings-status.connected strong { color: var(--teal); }
.map-settings-status code { overflow-wrap: anywhere; }
.field-label-row { min-height: 18px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.now-dispatch-btn { border: 1px solid #f2c27f; border-radius: 99px; background: #fff7e8; color: #a45a00; padding: 4px 9px; font-size: 9px; font-weight: 800; cursor: pointer; }
.now-dispatch-btn:hover, .now-dispatch-btn.active { border-color: var(--orange); background: var(--orange-soft); }
.route-distance-btn { border: 1px solid #9acbc7; border-radius: 99px; background: var(--teal-soft); color: var(--teal); padding: 4px 9px; font-size: 9px; font-weight: 800; cursor: pointer; }
.route-distance-btn:hover { border-color: var(--teal); }
.route-distance-btn:disabled { cursor: wait; opacity: .65; }
.location-search-btn { border: 0; background: transparent; color: var(--teal); padding: 3px 0; font-size: 9px; font-weight: 800; cursor: pointer; }
.location-search-btn:disabled { color: var(--muted); cursor: wait; }
.location-picker > input[type="hidden"] { display: none; }
.location-results { display: none; border: 1px solid var(--line); border-radius: 9px; background: white; overflow: hidden; }
.location-results.open { display: grid; }
.location-result { border: 0; border-bottom: 1px solid var(--line); background: white; padding: 9px; text-align: left; display: grid; grid-template-columns: 22px minmax(0,1fr); column-gap: 7px; row-gap: 2px; cursor: pointer; }
.location-result:last-child { border-bottom: 0; }
.location-result:hover, .location-result:focus-visible { background: var(--teal-soft); outline: 0; }
.location-result > span { grid-row: 1 / 3; width: 20px; height: 20px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; font-size: 9px; font-weight: 800; }
.location-result strong { color: var(--ink); font-size: 9px; line-height: 1.45; }
.location-result small { color: var(--teal); font-size: 8px; font-weight: 700; }
.location-result.approximate small { color: #a45a00; }
.location-searching, .location-search-empty, .location-confirmed { padding: 10px; display: grid; gap: 3px; font-size: 9px; color: var(--muted); }
.location-search-empty strong { color: var(--red); }
.location-results.confirmed { border-color: #92cfc4; background: var(--teal-soft); }
.location-results.confirmed.approximate { border-color: #f2c27f; background: #fff7e8; }
.location-confirmed strong { color: var(--teal); font-size: 10px; }
.location-results.approximate .location-confirmed strong { color: #a45a00; }
.location-confirmed span { line-height: 1.45; overflow-wrap: anywhere; }
.location-confirmed small { color: var(--muted); }
.route-lookup-status { border: 1px dashed #c9d5d9; border-radius: 8px; padding: 9px 11px; color: var(--muted); display: grid; gap: 4px; font-size: 9px; line-height: 1.45; }
.route-lookup-status strong { color: var(--teal); font-size: 10px; }
.route-lookup-status span { overflow-wrap: anywhere; }
.route-lookup-status small { color: #87929e; }
.patient-search { display: none; position: relative; }
.client-lookup.patient-mode .patient-search { display: block; }
.client-lookup.patient-mode > select { display: none; }
.patient-search-results { display: none; margin-top: 6px; border: 1px solid var(--line); border-radius: 9px; background: white; overflow: hidden; box-shadow: 0 10px 28px rgba(17,35,53,.1); }
.patient-search-results.open { display: grid; }
.patient-result { border: 0; border-bottom: 1px solid var(--line); background: white; padding: 10px 11px; text-align: left; display: grid; gap: 3px; cursor: pointer; }
.patient-result:last-child { border-bottom: 0; }
.patient-result:hover, .patient-result:focus-visible { background: var(--teal-soft); outline: 0; }
.patient-result strong { font-size: 11px; color: var(--ink); }
.patient-result small, .patient-search-empty { font-size: 9px; color: var(--muted); }
.patient-search-empty { padding: 11px; }
.form-section { margin: 8px 0 16px; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; grid-column: 1 / -1; }
.form-section h3 { margin: 0; font-size: 13px; }
.mode-picker { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; }
.mode-picker.duty-picker { grid-template-columns: repeat(2,minmax(0,1fr)); }
.mode-picker label { cursor: pointer; min-width: 0; }
.mode-picker input { position: absolute; opacity: 0; pointer-events: none; }
.mode-picker label > span { min-height: 76px; border: 1px solid var(--line); border-radius: 9px; padding: 11px; display: grid; grid-template-columns: 22px minmax(0,1fr); column-gap: 7px; align-items: center; background: white; }
.mode-picker svg { color: var(--teal); }
.mode-picker strong { font-size: 11px; }
.mode-picker small { grid-column: 2; color: var(--muted); font-size: 9px; }
.mode-picker input:checked + span { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 1px var(--teal); }
.mode-picker input:focus-visible + span { outline: 3px solid rgba(31,122,117,.2); outline-offset: 2px; }
.billing-picker { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.billing-picker label { cursor: pointer; min-width: 0; }
.billing-picker input { position: absolute; opacity: 0; pointer-events: none; }
.billing-picker label > span { min-height: 64px; border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; display: grid; gap: 4px; background: white; }
.billing-picker strong, .billing-picker small { display: block; }
.billing-picker strong { color: var(--ink); font-size: 11px; }
.billing-picker small { color: var(--muted); font-size: 9px; line-height: 1.45; }
.billing-picker input:checked + span { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 1px var(--teal); }
.billing-picker input:focus-visible + span { outline: 3px solid rgba(31,122,117,.2); outline-offset: 2px; }
.pricing-panel { display: none; grid-column: 1 / -1; border: 1px solid var(--line); background: #fbfcfc; border-radius: 10px; padding: 14px; }
.pricing-panel.active { display: block; }
.pricing-panel .form-section { margin: 0 0 14px; padding: 0; }
.rule-note { color: var(--teal); background: var(--teal-soft); border-radius: 99px; padding: 5px 9px; font-size: 9px; font-weight: 700; }
.addon-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.addon-grid label { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; align-items: center; gap: 7px; cursor: pointer; background: white; }
.addon-grid label:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 1px var(--teal); }
.addon-grid label.disabled { opacity: .42; cursor: not-allowed; }
.addon-grid input { width: auto; }
.addon-grid span { flex: 1; display: flex; justify-content: space-between; gap: 5px; font-size: 10px; }
.addon-grid b { color: var(--teal); }
.price-breakdown { background: var(--navy); color: white; border-radius: 9px; padding: 11px 13px; display: grid; gap: 7px; }
.price-breakdown span { display: flex; justify-content: space-between; gap: 12px; font-size: 10px; color: #c6d0dc; }
.price-breakdown strong { color: white; }
.line-items { grid-column: 1 / -1; display: grid; gap: 8px; }
.line-row { display: grid; grid-template-columns: minmax(170px,1fr) 75px 110px 36px; gap: 8px; align-items: center; }
.line-row input { width: 100%; border: 1px solid #d7dde1; border-radius: 8px; padding: 9px; min-width: 0; }
.line-row button { border: 0; background: var(--red-soft); color: var(--red); border-radius: 7px; height: 36px; }
.quote-total { grid-column: 1 / -1; display: flex; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.quote-total span { color: var(--muted); font-size: 11px; margin-right: 20px; }
.quote-total strong { font-size: 20px; }
.detail-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-bottom: 18px; }
.detail-cell { background: var(--canvas); border-radius: 8px; padding: 11px; }
.detail-cell span { color: var(--muted); font-size: 9px; display: block; margin-bottom: 4px; }
.detail-cell strong { font-size: 12px; overflow-wrap: anywhere; }
.receipt { font-family: "Noto Sans TC", sans-serif; border: 1px solid var(--line); padding: 28px; }
.receipt-title { display: flex; justify-content: space-between; border-bottom: 2px solid var(--navy); padding-bottom: 16px; margin-bottom: 18px; }
.receipt-title h2 { margin: 0; letter-spacing: .18em; }
.receipt-title small { color: var(--muted); }
.receipt table { min-width: 0; }
.receipt-total { text-align: right; margin-top: 18px; font-size: 18px; font-weight: 700; }
.toast { position: fixed; right: 26px; bottom: 24px; z-index: 80; background: var(--navy); color: white; border-radius: 9px; padding: 11px 15px; font-size: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .sidebar { width: 76px; padding-inline: 10px; }
  .brand { padding-inline: 10px; }
  .brand > span:last-child, .nav-item span, .sidebar-foot > span:not(.avatar), .sidebar-foot .icon-btn { display: none; }
  .nav-item { justify-content: center; padding: 13px; }
  .sidebar-foot { display: flex; justify-content: center; }
  main { margin-left: 76px; }
  .content-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 640px) {
  .sidebar { position: fixed; inset: auto 0 0 0; width: auto; height: 67px; padding: 7px 8px; flex-direction: row; align-items: center; overflow-x: auto; border-top: 1px solid rgba(255,255,255,.1); }
  .brand, .sidebar-foot { display: none; }
  nav { width: 100%; display: flex; justify-content: space-around; gap: 2px; }
  .nav-item { width: auto; flex: 1; padding: 7px 4px; display: grid; justify-items: center; gap: 3px; font-size: 9px; }
  .nav-item span { display: block; }
  .nav-item svg { width: 17px; }
  .nav-item.active { box-shadow: inset 0 -2px var(--teal); }
  main { margin-left: 0; padding-bottom: 67px; }
  .topbar { height: auto; min-height: 76px; padding: 13px 16px; }
  .eyebrow { font-size: 9px; }
  h1 { font-size: 19px; }
  .global-search { display: none; }
  .top-actions .notification-btn { display: none; }
  .top-actions .primary-btn { width: 38px; padding: 0; }
  .top-actions .primary-btn { font-size: 0; }
  .top-actions .primary-btn svg { width: 17px; }
  .page { padding: 20px 16px 30px; }
  .welcome-row { align-items: flex-start; }
  .date-chip { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 14px; }
  .stat-card strong { font-size: 22px; }
  .stat-card .delta { font-size: 9px; }
  .stat-icon { width: 31px; height: 31px; }
  .job-row { grid-template-columns: 36px minmax(0,1fr) 76px; }
  .job-meta { display: none; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar .global-search { display: flex; width: 100%; }
  .section-head { align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full, .form-section, .line-items, .quote-total { grid-column: 1; }
  .mode-picker { grid-template-columns: 1fr; }
  .mode-picker.duty-picker { grid-template-columns: 1fr; }
  .billing-picker { grid-template-columns: 1fr; }
  .mode-picker label > span { min-height: 58px; }
  .pricing-panel { grid-column: 1; }
  .addon-grid { grid-template-columns: 1fr 1fr; }
  .line-row { grid-template-columns: minmax(120px,1fr) 56px 86px 34px; }
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal, .modal.wide { width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; }
  .modal-body { padding: 18px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .toast { right: 16px; bottom: 82px; left: 16px; text-align: center; }
}

/* One backend, touch-friendly layouts; no device-specific data or auth changes. */
@media (max-width: 980px) {
  .topbar { height: auto; gap: 14px; flex-wrap: wrap; padding: 18px 24px; }
  .topbar > div:first-child { flex: 1 1 100%; min-width: 0; }
  .top-actions { flex: 1 1 100%; flex-wrap: wrap; min-width: 0; }
  .top-actions .global-search { flex: 1; width: auto; }
  .primary-btn, .secondary-btn, .ghost-btn, .icon-btn, .row-actions button,
  .filter-btn, .now-dispatch-btn, .route-distance-btn, .location-search-btn { min-height: 44px; }
  .row-actions button { min-width: 44px; }
  .field input, .field select, .field textarea, .line-row input { min-height: 44px; font-size: 16px; }
  .modal { max-height: calc(100dvh - 40px); }
  .modal-foot { flex-wrap: wrap; }
  .field-label-row { flex-wrap: wrap; }
}
@media (min-width: 641px) and (max-width: 980px) {
  .sidebar { width: 112px; padding-inline: 8px; overflow-y: auto; }
  main { margin-left: 112px; }
  .nav-item { display: grid; justify-items: center; gap: 5px; padding: 10px 5px; }
  .nav-item span { display: block; font-size: 12px; white-space: nowrap; }
  .staff-entry { font-size: 11px; padding: 10px 4px; overflow-wrap: anywhere; }
  button.staff-entry { border: 1px solid #61738b; border-radius: 8px; background: transparent; }
  .page { padding: 24px; }
}
@media (max-width: 640px) {
  .sidebar { height: auto; min-height: 72px; padding-bottom: calc(7px + env(safe-area-inset-bottom)); }
  .sidebar nav { flex: 0 0 360px; width: 360px; }
  .nav-item { min-width: 58px; min-height: 52px; }
  .nav-item span { white-space: nowrap; font-size: 10px; }
  .sidebar .staff-entry { flex: 0 0 88px; padding: 8px; font-size: 10px; }
  .sidebar button.staff-entry { background: transparent; border: 1px solid #61738b; border-radius: 8px; }
  main { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
  .topbar { padding: 12px 16px; gap: 10px; }
  .top-actions { gap: 8px; }
  .top-actions .primary-btn { width: auto; padding: 0 12px; font-size: 13px; margin-left: auto; }
  .page { padding-inline: 14px; }
  .section-head { flex-wrap: wrap; }
  .modal, .modal.wide { max-height: 94dvh; }
  .modal-head { padding: 16px; gap: 12px; }
  .modal-head > div { min-width: 0; overflow-wrap: anywhere; }
  .modal-body { padding: 16px; }
  .modal-foot { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot button { width: 100%; min-width: 0; padding-inline: 8px; }
  .line-row { grid-template-columns: minmax(0,1fr) minmax(0,1.3fr) 44px; }
  .line-row input[name="itemName"] { grid-column: 1 / -1; }
  .line-row button { min-height: 44px; }
  .table-wrap { max-width: 100%; overscroll-behavior-x: contain; }
  .auth-card { padding: 24px; }
  .auth-card button { min-height: 48px; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}

@media print {
  body * { visibility: hidden; }
  .receipt, .receipt * { visibility: visible; }
  .receipt { position: absolute; inset: 0; border: 0; }
  .modal-backdrop { background: white; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
