:root {
  --ust-text-brand: #055cdb;
  --ust-text-primary: #0f1c38;
  --ust-text-secondary: #63738f;
  --ust-icon-primary: #263b5b;
  --ust-icon-secondary: #63738f;
  --ust-surface-default: #ffffff;
  --ust-surface-brand: #053373;
  --ust-border-default: #dbe3f0;
  --ust-border-brand: #0b6ef3;
  --ust-brand-100: #eaf2ff;
  --ust-brand-200: #bfd7ff;
  --ust-background-subtle: #eef3f9;
  --ust-background-canvas: #f5f7fc;
  --ust-action-primary-default: #055cdb;
  --ust-action-primary-hover: #0757b5;
  --ust-action-primary-pressed: #06458f;
  --ust-action-disabled: #dbe3f0;
  --ust-focus-ring: #4a90ff;
  --ust-status-success-text: #21a659;
  --ust-status-success-background: #e8f7ef;
  --ust-status-warning-text: #f5940d;
  --ust-status-warning-background: #fff2df;
  --ust-status-info-text: #0878e8;
  --ust-status-info-background: #e8f4ff;
  --ust-status-danger-text: #eb333d;
  --ust-status-danger-background: #ffe8ea;
  --ust-status-new-text: #7a40e0;
  --ust-status-new-background: #f0e8ff;
  --bg: var(--ust-background-canvas);
  --surface: var(--ust-surface-default);
  --surface-2: var(--ust-background-subtle);
  --text: var(--ust-text-primary);
  --muted: var(--ust-text-secondary);
  --border: var(--ust-border-default);
  --primary: var(--ust-action-primary-default);
  --primary-strong: var(--ust-action-primary-hover);
  --success: var(--ust-status-success-text);
  --warning: var(--ust-status-warning-text);
  --danger: var(--ust-status-danger-text);
  --accent: var(--ust-text-brand);
  --shadow: 0 10px 28px rgba(15, 28, 56, .08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --ust-text-primary: #f4f7fb;
  --ust-text-secondary: #aebbd0;
  --ust-icon-primary: #e7edf7;
  --ust-icon-secondary: #aebbd0;
  --ust-surface-default: #17233a;
  --ust-surface-brand: #071f48;
  --ust-border-default: #334663;
  --ust-brand-100: #163b70;
  --ust-brand-200: #27568d;
  --ust-background-subtle: #1e2d46;
  --ust-background-canvas: #0e1727;
  --ust-action-disabled: #334663;
  --bg: var(--ust-background-canvas);
  --surface: var(--ust-surface-default);
  --surface-2: var(--ust-background-subtle);
  --text: var(--ust-text-primary);
  --muted: var(--ust-text-secondary);
  --border: var(--ust-border-default);
  --shadow: 0 12px 32px rgba(0, 0, 0, .26);
}

body { background: var(--ust-background-canvas); color: var(--ust-text-primary); font-family: inherit; }
h1 { font-size: 32px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 650; }
.ui-icon { display: block; width: 22px; height: 22px; flex: 0 0 auto; object-fit: contain; }
.primary-button .ui-icon, .secondary-button .ui-icon, .verified-mark .ui-icon, .text-link .ui-icon { width: 18px; height: 18px; }

.primary-button, .secondary-button {
  min-height: 44px;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 650;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.primary-button { border-color: var(--ust-action-primary-default); background: var(--ust-action-primary-default); }
.primary-button:hover { border-color: var(--ust-action-primary-hover); background: var(--ust-action-primary-hover); }
.primary-button:active { border-color: var(--ust-action-primary-pressed); background: var(--ust-action-primary-pressed); }
.secondary-button { border-color: var(--ust-brand-200); color: var(--ust-text-brand); }
.secondary-button:hover { border-color: var(--ust-border-brand); background: var(--ust-brand-100); }
.primary-button:focus-visible, .secondary-button:focus-visible, .icon-button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--ust-focus-ring) 38%, transparent); outline-offset: 2px; }
.icon-button { border-color: var(--ust-border-default); border-radius: 8px; }

.topbar {
  height: 72px;
  padding: 0 24px 0 20px;
  border: 0;
  background: var(--ust-surface-brand);
  color: #fff;
}
.brand { display: flex; width: 224px; align-items: center; }
.brand img { display: block; width: 210px; height: 56px; object-fit: contain; object-position: left center; }
.account { gap: 10px; color: #fff; }
.account-copy { display: grid; min-width: 150px; line-height: 1.2; text-align: right; }
.account-copy small { color: rgba(255,255,255,.7); font-size: 11px; }
.account-copy strong { max-width: 220px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.account-avatar { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; background: rgba(255,255,255,.12); font-weight: 700; }
.topbar-action { border-color: rgba(255,255,255,.18); background: transparent; }
.topbar-action:hover { background: rgba(255,255,255,.12); }
.topbar-action .ui-icon { filter: brightness(0) invert(1); }

.sidebar {
  top: 72px;
  width: 272px;
  gap: 4px;
  padding: 24px 12px 18px;
  border: 0;
  background: var(--ust-surface-brand);
}
.sidebar-label { margin: 12px 12px 7px; color: rgba(255,255,255,.52); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.sidebar-label:first-child { margin-top: 0; }
.sidebar a { display: flex; height: 48px; align-items: center; gap: 12px; padding: 0 16px; border-radius: 8px; color: rgba(255,255,255,.78); font-size: 14px; font-weight: 600; }
.sidebar a .ui-icon { width: 22px; height: 22px; filter: brightness(0) invert(1); opacity: .78; }
.sidebar a:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar a[aria-current="page"] { background: var(--ust-action-primary-default); color: #fff; }
.sidebar a[aria-current="page"] .ui-icon { opacity: 1; }
.sidebar-theme { margin-top: auto; }
.sidebar .theme-control { position: static; width: auto; padding: 3px; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); box-shadow: none; }
.sidebar .theme-control button { color: rgba(255,255,255,.72); }
.sidebar .theme-control button[aria-pressed="true"] { background: #fff; color: var(--ust-surface-brand); }
.app-main { width: calc(100% - 272px); max-width: none; margin-left: 272px; padding: 104px clamp(20px, 3vw, 44px) 48px; }

.page-heading { align-items: center; margin-bottom: 26px; }
.page-heading h1 { max-width: 900px; }
.eyebrow { margin-bottom: 5px; color: var(--ust-text-brand); font-size: 11px; letter-spacing: 0; }
.content-section { padding: 22px; border-color: var(--ust-border-default); border-radius: 8px; box-shadow: 0 1px 2px rgba(15,28,56,.02); }
.section-heading { margin-bottom: 18px; }
.text-action { font-size: 13px; font-weight: 650; text-decoration: none; }

.metrics { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 22px; }
.metrics article { display: flex; min-height: 112px; align-items: center; gap: 16px; padding: 20px; border-radius: 8px; }
.metrics article > div { display: flex; flex-direction: column; }
.metrics article > div > span { order: 2; font-size: 13px; }
.metrics strong { order: 1; margin: 0; color: var(--ust-text-primary); font-size: 28px; line-height: 1.15; }
.metric-icon { display: grid; width: 48px; height: 48px; flex: 0 0 48px; place-items: center; border-radius: 50%; background: var(--ust-brand-100); }
.metric-icon .ui-icon { width: 24px; height: 24px; }
.metric-success .metric-icon { background: var(--ust-status-success-background); }
.metric-warning .metric-icon { background: var(--ust-status-warning-background); }
.metric-new .metric-icon { background: var(--ust-status-new-background); }

.order-list { gap: 0; overflow: hidden; border: 1px solid var(--ust-border-default); border-radius: 8px; }
.order-list > [data-order-card] + [data-order-card] { border-top: 1px solid var(--ust-border-default); }
.order-card { padding: 16px 18px; border: 0; border-left: 0; border-radius: 0; }
.order-card + .order-card { border-top: 1px solid var(--ust-border-default); }
.order-card:hover { border-color: transparent; background: var(--ust-background-subtle); }
.order-id { margin-right: 10px; color: var(--ust-text-brand); font-size: 12px; }
.route-line { margin: 12px 0; }
.route-line b { display: grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; border-radius: 50%; background: var(--ust-brand-100); }
.route-line b .ui-icon { width: 17px; height: 17px; }
.order-meta span { display: inline-flex; align-items: center; gap: 6px; }
.order-meta .ui-icon { width: 16px; height: 16px; }
.stage, .status-badge { display: inline-flex; min-height: 23px; align-items: center; gap: 6px; padding: 3px 9px; border: 0; border-radius: 999px; background: var(--ust-status-info-background); color: var(--ust-status-info-text); font-size: 11px; font-weight: 700; }
.stage::before, .status-badge::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.stage-created, .stage-assigned { background: var(--ust-status-new-background); color: var(--ust-status-new-text); }
.stage-in_transit, .stage-accepted, .stage-arrived { background: var(--ust-status-info-background); color: var(--ust-status-info-text); }
.stage-delivered, .stage-closed, .status-success { background: var(--ust-status-success-background); color: var(--ust-status-success-text); }
.stage-cancelled { background: var(--ust-status-danger-background); color: var(--ust-status-danger-text); }
.status-neutral { background: var(--ust-background-subtle); color: var(--ust-text-secondary); }

.filter-bar { grid-template-columns: minmax(280px, 1fr) minmax(190px, 240px); margin-bottom: 16px; }
.search-control { position: relative; display: block; }
.search-control .ui-icon { position: absolute; z-index: 1; top: 11px; left: 13px; width: 20px; height: 20px; }
.search-control input { padding-left: 42px; }
label { color: var(--ust-text-secondary); font-size: 12px; }
input, select, textarea { min-height: 44px; border-color: var(--ust-border-default); border-radius: 8px; }
input:hover, select:hover, textarea:hover { border-color: var(--ust-brand-200); }
input:focus, select:focus, textarea:focus { border-color: var(--ust-border-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ust-focus-ring) 20%, transparent); }

.wizard { max-width: 1080px; padding: 28px; border-radius: 8px; }
.wizard-progress { position: relative; gap: 0; margin-bottom: 32px; }
.wizard-progress::before { position: absolute; top: 18px; right: 12%; left: 12%; height: 2px; background: var(--ust-border-default); content: ""; }
.wizard-progress li { position: relative; z-index: 1; display: grid; justify-items: center; gap: 7px; padding: 0; border: 0; background: transparent; text-align: center; }
.wizard-progress li span { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--ust-border-default); border-radius: 50%; background: var(--ust-surface-default); color: var(--ust-text-secondary); font-weight: 700; }
.wizard-progress li.active { color: var(--ust-text-primary); }
.wizard-progress li.active span { border-color: var(--ust-border-brand); background: var(--ust-action-primary-default); color: #fff; }
.wizard-step { min-height: 300px; }
.form-note { border-left-color: var(--ust-text-brand); background: var(--ust-brand-100); }
.review-block { background: var(--ust-background-subtle); }

.timeline { display: grid; gap: 0; }
.timeline li { min-height: 46px; grid-template-columns: 28px 1fr; }
.timeline li span { display: grid; width: 22px; height: 22px; margin: 0; place-items: center; border-width: 1px; background: var(--ust-background-subtle); }
.timeline li::after { top: 23px; bottom: 0; left: 10px; width: 1px; }
.timeline li.reached span { border-color: var(--ust-status-success-text); background: var(--ust-status-success-background); }
.timeline li.reached span::after { color: var(--ust-status-success-text); content: "✓"; font-size: 12px; font-weight: 800; }
.timeline li.current span { border-color: var(--ust-border-brand); background: var(--ust-brand-100); }
.timeline li.current strong { color: var(--ust-text-brand); }
.cargo-item.verified { border-color: color-mix(in srgb, var(--ust-status-success-text) 45%, var(--ust-border-default)); background: color-mix(in srgb, var(--ust-status-success-background) 55%, var(--ust-surface-default)); }
.verified-mark { display: inline-flex; align-items: center; gap: 6px; }

.responsive-table table { font-size: 13px; }
.responsive-table th { padding: 11px 14px; background: var(--ust-background-subtle); color: var(--ust-text-secondary); font-size: 10px; }
.responsive-table td { padding: 14px; }
.responsive-table tbody tr:hover { background: var(--ust-background-subtle); }

.auth-body .guest-main { display: grid; min-height: 100vh; padding: 0; }
.auth-shell { position: relative; display: grid; width: 100%; min-height: 100vh; grid-template-columns: minmax(360px, 42%) minmax(420px, 58%); margin: 0; }
.auth-brand { position: relative; display: flex; min-height: 100%; flex-direction: column; overflow: hidden; padding: 54px 48px; background: var(--ust-surface-brand); color: #fff; }
.auth-brand > img:first-child { width: min(280px, 85%); height: 82px; object-fit: contain; object-position: left center; }
.auth-brand p { position: relative; z-index: 1; margin: auto 0 0; color: rgba(255,255,255,.78); font-size: 18px; }
.auth-vehicle { position: absolute; right: -60px; bottom: 110px; width: min(520px, 110%); height: auto; object-fit: contain; filter: drop-shadow(0 24px 30px rgba(0,0,0,.22)); }
.auth-shell .back-link { position: absolute; z-index: 2; top: 38px; left: calc(42% + 48px); display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--ust-text-secondary); font-size: 13px; }
.auth-panel { align-self: center; width: min(480px, calc(100% - 72px)); margin: 80px auto 40px; padding: 38px; border-radius: 8px; box-shadow: var(--shadow); }
.auth-role-icon { display: grid; width: 52px; height: 52px; margin-bottom: 22px; place-items: center; border-radius: 50%; background: var(--ust-brand-100); }
.auth-role-icon .ui-icon { width: 26px; height: 26px; }
.auth-role-driver { background: var(--ust-status-success-background); }
.auth-role-admin { background: var(--ust-status-new-background); }
.auth-panel form { margin-top: 24px; }
.auth-panel form .primary-button { margin-top: 6px; }
.guest-theme { top: 20px; right: 24px; width: 264px; box-shadow: none; }

.public-qr { width: min(760px, 100%); }
.public-qr-heading { padding-right: 250px; }
.qr-lookup { padding: 26px; }
.qr-result { border-color: color-mix(in srgb, var(--ust-status-success-text) 45%, var(--ust-border-default)); background: color-mix(in srgb, var(--ust-status-success-background) 40%, var(--ust-surface-default)); }
.text-link { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; }
.scanner-dialog { padding: 22px; border-radius: 8px; box-shadow: 0 24px 70px rgba(5, 20, 45, .32); }

.public-header { background: var(--ust-surface-brand); }
.public-brand img { width: 230px; height: 64px; border-radius: 0; object-fit: contain; object-position: left center; }
.public-header-inner { grid-template-columns: 250px minmax(420px, 1fr) auto; }
.public-menu-toggle .ui-icon { width: 26px; height: 26px; filter: brightness(0) invert(1); }
.public-menu-toggle span { display: none; }
.feature-mark .ui-icon, .landing-advantages .ui-icon, .help-mark .ui-icon { width: 26px; height: 26px; }
.qr-device-mark { width: 72px; height: 72px; border: 0; border-radius: 0; }
.qr-device-mark::after { display: none; }
.qr-device-mark .ui-icon { width: 58px; height: 58px; }
.qr-camera-button .ui-icon, .qr-image-button .ui-icon { width: 20px; height: 20px; margin-right: 8px; }
.role-avatar { border-width: 1px; border-radius: 8px; background: #fff; }
.role-avatar .ui-icon { width: 34px; height: 34px; }
.landing-role b { font-size: 20px; }

@media (max-width: 1100px) {
  .sidebar { width: 232px; }
  .app-main { width: calc(100% - 232px); margin-left: 232px; }
  .public-header-inner { grid-template-columns: 250px auto; }
  .auth-shell { grid-template-columns: minmax(300px, 38%) minmax(400px, 62%); }
  .auth-shell .back-link { left: calc(38% + 36px); }
}

@media (max-width: 820px) {
  .topbar { height: 64px; padding: 0 14px; }
  .brand { width: auto; }
  .brand img { width: 170px; height: 48px; }
  .account-copy, .topbar .account-avatar { display: none; }
  .sidebar { display: none; }
  .app-main { width: 100%; margin-left: 0; padding: 84px 16px calc(92px + env(safe-area-inset-bottom)); }
  .mobile-nav { min-height: 68px; padding: 5px 8px calc(5px + env(safe-area-inset-bottom)); border-color: var(--ust-border-default); }
  .mobile-nav a { align-content: center; gap: 2px; border-radius: 8px; font-size: 11px; }
  .mobile-nav a .ui-icon { width: 21px; height: 21px; }
  .mobile-nav a[aria-current="page"] { background: var(--ust-brand-100); color: var(--ust-text-brand); }
  .auth-shell { display: block; min-height: 100vh; padding: 88px 18px 34px; }
  .auth-brand { position: absolute; top: 0; right: 0; left: 0; min-height: 72px; height: 72px; padding: 8px 18px; }
  .auth-brand > img:first-child { width: 190px; height: 54px; }
  .auth-brand p, .auth-vehicle { display: none; }
  .auth-shell .back-link { position: static; margin: 0 0 16px; }
  .auth-panel { width: 100%; margin: 0; padding: 26px; }
  .guest-theme { top: 16px; right: 16px; bottom: auto; width: 132px; }
  .guest-theme button { padding: 0 3px; font-size: 10px; }
  .public-qr-heading { padding-right: 0; }
}

@media (max-width: 700px) {
  h1 { font-size: 27px; }
  .page-heading { align-items: stretch; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics article { min-height: 98px; gap: 10px; padding: 14px; }
  .metric-icon { width: 40px; height: 40px; flex-basis: 40px; }
  .metrics strong { font-size: 23px; }
  .content-section, .wizard { padding: 16px; }
  .filter-bar { grid-template-columns: 1fr; }
  .order-card { padding: 14px; }
  .order-card-top { flex-direction: column; gap: 8px; }
  .route-line { display: grid; grid-template-columns: 1fr; }
  .route-line b { transform: rotate(90deg); }
  .wizard-progress li { font-size: 10px; }
  .wizard-progress li span { width: 32px; height: 32px; }
  .wizard-progress::before { top: 15px; }
  .public-brand img { width: 210px; height: 58px; }
  .public-header { min-height: 92px; }
  .public-header-inner { min-height: 92px; }
  .public-nav { top: 92px; }
  .landing-intro { min-height: 460px; }
  .landing-features > div { background: rgba(255,255,255,.9); }
}

@media (max-width: 430px) {
  .app-main { padding-right: 12px; padding-left: 12px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metrics article { display: grid; grid-template-columns: 38px minmax(0, 1fr); }
  .metrics article > div > span { font-size: 11px; }
  .auth-shell { padding-right: 12px; padding-left: 12px; }
  .auth-panel { padding: 22px 18px; }
  .landing-role { grid-template-columns: 52px minmax(0,1fr) 34px; padding: 16px; }
}
