:root {
  color-scheme: light;
  --navy: #071426;
  --navy-soft: #14253b;
  --blue: #0078bd;
  --cyan: #00a4df;
  --green: #16794a;
  --amber: #9a5b00;
  --red: #b33434;
  --ink: #17212e;
  --muted: #647181;
  --line: #d9e0e7;
  --surface: #ffffff;
  --canvas: #eef2f5;
  --soft-blue: #e9f5fb;
  --soft-green: #eaf6ef;
  --soft-amber: #fff5df;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100%; color: var(--ink); background: var(--canvas); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(0, 164, 223, 0.32); outline-offset: 2px; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--navy); }
.login-panel { width: min(100%, 390px); background: #fff; border: 1px solid #2b435f; border-radius: 7px; overflow: hidden; box-shadow: 0 18px 52px rgba(0, 0, 0, 0.28); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 18px; min-height: 158px; padding: 24px; background: #020b1b; border-bottom: 3px solid var(--cyan); }
.login-brand img { width: 88px; height: 88px; object-fit: contain; }
.login-wordmark { display: grid; color: #fff; line-height: 1; }
.login-wordmark strong { font-size: 28px; font-weight: 800; }
.login-wordmark span { margin-top: 4px; color: var(--cyan); font-size: 17px; font-weight: 700; letter-spacing: 0; }
.login-wordmark small { margin-top: 13px; color: #aebed0; font-size: 8px; font-weight: 700; }
.login-form { display: grid; gap: 8px; padding: 24px; }
.login-form h1 { margin: 0 0 10px; color: var(--navy); font-size: 24px; }
.login-form label { margin-top: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.login-form input { width: 100%; min-height: 44px; padding: 10px 11px; border: 1px solid #bfcbd5; border-radius: 5px; }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; top: 2px; right: 2px; width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.text-button { min-height: 40px; border: 0; color: var(--blue); background: transparent; font-weight: 700; }
.form-error { margin: 5px 0 0; color: var(--red); font-size: 13px; }
.auth-separator { display: flex; align-items: center; gap: 9px; margin: 6px 0; color: var(--muted); font-size: 11px; }
.auth-separator::before, .auth-separator::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.app-shell { min-height: 100vh; background: var(--surface); padding-bottom: calc(74px + var(--safe-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 16px; color: #fff; background: var(--navy); border-bottom: 3px solid var(--cyan); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: #fff; text-decoration: none; }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.brand span { display: grid; line-height: 1; }
.brand strong { font-size: 17px; font-weight: 700; }
.brand small { margin-top: 4px; color: #42bced; font-size: 10px; font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.mode-button { min-height: 34px; padding: 6px 9px; border: 1px solid #34455b; border-radius: 5px; color: #fff; background: var(--navy-soft); font-size: 11px; font-weight: 700; }
.user-summary { display: none; max-width: 180px; color: #d7e2ed; font-size: 11px; text-align: right; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; color: #d7e2ed; font-size: 12px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #56d48e; }
.status-dot.offline::before { background: #f1ae42; }

.icon-button { width: 40px; height: 40px; display: inline-grid; place-items: center; flex: 0 0 40px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--surface); font-weight: 700; }
.topbar .icon-button { width: 36px; height: 36px; flex-basis: 36px; color: #fff; border-color: #34455b; background: var(--navy-soft); }
.offline-banner, .degraded-banner, .update-banner { padding: 10px 16px; font-size: 13px; border-bottom: 1px solid; }
.offline-banner { color: #553300; background: var(--soft-amber); border-color: #e8c675; }
.degraded-banner { color: #17435a; background: var(--soft-blue); border-color: #a9d9ee; }
.update-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #17354b; background: #e2f3fb; border-color: #98d3eb; }
.update-banner button { min-height: 34px; border: 0; color: #fff; background: var(--blue); border-radius: 5px; font-weight: 700; }
.offline-banner button { float: right; border: 0; color: var(--blue); background: transparent; font-weight: 700; }
.desk-sidebar { display: none; }

main { width: 100%; margin: 0 auto; }
main:focus { outline: none; }
.view { min-height: calc(100vh - 141px); padding: 22px 16px 32px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 20px; }
.heading-actions { display: flex; align-items: center; gap: 7px; }
.compact-heading { align-items: flex-end; }
.section-heading h1, .section-heading h2, .route-command h2, .dialog h2 { margin: 0; color: var(--navy); }
.section-heading h1 { font-size: 26px; line-height: 1.15; }
.section-heading h2, .route-command h2, .dialog h2 { font-size: 19px; }
.eyebrow { margin: 0 0 5px; color: var(--blue); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.support-copy { margin: 7px 0 0; color: var(--muted); line-height: 1.5; }
.next-visit { margin: 16px 0 18px; padding: 16px; border: 1px solid #b9d8e7; border-left: 5px solid var(--cyan); border-radius: 6px; background: var(--soft-blue); }
.next-visit h2 { margin: 0 0 8px; color: var(--navy); font-size: 12px; text-transform: uppercase; }
.next-visit strong { display: block; color: var(--navy); font-size: 20px; }
.next-visit p { margin: 5px 0; color: var(--muted); }
.field-route-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 14px; }
.field-route-actions a, .field-route-actions button { min-width: 0; min-height: 42px; display: grid; place-items: center; padding: 8px; border: 1px solid #a8cbdc; border-radius: 5px; color: #075b81; background: #fff; text-decoration: none; text-align: center; font-size: 12px; font-weight: 750; }
.field-day { padding: 14px 0; border-bottom: 1px solid var(--line); }
.field-day > button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0; border: 0; color: var(--ink); background: transparent; text-align: left; }
.field-day h2 { margin: 0; color: var(--navy); font-size: 17px; }
.field-visit-row { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.field-visit-row time { color: var(--blue); font-weight: 800; }
.field-visit-row strong, .field-visit-row small { display: block; overflow-wrap: anywhere; }
.field-visit-row small { margin-top: 3px; color: var(--muted); }
.passkey-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.passkey-row strong, .passkey-row small { display: block; }
.passkey-row small { color: var(--muted); }
.sync-conflict-center { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.sync-conflict-center h2 { margin: 0; color: var(--navy); font-size: 18px; }
.sync-conflict-card { margin-top: 12px; padding: 14px; border: 1px solid #e1bd6e; border-left: 4px solid var(--amber); border-radius: 6px; background: var(--soft-amber); }
.sync-conflict-card pre { max-height: 130px; overflow: auto; padding: 8px; color: var(--ink); background: #fff; border: 1px solid #e8c675; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; }
.sync-conflict-card textarea { width: 100%; min-height: 100px; padding: 8px; border: 1px solid #c9a85f; border-radius: 5px; resize: vertical; }

.morning-band { display: grid; gap: 18px; margin: 0 -16px; padding: 22px 16px; color: #fff; background: var(--navy-soft); border-top: 1px solid #273b54; border-bottom: 1px solid #273b54; }
.morning-band h2 { margin: 0; font-size: 21px; }
.morning-band .eyebrow { color: #63c9ee; }
.morning-band .support-copy { color: #d7e2ed; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; background: #3a4d64; border: 1px solid #3a4d64; }
.metrics div { min-width: 0; padding: 12px 8px; background: #102238; }
.metrics div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.metrics dt { color: #b8c7d6; font-size: 10px; line-height: 1.25; }
.metrics dd { margin: 4px 0 0; font-size: 22px; font-weight: 750; }
.feedback-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.feedback-actions button { min-height: 42px; padding: 8px 15px; border: 1px solid #7590a8; border-radius: 5px; color: #fff; background: #102238; font-weight: 750; }
.morning-details { display: grid; gap: 0; margin: 18px 0 26px; }
.morning-details h2 { margin: 18px 0 6px; color: var(--navy); font-size: 17px; }
.freshness-copy { margin-top: 14px; }

.chat-section { padding-top: 26px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 12px; }
.quick-actions button, .secondary-button { min-height: 38px; padding: 8px 11px; border: 1px solid #abd8ea; border-radius: 6px; color: #075b81; background: var(--soft-blue); white-space: nowrap; font-size: 13px; font-weight: 650; }
.chat-log { min-height: 180px; max-height: 430px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.message { max-width: 88%; padding: 11px 12px; border-radius: 7px; line-height: 1.45; font-size: 14px; overflow-wrap: anywhere; }
.message.assistant { align-self: flex-start; background: #f0f3f6; border: 1px solid #dce3e9; }
.message.user { align-self: flex-end; color: #fff; background: var(--blue); border: 1px solid var(--blue); }
.message.pending { opacity: 0.72; border-style: dashed; }
.message p { margin: 0; white-space: pre-wrap; }
.message .message-meta { margin-top: 6px; color: inherit; opacity: 0.72; font-size: 11px; }
.confirmation-actions { display: flex; gap: 8px; margin-top: 10px; }
.confirmation-actions button { min-height: 34px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.confirmation-actions button:first-child { color: #fff; border-color: var(--green); background: var(--green); }
.assistant-contact-button { width: 100%; margin-top: 10px; }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 40px 44px; gap: 7px; align-items: end; padding-top: 12px; border-top: 1px solid var(--line); }
.composer textarea { width: 100%; min-height: 46px; max-height: 130px; resize: vertical; padding: 11px; border: 1px solid #bfcbd5; border-radius: 6px; color: var(--ink); background: #fff; }
.send-button { width: 44px; height: 44px; border: 0; border-radius: 6px; color: #fff; background: var(--blue); font-size: 19px; }

.item-list { display: grid; gap: 9px; }
.item-card { padding: 14px; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 6px; background: #fff; }
.item-card.priority-urgent { border-left-color: var(--red); }
.item-card.priority-attention { border-left-color: var(--amber); }
.item-card button.card-main { width: 100%; padding: 0; border: 0; color: inherit; background: transparent; text-align: left; }
.item-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.item-title strong { color: var(--navy); font-size: 15px; }
.score { flex: 0 0 auto; min-width: 42px; padding: 4px 6px; color: #fff; background: var(--navy); border-radius: 4px; text-align: center; font-size: 12px; font-weight: 800; }
.item-card p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 9px; color: var(--muted); font-size: 11px; }
.loading-state, .empty-state { padding: 28px 4px; color: var(--muted); text-align: center; }

.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 18px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented-control button { min-height: 40px; border: 0; border-right: 1px solid var(--line); color: var(--muted); background: #fff; font-size: 13px; }
.segmented-control button:last-child { border-right: 0; }
.segmented-control button.active { color: #fff; background: var(--navy-soft); font-weight: 700; }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; min-height: 68px; margin-left: 12px; padding: 0 0 18px 26px; border-left: 2px solid #bed2df; }
.timeline-item::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--cyan); border: 3px solid #fff; box-shadow: 0 0 0 1px #9ab9ca; }
.timeline-time { color: var(--blue); font-size: 12px; font-weight: 750; }
.timeline-title { margin-top: 3px; color: var(--navy); font-weight: 700; }
.timeline-detail { margin-top: 3px; color: var(--muted); font-size: 12px; }
.visit-tomorrow-label { margin-bottom: 4px; color: var(--blue); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.visit-confirm-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 11px; }
.visit-confirm-actions button { min-width: 0; min-height: 42px; white-space: normal; line-height: 1.2; }
.sync-state { min-height: 22px; margin: 6px 0 10px; }
.calendar-conflicts { display: grid; gap: 10px; margin-bottom: 14px; }
.calendar-conflict { border-left: 4px solid #d98f16; background: #fff8e8; padding: 12px; }
.calendar-conflict h3 { margin: 0 0 6px; font-size: 1rem; }
.calendar-conflict-times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.calendar-conflict-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.calendar-conflict-edit { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 9px; }
.timeline-item.calendar-event { border-left: 4px solid #667085; }
.timeline-item.visit-confirmed { border-left: 4px solid #218739; }
.timeline-item.visit-pending { border-left: 4px solid #d98f16; }
.timeline-item.visit-conflict { border-left: 4px solid #c43d3d; background: #fff7f7; }
.status-label { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 7px; border: 1px solid var(--line); background: #f5f7fa; font-size: .78rem; font-weight: 700; }
.recommendation-result { margin-top: 12px; padding: 12px; border: 1px solid var(--line); background: #f7f9fc; }
.recommendation-result ul { margin: 7px 0 10px; padding-left: 20px; }
@media (max-width: 560px) {
  .calendar-conflict-times, .calendar-conflict-edit { grid-template-columns: 1fr; }
  [data-view="agenda"] .section-heading { align-items: flex-start; flex-wrap: wrap; }
  [data-view="agenda"] .heading-actions { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .72fr) 40px; }
  [data-view="agenda"] .heading-actions .secondary-button { min-width: 0; white-space: normal; }
}
.replacement-options { display: grid; gap: 8px; margin: 0 0 18px; padding: 16px; border: 1px solid #a9d5bb; background: var(--soft-green); }
.replacement-options h2 { margin: 0 0 4px; color: var(--navy); font-size: 17px; }

.route-command { display: grid; gap: 16px; margin: 0 -16px; padding: 20px 16px; background: var(--soft-blue); border-top: 1px solid #b9deed; border-bottom: 1px solid #b9deed; }
.route-command p { margin: 7px 0 0; color: #365b6d; font-size: 13px; line-height: 1.45; }
.primary-button { min-height: 42px; padding: 10px 14px; border: 1px solid var(--blue); border-radius: 6px; color: #fff; background: var(--blue); font-weight: 750; }
.primary-button:disabled { cursor: wait; opacity: 0.62; }
.full-button { width: 100%; margin-top: 8px; }
.plan-summary { padding: 18px 0; border-bottom: 1px solid var(--line); }
.plan-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.plan-kpis div { min-width: 0; padding: 10px; background: #f0f3f6; border: 1px solid var(--line); border-radius: 5px; }
.plan-kpis small { display: block; color: var(--muted); font-size: 10px; }
.plan-kpis strong { display: block; margin-top: 3px; color: var(--navy); font-size: 16px; overflow-wrap: anywhere; }
.plan-actions { display: flex; gap: 8px; margin-top: 14px; }
.route-opportunity-button { width: 100%; margin-top: 12px; }
.route-opportunities { display: grid; gap: 10px; padding-top: 18px; }
.route-opportunities:empty { display: none; }
.route-opportunities h2 { margin: 0 0 4px; color: var(--navy); font-size: 18px; }
.route-opportunity-card .primary-button { width: 100%; margin-top: 12px; }
.success-state { padding: 12px; color: #0f5e38; background: var(--soft-green); border: 1px solid #a9d5bb; border-radius: 6px; }
.route-days { display: grid; gap: 0; }
.route-day { padding: 18px 0; border-bottom: 1px solid var(--line); }
.route-day h3 { margin: 0; color: var(--navy); font-size: 16px; }
.route-day > p { margin: 5px 0 12px; color: var(--muted); font-size: 12px; }
.route-stop { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 10px; padding: 9px 0; }
.route-stop time { color: var(--blue); font-size: 12px; font-weight: 750; }
.route-stop strong { display: block; font-size: 13px; }
.route-stop small { display: block; margin-top: 3px; color: var(--muted); }

.search-bar { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 7px; margin-bottom: 16px; }
.search-bar input, .dialog input, .dialog textarea, .dialog select { width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid #bfcbd5; border-radius: 5px; color: var(--ink); background: #fff; }

.menu-groups { display: grid; gap: 28px; }
.menu-groups section { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.menu-groups h2, .settings-form h2, .integration-band h2, #connect-preview h2 { margin: 0 0 12px; color: var(--navy); font-size: 17px; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.menu-grid button { min-width: 0; min-height: 104px; display: grid; align-content: center; justify-items: start; gap: 3px; padding: 14px; border: 1px solid var(--line); border-left: 4px solid var(--cyan); border-radius: 6px; color: var(--ink); background: #fff; text-align: left; }
.menu-grid button span { color: var(--blue); font-size: 22px; line-height: 1; }
.menu-grid button strong { color: var(--navy); font-size: 14px; }
.menu-grid button small { max-width: 100%; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }

.route-builder { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 10px; align-items: end; margin-bottom: 14px; }
.route-builder label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.route-builder label:nth-of-type(2), .route-builder .primary-button { grid-column: 1 / -1; }
.route-builder select, .settings-form input, .settings-form select, .mapping-grid select { width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid #bfcbd5; border-radius: 5px; color: var(--ink); background: #fff; }
.map-summary { min-height: 46px; padding: 13px 0; color: var(--navy); font-weight: 750; }
.route-map { width: 100%; height: auto; aspect-ratio: 900 / 470; display: block; border: 1px solid #cad7df; border-radius: 6px; background: #edf3f6; }
.secondary-link { display: inline-block; margin-top: 12px; color: var(--blue); font-weight: 700; }

.source-strip, .card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.card-actions { margin: 14px 0 0; }
.card-actions .primary-button, .card-actions .secondary-button { min-height: 38px; }
.dashboard-grid, .quality-band { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.dashboard-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.dashboard-filters label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.dashboard-filters select { width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid #bfcbd5; border-radius: 5px; color: var(--ink); background: #fff; }
.dashboard-filters button { grid-column: 1 / -1; }
.dashboard-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.dashboard-section h2 { margin: 0 0 12px; color: var(--navy); font-size: 18px; }
details.dashboard-section summary { color: var(--navy); cursor: pointer; font-size: 17px; font-weight: 750; }
.dashboard-progress {
  width: 100%; height: 10px; margin-top: 12px; overflow: hidden;
  appearance: none; border: 0; border-radius: 5px; background: #dce6ee;
}
.dashboard-progress::-webkit-progress-bar { border-radius: 5px; background: #dce6ee; }
.dashboard-progress::-webkit-progress-value { border-radius: 5px; background: var(--blue); }
.dashboard-progress::-moz-progress-bar { border-radius: 5px; background: var(--blue); }
.compact-row { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.compact-row strong, .compact-row span { min-width: 0; overflow-wrap: anywhere; }
.compact-row span { color: var(--muted); font-size: 12px; text-align: left; }
.compact-row .text-button { grid-column: 1 / -1; justify-self: start; }
.status-label { color: var(--blue) !important; font-weight: 750; }
.metric-tile, .quality-band > div { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.metric-tile small, .quality-band small { display: block; color: var(--muted); font-size: 10px; text-transform: capitalize; }
.metric-tile strong, .quality-band strong { display: block; margin-top: 5px; color: var(--navy); font-size: 22px; overflow-wrap: anywhere; }
.quality-band { margin: 0 -16px 22px; padding: 18px 16px; background: var(--navy-soft); }
.quality-band > div { border-color: #3a4d64; background: #102238; }
.quality-band small { color: #b8c7d6; }
.quality-band strong { color: #fff; }
.settings-form { display: grid; gap: 16px; }
.commercial-settings { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.settings-form > label, .form-grid label, .mapping-grid label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.form-grid, .mapping-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-form fieldset { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
.settings-form legend { padding: 0 6px; color: var(--navy); font-size: 13px; font-weight: 750; }
.day-options { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.check-line { display: inline-flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 6px; color: var(--ink) !important; }
.check-line input { width: 18px !important; min-height: 18px !important; }
.integration-band { display: flex; justify-content: space-between; gap: 12px; margin: 24px -16px 0; padding: 20px 16px; background: var(--soft-blue); border-top: 1px solid #b9deed; border-bottom: 1px solid #b9deed; }
.integration-band { align-items: center; }
.message-template-form { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.settings-form textarea { width: 100%; padding: 10px; border: 1px solid #bfcbd5; border-radius: 5px; resize: vertical; }
.pending-center { margin: 0 0 24px; border-bottom: 1px solid var(--line); }
.pending-center h2 { margin: 0 0 10px; color: var(--navy); font-size: 17px; }
.pending-row { width: 100%; min-height: 48px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 11px 0; border: 0; border-top: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
.pending-row strong { min-width: 34px; padding: 4px 7px; border-radius: 4px; color: #fff; background: var(--navy); text-align: center; }
.pending-contact-form { display: grid; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.pending-contact-form label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.pending-contact-form input { width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid #bfcbd5; border-radius: 5px; }
.pending-actions, .profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pending-actions button, .profile-actions > * { flex: 1 1 130px; min-height: 44px; text-align: center; text-decoration: none; }
.dialog-actions, .contact-result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.dialog-actions > *, .contact-result-actions > * { min-width: 0; min-height: 44px; display: inline-grid; place-items: center; white-space: normal; text-align: center; text-decoration: none; }
.danger-button { padding: 10px 14px; border: 1px solid var(--red); border-radius: 6px; color: #8a1f1f; background: #fff0f0; font-weight: 750; }
#connect-preview { display: grid; gap: 14px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.external-connectors { display: grid; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.connector-form { display: grid; gap: 9px; }
.connector-form label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.connector-form input { width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid #bfcbd5; border-radius: 5px; }

.bottom-nav { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; height: calc(66px + var(--safe-bottom)); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 4px 4px var(--safe-bottom); background: #fff; border-top: 1px solid #cbd5de; box-shadow: 0 -3px 12px rgba(7, 20, 38, 0.09); }
.bottom-nav button { min-width: 0; height: 58px; display: grid; place-content: center; gap: 3px; border: 0; color: #657282; background: transparent; }
.bottom-nav span { font-size: 20px; line-height: 1; }
.bottom-nav small { max-width: 100%; overflow: hidden; font-size: 9px; text-overflow: ellipsis; }
.bottom-nav button.active { color: var(--blue); box-shadow: inset 0 3px 0 var(--cyan); font-weight: 800; }

.dialog { width: min(92vw, 520px); max-height: 84vh; padding: 0; border: 1px solid #b8c4ce; border-radius: 7px; color: var(--ink); background: #fff; }
.dialog::backdrop { background: rgba(7, 20, 38, 0.62); }
.dialog > div, .dialog > form { padding: 18px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.dialog label { display: grid; gap: 6px; margin: 12px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.client-form-dialog form { overflow-y: auto; max-height: 84vh; }
.client-form-dialog .form-grid { grid-template-columns: 1fr; }
.client-form-dialog fieldset { min-width: 0; margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.client-form-dialog legend { padding: 0 6px; color: var(--navy); font-size: 13px; font-weight: 750; }
.product-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.duplicate-warning { margin: 14px 0; padding: 13px; color: #553300; background: var(--soft-amber); border: 1px solid #e8c675; border-radius: 6px; }
.duplicate-warning > strong { display: block; margin-bottom: 8px; text-transform: uppercase; }
.duplicate-item { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid #e8c675; }
.text-button { padding: 5px 0; border: 0; color: var(--blue); background: transparent; font-weight: 700; }
.auth-dialog .support-copy { margin: 12px 0; }
.account-security { display: grid; gap: 14px; margin-top: 18px; }
.session-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.session-row strong, .session-row small { display: block; }
.session-row small { margin-top: 3px; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.detail-grid div { min-width: 0; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.detail-grid small { display: block; color: var(--muted); }
.detail-grid strong { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.history-list { display: grid; gap: 8px; margin: 14px 0; }
.history-item { padding: 9px; background: #f1f4f6; border-radius: 5px; font-size: 12px; }
.toast { position: fixed; z-index: 60; right: 16px; bottom: calc(82px + var(--safe-bottom)); left: 16px; max-width: 500px; margin: auto; padding: 12px 14px; color: #fff; background: var(--navy); border: 1px solid #41536a; border-radius: 6px; box-shadow: 0 8px 28px rgba(7, 20, 38, 0.25); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 720px) {
  .app-shell { padding-bottom: 82px; }
  .topbar { padding-right: max(24px, calc((100vw - 960px) / 2)); padding-left: max(24px, calc((100vw - 960px) / 2)); }
  main { max-width: 960px; }
  .view { padding: 30px 24px 42px; }
  .morning-band, .route-command { margin-right: -24px; margin-left: -24px; padding-right: 24px; padding-left: 24px; }
  .morning-band { grid-template-columns: minmax(0, 1.25fr) minmax(350px, 0.75fr); align-items: center; }
  .route-command { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .item-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .menu-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .route-builder { grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr) auto; }
  .route-builder label:nth-of-type(2), .route-builder .primary-button { grid-column: auto; }
  .dashboard-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #dashboard-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .dashboard-filters { grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: end; }
  .dashboard-filters button { grid-column: auto; }
  .compact-row { grid-template-columns: minmax(0, 1fr) auto; }
  .compact-row span { text-align: right; }
  .external-connectors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quality-band { margin-right: -24px; margin-left: -24px; padding-right: 24px; padding-left: 24px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bottom-nav { right: 50%; left: auto; width: min(620px, 100%); transform: translateX(50%); border-right: 1px solid #cbd5de; border-left: 1px solid #cbd5de; }
  .toast { bottom: 94px; }
  .user-summary { display: block; }
  .client-form-dialog .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .app-shell[data-experience="desk"] { padding-bottom: 0; }
  .app-shell[data-experience="desk"] .desk-sidebar {
    position: fixed; z-index: 15; top: 67px; bottom: 0; left: 0; width: 210px;
    display: block; overflow-y: auto; padding: 22px 14px; color: #fff; background: var(--navy);
    border-right: 1px solid #243b56;
  }
  .desk-sidebar > div { display: grid; gap: 3px; margin-bottom: 22px; }
  .desk-sidebar small { margin: 0 8px 7px; color: #8fa4b9; font-size: 10px; font-weight: 800; }
  .desk-sidebar button { min-height: 38px; padding: 8px 10px; border: 0; border-radius: 5px; color: #dbe6ef; background: transparent; text-align: left; }
  .desk-sidebar button.active { color: #fff; background: #0b659b; box-shadow: inset 3px 0 0 var(--cyan); }
  .app-shell[data-experience="desk"] #main-content { margin-left: 210px; width: calc(100% - 210px); }
  .app-shell[data-experience="desk"] .bottom-nav { display: none; }
  .app-shell[data-experience="desk"] .topbar { padding-left: 24px; }
  .app-shell[data-experience="desk"] .view { min-height: calc(100vh - 67px); }
}

@media (max-width: 430px) {
  .mode-button { max-width: 78px; white-space: normal; line-height: 1.05; }
  .status-dot { font-size: 0; }
  .field-route-actions { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; }
  #refresh-field-package { max-width: 130px; white-space: normal; }
}

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