:root {
  color-scheme: light;
  --nav: #111827;
  --canvas: #f3f5f8;
  --surface: #ffffff;
  --text: #182033;
  --muted: #687386;
  --line: #dfe4eb;
  --line-soft: #edf0f4;
  --primary: #5047dc;
  --primary-soft: #eeedff;
  --success: #117b56;
  --success-soft: #e8f7f0;
  --danger: #bf344b;
  --danger-soft: #fff0f2;
  --warn: #9a5708;
  --warn-soft: #fff3da;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--canvas);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(80, 71, 220, 0.22);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, var(--nav) 0 34%, transparent 34%),
    var(--canvas);
}

.login-panel {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(280px, 420px);
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.18);
}

.login-panel > .brand {
  min-height: 100%;
  align-items: flex-start;
  padding-top: 28px;
  background: var(--nav);
  border-bottom: 0;
}

.login-card {
  display: grid;
  gap: 16px;
  padding: 34px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: #4b5668;
  font-size: 12px;
  font-weight: 750;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  display: flex;
  flex-direction: column;
  background: var(--nav);
  color: #fff;
}

.brand {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  font-family: Cinzel, Georgia, serif;
  font-weight: 700;
}

.brand-name {
  font-family: Cinzel, Georgia, serif;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-sub {
  margin-top: 2px;
  color: #aeb9c9;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
}

.nav-btn {
  height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #b9c3d2;
  text-align: left;
  padding: 0 11px;
  font-weight: 650;
}

.nav-btn.active {
  background: #2b3550;
  color: #fff;
  box-shadow: inset 3px 0 #746bf8;
}

.sidebar-note {
  margin: auto 12px 16px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #aeb9c9;
  font-size: 11px;
  line-height: 1.5;
}

.sidebar-note b {
  display: block;
  color: #fff;
}

.workspace {
  min-height: 100vh;
  margin-left: 232px;
  padding-top: 68px;
}

.topbar {
  position: fixed;
  top: 0;
  left: 232px;
  right: 0;
  z-index: 30;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 19px;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  margin-left: auto;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
}

.mobile-menu,
.mobile-nav-backdrop,
.mobile-drawer,
.mobile-list {
  display: none;
}

.content {
  max-width: 1560px;
  margin: 0 auto;
  padding: 26px 28px 42px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0 0 5px;
  font-size: 22px;
}

.page-head p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.btn {
  min-height: 38px;
  border: 1px solid #d7dce4;
  border-radius: 7px;
  background: #fff;
  color: #374153;
  padding: 0 13px;
  font-weight: 700;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn.danger {
  border-color: #efc5cc;
  background: #fff;
  color: var(--danger);
}

.btn.small {
  min-height: 31px;
  padding: 0 10px;
  font-size: 11px;
}

.btn.full {
  width: 100%;
  margin-top: 8px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi,
.card,
.state-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpi {
  min-height: 108px;
  padding: 16px;
}

.kpi span,
.kpi small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.kpi b {
  display: block;
  margin: 10px 0 6px;
  font-size: 28px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  overflow: hidden;
}

.card-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head h3 {
  margin: 0;
  font-size: 13px;
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
}

.toolbar {
  display: flex;
  gap: 9px;
  padding: 11px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search-input,
.toolbar select,
label input {
  height: 38px;
  border: 1px solid #d8dee7;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
}

.search-input {
  min-width: 260px;
}

.desktop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.desktop-table th {
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  color: #778195;
  font-size: 10px;
  text-align: left;
  text-transform: uppercase;
}

.desktop-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line-soft);
  color: #344054;
}

.desktop-table td span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 20px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 800;
}

.badge::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.badge.success {
  background: var(--success-soft);
  color: var(--success);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.detail-panel {
  margin-top: 16px;
}

.detail-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: #fff;
}

.detail-hero h2 {
  margin: 0 0 4px;
  font-size: 19px;
}

.detail-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.portal-tabs {
  display: flex;
  gap: 24px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-top: 0;
  background: #fff;
}

.portal-tabs button {
  height: 40px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #687386;
  font-size: 11px;
  font-weight: 750;
}

.portal-tabs .active {
  border-color: var(--primary);
  color: var(--primary);
}

.detail-grid {
  margin-top: 15px;
}

.admin-row,
.session-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.admin-row span,
.session-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.info-list {
  margin: 0;
  padding: 8px 16px;
}

.info-list div {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.info-list dt {
  color: var(--muted);
  font-size: 11px;
}

.info-list dd {
  margin: 0;
  font-weight: 700;
}

.state-list {
  padding: 4px 0;
}

.state-list button {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 12px 15px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  text-align: left;
}

.state-list span {
  color: var(--muted);
  font-size: 11px;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(320px, 1.2fr);
  gap: 16px;
}

.form-card {
  display: grid;
  gap: 14px;
  padding-bottom: 16px;
}

.form-card label,
.dialog label {
  display: grid;
  gap: 6px;
  padding: 0 16px;
  color: #4b5668;
  font-size: 11px;
  font-weight: 750;
}

.chart-card {
  padding-bottom: 18px;
}

.bars {
  height: 210px;
  display: flex;
  align-items: end;
  gap: 14px;
  padding: 18px;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 42px, #eef1f4 43px);
}

.bars span {
  flex: 1;
  min-width: 32px;
  border-radius: 6px 6px 0 0;
  background: var(--primary);
}

.modal-backdrop:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, 0.42);
}

.dialog {
  width: min(560px, 100%);
  display: grid;
  gap: 14px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 26px 80px rgba(10, 18, 36, 0.25);
}

.dialog header,
.dialog footer {
  display: flex;
  justify-content: space-between;
  gap: 9px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.dialog footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line-soft);
  border-bottom: 0;
}

.dialog h3 {
  margin: 0;
}

.dialog header button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.steps,
.notice {
  margin: 0 16px;
  padding: 10px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: #3730a3;
  font-size: 11px;
  line-height: 1.5;
}

.steps {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: #f8f9fb;
  color: var(--muted);
  font-weight: 750;
}

.state-page {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
}

.state-card.large {
  max-width: 440px;
  padding: 32px;
  text-align: center;
}

.state-card h2 {
  margin: 0 0 8px;
}

.state-card p {
  color: var(--muted);
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: none;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: 9px;
  background: #172135;
  color: #fff;
  box-shadow: 0 14px 44px rgba(20, 31, 53, 0.18);
}

.toast.show {
  display: block;
}

.company-admin-shell .sidebar-note {
  font-size: 11px;
}

.company-grid {
  align-items: start;
}

.company-empty {
  padding: 18px;
}

.company-empty h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.company-empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.company-mobile-card {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.company-mobile-card span {
  color: var(--muted);
  font-size: 11px;
}

.live-map-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.38fr) minmax(420px, 0.62fr);
  gap: 14px;
  margin-bottom: 16px;
}

.live-list {
  min-height: 360px;
}

.live-trip-row {
  width: 100%;
  display: grid;
  gap: 6px;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
  text-align: left;
}

.live-trip-row:hover {
  background: #f8f9fb;
}

.live-trip-row span:not(.badge) {
  color: var(--muted);
  font-size: 11px;
}

.google-map-shell {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.google-map-canvas {
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ec;
}

.site-location-config {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.site-location-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.site-location-map {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ec;
}

.map-state-stack {
  display: grid;
  gap: 8px;
}

.warehouse-site-shell .sidebar-note {
  font-size: 11px;
}

.request-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.request-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.request-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.request-id,
.request-meta {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.request-driver {
  margin-top: 4px;
  font-weight: 800;
}

.request-containers {
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
  font-weight: 700;
}

.request-actions {
  display: flex;
  gap: 7px;
}

.request-actions .btn {
  flex: 1;
}

.calendar-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.site-chip {
  min-height: 72px;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.site-chip span,
.site-chip small {
  color: var(--muted);
  font-size: 10px;
}

.review-form {
  display: grid;
  gap: 14px;
}

.review-form .notice {
  margin-top: 0;
}

.history-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 14px;
  margin-bottom: 16px;
}

.history-list,
.correction-grid {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.history-row,
.correction-card {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
}

.history-row span:not(.badge),
.history-row small,
.correction-card span,
.correction-card small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.history-detail {
  display: grid;
  gap: 14px;
}

.history-route-map {
  display: grid;
  gap: 8px;
  min-height: 220px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, #f7faf8, #eef4f1);
}

.history-route-map svg {
  width: 100%;
  min-height: 180px;
}

.history-route-line {
  fill: none;
  stroke: #285846;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-route-point {
  fill: #ffffff;
  stroke: #1f3d35;
  stroke-width: 1.4;
}

.history-route-point.end {
  fill: #d8a537;
}

.history-route-legend {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.history-route-map.empty {
  align-content: center;
  color: var(--muted);
}

.correction-card pre,
.correction-grid textarea {
  min-height: 92px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8f9fb;
  color: var(--text);
  padding: 9px;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (max-width: 760px) {
  .login-shell {
    place-items: stretch;
    padding: 0;
    background: var(--canvas);
  }

  .login-panel {
    min-height: 100vh;
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
  }

  .login-panel > .brand {
    min-height: 68px;
    align-items: center;
    padding-top: 0;
  }

  .login-card {
    align-content: start;
    padding: 28px 20px;
  }

  .sidebar {
    display: none;
  }

  .workspace,
  .topbar {
    left: 0;
    margin-left: 0;
  }

  .topbar {
    padding: 0 14px;
  }

  .topbar h1 {
    font-size: 15px;
  }

  .mobile-menu {
    display: grid;
    min-width: 54px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-nav-backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: block;
    background: rgba(17, 24, 39, 0.42);
  }

  .mobile-drawer:not([hidden]) {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 90;
    display: flex;
    width: min(86vw, 330px);
    flex-direction: column;
    background: var(--nav);
    color: #fff;
    box-shadow: 18px 0 45px rgba(18, 27, 44, 0.18);
  }

  .mobile-drawer-head {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .mobile-close {
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-nav-open {
    overflow: hidden;
  }

  .content {
    padding: 18px 14px 32px;
  }

  .page-head,
  .grid-2,
  .settings-layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .head-actions,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .kpi-grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    margin: 0 -14px 16px;
    padding: 0 14px 4px;
  }

  .kpi {
    flex: 0 0 148px;
  }

  .desktop-table {
    display: none;
  }

  .mobile-list {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .list-card {
    display: grid;
    gap: 8px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .list-card span {
    color: var(--muted);
    font-size: 10px;
  }

  .list-card div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
  }

  .detail-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .portal-tabs {
    overflow-x: auto;
    gap: 20px;
  }

  .admin-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .action-sheet:not([hidden]) {
    position: fixed;
    inset: auto 0 0;
    z-index: 110;
    display: block;
    padding: 8px 14px calc(14px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
    background: #fff;
    box-shadow: 0 -16px 50px rgba(18, 27, 44, 0.18);
  }

  .action-sheet header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .action-sheet header button {
    border: 0;
    background: transparent;
    color: var(--muted);
  }

  .toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
  }

  .company-admin-shell .content {
    padding: 18px 14px 34px;
  }

  .company-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .company-mobile-card {
    min-height: 92px;
  }

  .live-map-layout {
    grid-template-columns: 1fr;
  }

  .live-list {
    min-height: 0;
  }

  .google-map-canvas {
    min-height: 320px;
  }

  .site-location-grid {
    grid-template-columns: 1fr;
  }

  .site-location-map {
    min-height: 280px;
  }

  .warehouse-site-shell .content {
    padding: 18px 14px 34px;
  }

  .request-grid,
  .calendar-strip {
    grid-template-columns: 1fr;
  }

  .request-actions,
  .review-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .history-grid,
  .correction-grid {
    grid-template-columns: 1fr;
  }

  .history-row {
    align-items: stretch;
  }
}
