:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #e9eef2;
  --text: #18232d;
  --muted: #687987;
  --border: #d4dde4;
  --primary: #1264a3;
  --primary-strong: #0b4777;
  --accent: #e76f23;
  --success: #197451;
  --danger: #b9353b;
  --warning: #9b6400;
  --shadow: 0 12px 32px rgba(21, 38, 52, 0.1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12171b;
  --surface: #1c2329;
  --surface-2: #273139;
  --text: #eef3f6;
  --muted: #a8b5bf;
  --border: #3a4650;
  --primary: #63a9dd;
  --primary-strong: #9fcdf0;
  --accent: #ff9b5a;
  --success: #61c79b;
  --danger: #ff8287;
  --warning: #f4c15d;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
/* Disable double-tap zoom throughout the page while preserving scrolling and pinch zoom. */
html { background: var(--bg); color: var(--text); touch-action: manipulation; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", Arial, sans-serif; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
a { color: var(--primary); }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: 30px; line-height: 1.2; }
h2 { margin: 0; font-size: 20px; line-height: 1.3; }

.topbar { position: fixed; z-index: 80; top: 0; right: 0; left: 0; display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 344px 0 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { color: var(--text); font-size: 19px; font-weight: 800; text-decoration: none; }
.brand span { color: var(--accent); font-weight: 650; }
.account { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.account form { margin: 0; }
.sidebar { position: fixed; z-index: 70; top: 64px; bottom: 0; left: 0; display: flex; width: 220px; flex-direction: column; gap: 5px; padding: 20px 12px; border-right: 1px solid var(--border); background: var(--surface); }
.sidebar a { padding: 11px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.sidebar a:hover, .sidebar a[aria-current="page"] { background: var(--surface-2); color: var(--primary-strong); }
.app-main { width: min(1440px, calc(100% - 220px)); min-height: 100vh; margin-left: 220px; padding: 92px 28px 40px; }
.guest-main { min-height: 100vh; padding: 88px 24px 72px; }

.theme-control { position: fixed; z-index: 100; top: 12px; right: 12px; display: grid; grid-template-columns: repeat(3, 1fr); width: 314px; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.theme-control button { min-height: 36px; padding: 0 8px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.theme-control button[aria-pressed="true"] { background: var(--primary); color: #fff; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 15px; border: 1px solid var(--primary); border-radius: 6px; background: var(--primary); color: #fff; font-weight: 650; text-decoration: none; cursor: pointer; }
.secondary-button { border-color: var(--border); background: var(--surface); color: var(--text); }
/* Text actions grow with their labels, including inside narrow cards and tables. */
:is(.primary-button, .secondary-button, .danger-button, .qr-camera-button, .qr-image-button) { min-width: 0; max-width: 100%; height: auto; white-space: normal; overflow-wrap: anywhere; }
:is(.primary-button, .secondary-button, .danger-button, .qr-camera-button, .qr-image-button) > span { min-width: 0; }
.icon-button { display: inline-grid; width: 40px; height: 40px; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; }
.wide-button { width: 100%; }

.alert { max-width: 960px; margin: 0 auto 16px; padding: 12px 14px; border: 1px solid; border-radius: 7px; background: var(--surface); }
.alert-error { border-color: var(--danger); color: var(--danger); }
.alert-success { border-color: var(--success); color: var(--success); }

.role-entry { width: min(1080px, 100%); margin: 0 auto; }
.role-entry-copy { max-width: 650px; margin-bottom: 32px; }
.role-entry-copy h1 { font-size: 42px; }
.role-entry-copy p:last-child { color: var(--muted); font-size: 18px; }
.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.role-option { min-height: 230px; padding: 24px; border: 1px solid var(--border); border-top: 5px solid var(--primary); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: transform .18s ease, border-color .18s ease; }
.role-option:hover { transform: translateY(-3px); border-color: var(--primary); }
.role-driver { border-top-color: var(--success); }
.role-admin { border-top-color: var(--accent); }
.role-option strong { display: block; margin: 52px 0 6px; font-size: 23px; }
.role-option > span:last-child { color: var(--muted); }
.role-number { color: var(--muted); font-size: 13px; font-weight: 700; }
.public-qr-link { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 14px; padding: 17px 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; }
.public-qr-link:hover { border-color: var(--primary); }
.public-qr-link span { color: var(--muted); }

.landing-body { background: #f4f8fd; }
.landing-body .guest-main { min-height: 0; padding: 0; }
.landing-body > .theme-control { display: none; }
.landing-page { min-height: 100vh; background: #f4f8fd; color: #112642; }
.public-header { position: sticky; z-index: 90; top: 0; min-height: 90px; background: #0757a1; color: #fff; }
.public-header-inner { display: grid; grid-template-columns: minmax(250px, .9fr) minmax(430px, 1.25fr) auto; align-items: center; gap: 28px; width: min(1380px, calc(100% - 48px)); min-height: 90px; margin: 0 auto; }
.public-brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.public-brand img { width: 54px; height: 54px; border-radius: 8px; }
.public-brand span { display: grid; line-height: 1.1; }
.public-brand strong { font-size: 23px; font-style: italic; }
.public-brand small { margin-top: 6px; font-size: 10px; font-weight: 500; }
.public-nav { display: flex; align-items: center; justify-content: center; gap: 34px; }
.public-nav a { color: #fff; font-weight: 650; text-decoration: none; white-space: nowrap; }
.public-nav a:hover { text-decoration: underline; text-underline-offset: 5px; }
.public-admin-link { opacity: .78; }
.mobile-theme { display: none; }
.public-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 22px; }
.support-link { padding: 10px 14px; border: 1px solid rgba(255, 255, 255, .28); border-radius: 7px; color: #fff; font-weight: 650; text-decoration: none; white-space: nowrap; }
.public-clock { display: grid; min-width: 84px; padding-left: 16px; border-left: 1px solid rgba(255, 255, 255, .28); line-height: 1.15; }
.public-clock strong { font-size: 16px; }
.public-clock span { margin-top: 4px; font-size: 11px; opacity: .82; white-space: nowrap; }
.public-menu-toggle { display: none; width: 48px; height: 48px; place-content: center; gap: 5px; border: 1px solid rgba(255, 255, 255, .3); border-radius: 7px; background: transparent; cursor: pointer; }
.public-menu-toggle span { display: block; width: 22px; height: 2px; background: #fff; }
.landing-content { width: min(1300px, calc(100% - 48px)); margin: 0 auto; padding: 38px 0 34px; }
.landing-hero { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(380px, .75fr); gap: 46px; min-height: 470px; padding: 48px; background: #fff url("/assets/portal-fleet-hero.webp") center / cover no-repeat; box-shadow: 0 16px 42px rgba(25, 74, 122, .12); }
.landing-intro { display: flex; min-width: 0; flex-direction: column; justify-content: space-between; padding: 8px 0; }
.landing-intro h1 { max-width: 600px; color: #142b48; font-size: 42px; line-height: 1.14; }
.landing-intro h1 span { display: block; margin-top: 4px; color: #0868d2; }
.landing-intro > p { max-width: 500px; margin: 24px 0 auto; color: #4e6380; font-size: 18px; }
.landing-features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; max-width: 630px; }
.landing-features > div { display: flex; align-items: center; gap: 16px; min-width: 0; padding: 9px; border-radius: 8px; background: rgba(255, 255, 255, .78); }
.feature-mark { display: grid; width: 60px; height: 60px; flex: 0 0 60px; place-items: center; border: 1px solid #acd0f9; border-radius: 8px; background: rgba(255, 255, 255, .9); color: #0870df; font-size: 30px; font-weight: 800; }
.landing-features p, .landing-role span, .landing-advantages p, .landing-help p { display: grid; min-width: 0; margin: 0; }
.landing-features strong { font-size: 15px; }
.landing-features small { margin-top: 4px; color: #4e6380; font-size: 13px; }
.landing-qr { align-self: center; padding: 28px; border: 1px solid #dbe5f0; border-radius: 8px; background: rgba(255, 255, 255, .97); box-shadow: 0 10px 28px rgba(25, 74, 122, .1); }
.landing-qr h2 { margin-bottom: 20px; color: #112642; text-align: center; }
.qr-launch-panel { display: grid; gap: 20px; padding: 25px 16px 16px; border: 1px solid #a9cdf7; border-radius: 7px; background: #f4f8fd; }
.qr-device-mark { position: relative; display: grid; width: 58px; height: 78px; margin: 0 auto; place-items: center; border: 3px solid #0870df; border-radius: 8px; color: #0870df; font-weight: 800; }
.qr-device-mark::after { position: absolute; bottom: 6px; width: 20px; height: 3px; border-radius: 2px; background: #0870df; content: ""; }
.qr-camera-button, .qr-image-button { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 15px; border: 1px solid #0870df; border-radius: 6px; font-weight: 700; text-align: center; text-decoration: none; }
.qr-camera-button { background: #0870df; color: #fff; }
.qr-image-button { color: #0870df; }
.qr-camera-button span, .qr-image-button span { margin-right: 8px; font-size: 19px; }
.qr-divider { position: relative; margin: 18px 0; border-top: 1px solid #d9e2ed; text-align: center; }
.qr-divider span { position: relative; top: -11px; padding: 0 14px; background: #fff; color: #62738a; }
.landing-roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 28px; }
.landing-role { display: grid; grid-template-columns: 72px minmax(0, 1fr) 46px; align-items: center; gap: 18px; min-height: 118px; padding: 22px 28px; border: 1px solid; border-radius: 8px; text-decoration: none; }
.landing-role-master { border-color: #bdd8f7; background: #edf5ff; color: #0867c9; }
.landing-role-driver { border-color: #c5e9d0; background: #edf9f1; color: #079447; }
.role-avatar { display: grid; width: 62px; height: 62px; place-items: center; border: 2px solid currentColor; border-radius: 50%; font-size: 24px; font-weight: 800; }
.landing-role strong { font-size: 20px; }
.landing-role small { max-width: 340px; margin-top: 4px; color: #30445e; font-size: 13px; }
.landing-role b { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: #fff; font-size: 32px; font-weight: 400; }
.landing-advantages { padding: 34px 0 8px; }
.landing-advantages h2 { margin-bottom: 24px; text-align: center; }
.landing-advantages > div { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 22px; }
.landing-advantages article { display: flex; align-items: center; gap: 13px; min-width: 0; }
.landing-advantages article > span { display: grid; width: 48px; height: 48px; flex: 0 0 48px; place-items: center; border: 1px solid #c9def7; border-radius: 8px; color: #0870df; font-weight: 800; }
.landing-advantages small { margin-top: 2px; color: #52657e; font-size: 12px; }
.landing-help { display: none; }
.landing-anchor { display: block; scroll-margin-top: 110px; }
.public-footer { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; min-height: 88px; padding: 18px max(28px, calc((100vw - 1300px) / 2)); background: #0757a1; color: #fff; font-size: 12px; }
.public-footer nav { display: flex; gap: 38px; }
.public-footer a { color: #fff; text-decoration: none; }
.footer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 18px; }
.footer-theme { display: flex; gap: 2px; padding: 3px; border: 1px solid rgba(255, 255, 255, .3); border-radius: 6px; }
.footer-theme button { min-height: 28px; padding: 2px 7px; border: 0; border-radius: 4px; background: transparent; color: #fff; font-size: 11px; cursor: pointer; }
.footer-theme button[aria-pressed="true"] { background: #fff; color: #0757a1; }
.landing-mobile-nav { display: none; }

:root[data-theme="dark"] .landing-page { background: #101820; color: var(--text); }
:root[data-theme="dark"] .landing-body { background: #101820; }
:root[data-theme="dark"] .landing-hero { background-color: #17232d; background-blend-mode: soft-light; }
:root[data-theme="dark"] .landing-intro h1, :root[data-theme="dark"] .landing-qr h2 { color: #f2f7fb; }
:root[data-theme="dark"] .landing-intro > p, :root[data-theme="dark"] .landing-features small { color: #c0ced9; }
:root[data-theme="dark"] .landing-qr, :root[data-theme="dark"] .qr-divider span { background: #1c2832; }
:root[data-theme="dark"] .qr-launch-panel { background: #17232d; }
:root[data-theme="dark"] .landing-role-master, :root[data-theme="dark"] .landing-role-driver { background: #17232d; }
:root[data-theme="dark"] .landing-role small, :root[data-theme="dark"] .landing-advantages small { color: #bdcad5; }
:root[data-theme="dark"] .landing-features > div { background: rgba(16, 24, 32, .78); }

@media (max-width: 1180px) {
  .public-header-inner { grid-template-columns: 1fr auto; }
  .public-menu-toggle { display: grid; }
  .public-nav { position: absolute; top: 90px; right: 24px; display: none; width: min(340px, calc(100vw - 48px)); align-items: stretch; flex-direction: column; gap: 2px; padding: 12px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 0 0 8px 8px; background: #0757a1; box-shadow: 0 18px 32px rgba(10, 32, 55, .24); }
  .public-nav.is-open { display: flex; }
  .public-nav a { padding: 10px 12px; }
  .public-header-actions { grid-column: 2; grid-row: 1; }
  .landing-hero { grid-template-columns: minmax(0, 1.2fr) minmax(350px, .8fr); gap: 26px; padding: 36px; }
  .landing-advantages > div { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .public-footer { grid-template-columns: 1fr 1fr; }
  .public-footer nav { display: none; }
}

.public-qr { width: min(680px, 100%); margin: 0 auto; }
.public-qr-heading { margin-bottom: 24px; }
.public-qr-heading > p:last-child { color: var(--muted); }
.qr-lookup { display: grid; gap: 14px; padding: 22px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.field-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.qr-result { margin-top: 16px; padding: 22px; border: 1px solid var(--success); border-radius: 8px; background: var(--surface); }
.qr-result dl { margin: 16px 0 0; }
.qr-result dl > div { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.qr-result dl > div:last-child { border-bottom: 0; }
.qr-result dt { color: var(--muted); }
.qr-result dd { margin: 0; font-weight: 650; }
.text-link { display: inline-block; margin-top: 20px; }
.error-page { display: grid; grid-template-columns: minmax(180px, .65fr) minmax(280px, 1fr); align-items: center; gap: 36px; width: min(820px, 100%); min-height: calc(100vh - 180px); margin: 0 auto; }
.error-code { color: var(--surface-2); font-size: 150px; font-weight: 800; line-height: 1; text-align: right; }
.error-page h1 { font-size: 34px; }
.error-page p:not(.eyebrow) { max-width: 520px; color: var(--muted); }
.error-actions { display: flex; gap: 10px; margin-top: 22px; }

.auth-shell { width: min(480px, 100%); margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: 18px; text-decoration: none; }
.auth-panel { padding: 28px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.auth-panel > p:not(.eyebrow) { color: var(--muted); }
.auth-panel form, .wizard-step { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 6px; outline: none; background: var(--surface); color: var(--text); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metrics article { min-height: 112px; padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.metrics span { color: var(--muted); }
.metrics strong { display: block; margin-top: 8px; font-size: 29px; }
.content-section { margin-top: 16px; padding: 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); }
.empty-state, .empty-page { padding: 48px 20px; text-align: center; color: var(--muted); }

.order-list { display: grid; gap: 10px; }
.order-card { display: block; padding: 16px; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 7px; background: var(--surface); color: var(--text); text-decoration: none; }
.order-card:hover { border-color: var(--primary); }
.order-card-top, .order-meta, .route-line { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.route-line { justify-content: flex-start; margin: 14px 0; }
.route-line span { flex: 1; }
.route-line b { color: var(--accent); }
.order-meta { justify-content: flex-start; color: var(--muted); font-size: 13px; }
.stage { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.stage-in_transit, .stage-accepted, .stage-arrived { border-color: var(--primary); color: var(--primary-strong); }
.stage-delivered, .stage-closed { border-color: var(--success); color: var(--success); }
.stage-cancelled { border-color: var(--danger); color: var(--danger); }
.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) 230px; gap: 10px; margin-bottom: 14px; }

.wizard { max-width: 980px; padding: 22px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.wizard-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 24px; padding: 0; list-style: none; counter-reset: steps; }
.wizard-progress li { padding: 10px; border-bottom: 3px solid var(--border); color: var(--muted); font-size: 13px; }
.wizard-progress li.active { border-color: var(--primary); color: var(--primary-strong); }
.wizard-step { display: none; min-height: 320px; align-content: start; }
.wizard-step.active { display: grid; }
.wizard-step > p { margin: 0; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.wizard-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.cargo-row { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(160px, 1fr) 40px 40px; gap: 8px; align-items: end; margin-bottom: 10px; }
.form-note { padding: 12px; border-left: 3px solid var(--accent); background: var(--surface-2); }
.review-block { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }

.scanner-dialog { width: min(560px, calc(100vw - 24px)); padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.scanner-dialog::backdrop { background: rgba(0, 0, 0, .58); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.camera-choice { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 12px; padding: 3px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.camera-choice button { min-height: 38px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.camera-choice button[aria-pressed="true"] { background: var(--surface); color: var(--primary-strong); box-shadow: var(--shadow); }
#qr-reader { min-height: 240px; margin-bottom: 12px; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; }
.scanner-status { min-height: 22px; margin: 0 0 12px; color: var(--muted); }
.scanner-status[data-state="error"] { color: var(--danger); }
.scanner-status[data-state="success"] { color: var(--success); }
.scanner-file { display: grid; gap: 7px; margin-bottom: 12px; font-weight: 700; }
.scanner-file input { width: 100%; padding: 10px; border: 1px dashed var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); }

.order-detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr); gap: 16px; }
.order-detail-grid .content-section { margin-top: 0; }
.order-summary dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px 18px; margin: 16px 0 0; }
.order-summary dt { color: var(--muted); }
.order-summary dd { margin: 0; }
.timeline { margin: 18px 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: 8px; min-height: 38px; color: var(--muted); }
.timeline li span { width: 12px; height: 12px; margin-top: 4px; border: 2px solid var(--border); border-radius: 50%; background: var(--surface); }
.timeline li::after { position: absolute; top: 17px; bottom: -3px; left: 5px; width: 2px; background: var(--border); content: ""; }
.timeline li:last-child::after { display: none; }
.timeline li.reached { color: var(--text); }
.timeline li.reached span { border-color: var(--success); background: var(--success); }
.timeline li.current strong { color: var(--primary-strong); }
.assignment-form { display: grid; gap: 10px; margin-top: 16px; }
.edit-details summary { color: var(--primary-strong); font-weight: 700; cursor: pointer; }
.route-edit-form { display: grid; gap: 14px; margin-top: 18px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 16px; padding: 18px 20px; border: 1px solid var(--danger); border-radius: 8px; background: var(--surface); }
.danger-zone > div { display: grid; gap: 3px; }
.danger-zone span { color: var(--muted); }
.danger-button { min-height: 42px; padding: 9px 15px; border: 1px solid var(--danger); border-radius: 6px; background: transparent; color: var(--danger); font-weight: 700; cursor: pointer; }
.cargo-list, .history-list { display: grid; gap: 8px; margin-top: 14px; }
.cargo-item { display: grid; grid-template-columns: 1.4fr 1fr auto; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 7px; }
.cargo-item > div { display: grid; gap: 3px; }
.cargo-item span { color: var(--muted); font-size: 13px; }
.cargo-item.verified { border-color: var(--success); }
.verified-mark { color: var(--success) !important; font-weight: 700; }
.history-list > div { display: grid; grid-template-columns: 150px 170px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.history-list time, .history-list span { color: var(--muted); }

.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.mobile-nav { display: none; }
.admin-users-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .6fr); gap: 16px; }
.admin-users-layout .content-section { margin-top: 0; }
.admin-create form { display: grid; gap: 13px; margin-top: 16px; }

@media (max-width: 980px) {
  .topbar { padding: 0 16px; }
  .account { margin-right: 330px; }
  .sidebar { position: fixed; top: auto; right: 0; bottom: 0; width: auto; height: 62px; flex-direction: row; justify-content: center; padding: 6px; border-top: 1px solid var(--border); border-right: 0; }
  .sidebar a { display: flex; align-items: center; }
  .app-main { width: 100%; margin-left: 0; padding: 92px 18px 82px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .order-detail-grid { grid-template-columns: 1fr; }
  .admin-users-layout { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  h1 { font-size: 25px; }
  .topbar { height: 58px; padding-right: 58px; }
  .account span { display: none; }
  .account { margin-right: 0; }
  .sidebar { display: none; }
  .mobile-nav { position: fixed; z-index: 85; right: 0; bottom: 0; left: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; min-height: 58px; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--border); background: var(--surface); }
  .mobile-nav a { display: grid; place-items: center; color: var(--muted); font-size: 12px; text-decoration: none; }
  .theme-control { top: auto; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); width: calc(100vw - 16px); }
  .guest-main { padding: 32px 14px 74px; }
  .app-main { padding: 78px 12px calc(138px + env(safe-area-inset-bottom)); }
  .role-entry-copy h1 { font-size: 34px; }
  .role-grid, .form-grid, .filter-bar { grid-template-columns: 1fr; }
  .public-qr-link { align-items: flex-start; flex-direction: column; }
  .field-action { grid-template-columns: 1fr; }
  .qr-result dl > div { grid-template-columns: 1fr; gap: 3px; }
  .error-page { grid-template-columns: 1fr; align-content: center; gap: 14px; min-height: calc(100vh - 150px); }
  .error-code { font-size: 92px; text-align: left; }
  .error-page h1 { font-size: 27px; }
  .role-option { min-height: 150px; }
  .role-option strong { margin-top: 24px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading .primary-button { width: 100%; }
  .content-section, .wizard, .auth-panel { padding: 16px; }
  .wizard-progress { gap: 3px; }
  .wizard-progress li { padding: 7px 3px; font-size: 11px; text-align: center; }
  .cargo-row { grid-template-columns: 1fr 40px 40px; }
  .cargo-row label:first-child { grid-column: 1 / -1; }
  .cargo-row label:nth-child(2) { grid-column: 1; }
  .route-line { display: grid; grid-template-columns: 1fr; }
  .route-line b { transform: rotate(90deg); }
  .order-card-top { align-items: flex-start; }
  .order-summary dl { grid-template-columns: 1fr; gap: 3px; }
  .order-summary dd { margin-bottom: 10px; }
  .cargo-item { grid-template-columns: 1fr; }
  .history-list > div { grid-template-columns: 1fr; gap: 3px; }
  .danger-zone { align-items: stretch; flex-direction: column; }
  .danger-button { width: 100%; }
  .table-section { padding: 8px; }
  .responsive-table { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { padding: 10px; border-bottom: 1px solid var(--border); }
  td { display: grid; grid-template-columns: 120px 1fr; gap: 8px; padding: 5px 0; border: 0; white-space: normal; }
  td::before { color: var(--muted); content: attr(data-label); }
  .landing-body .guest-main { padding: 0; }
  .public-header { min-height: 116px; }
  .public-header-inner { width: calc(100% - 36px); min-height: 116px; }
  .public-brand img { width: 48px; height: 48px; }
  .public-brand strong { font-size: 20px; }
  .public-brand small { font-size: 9px; }
  .public-header-actions { gap: 0; }
  .support-link, .public-clock { display: none; }
  .public-menu-toggle { width: 52px; height: 52px; }
  .public-nav { top: 116px; right: 18px; width: calc(100vw - 36px); }
  .mobile-theme { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin-top: 8px; padding: 4px; border: 1px solid rgba(255, 255, 255, .25); border-radius: 6px; }
  .mobile-theme button { min-height: 36px; border: 0; border-radius: 4px; background: transparent; color: #fff; font-size: 12px; }
  .mobile-theme button[aria-pressed="true"] { background: #fff; color: #0757a1; }
  .landing-content { width: calc(100% - 24px); padding: 22px 0 20px; }
  .landing-hero { display: block; min-height: 0; padding: 0; background: none; box-shadow: none; }
  .landing-intro { min-height: 470px; padding: 34px 28px; border-radius: 8px; background: #fff url("/assets/portal-fleet-hero.webp") 45% center / cover no-repeat; box-shadow: 0 12px 30px rgba(25, 74, 122, .1); }
  .landing-intro h1 { max-width: 420px; font-size: 34px; }
  .landing-intro > p { margin: 20px 0 auto; font-size: 17px; }
  .landing-features { gap: 14px; }
  .landing-features > div { align-items: center; flex-direction: column; gap: 10px; text-align: center; }
  .feature-mark { width: 56px; height: 56px; flex-basis: 56px; }
  .landing-features small { font-size: 12px; }
  .landing-qr { margin-top: 16px; padding: 26px 20px; }
  .qr-camera-button { min-height: 56px; }
  .landing-roles { grid-template-columns: 1fr; margin-top: 22px; }
  .landing-role { grid-template-columns: 60px minmax(0, 1fr) 42px; min-height: 126px; padding: 18px 20px; }
  .role-avatar { width: 54px; height: 54px; }
  .landing-role strong { font-size: 20px; }
  .landing-advantages { display: none; }
  .landing-help { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 14px; margin-top: 20px; padding: 20px; border: 1px solid #c9def7; border-radius: 8px; background: #edf5ff; }
  .help-mark { display: grid; width: 48px; height: 48px; place-items: center; border: 2px solid #0870df; border-radius: 50%; color: #0870df; font-size: 22px; font-weight: 800; }
  .landing-help small { margin-top: 3px; color: #53667e; }
  .landing-help > a { padding: 10px 14px; border-radius: 6px; background: #fff; font-weight: 700; text-decoration: none; }
  .public-footer { display: none; }
  .landing-mobile-nav { display: grid; grid-template-columns: repeat(3, 1fr); min-height: 82px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: #0757a1; }
  .landing-mobile-nav a { display: grid; place-items: center; align-content: center; gap: 3px; color: #fff; font-size: 12px; text-decoration: none; }
  .landing-mobile-nav span { font-size: 20px; font-weight: 700; }
  :root[data-theme="dark"] .landing-intro { background-color: #17232d; background-blend-mode: soft-light; }
  :root[data-theme="dark"] .landing-help { background: #17232d; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: 0s !important; }
}
