:root {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #1c2733;
  background: #f3f5f7;
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 1100px; }
.auth-required { display: none; }
.auth-required.authenticated { display: grid; }
.login-screen { min-height: 100vh; display: grid; place-items: center; background: #eef2f4; }
.login-screen.hidden { display: none; }
.login-panel { width: 390px; display: grid; gap: 18px; padding: 28px; background: #fff; border: 1px solid #d6dfe3; border-radius: 7px; box-shadow: 0 18px 50px #23333d18; }
.login-panel label { display: grid; gap: 6px; color: #4c5b64; }
.login-panel input, .login-panel button { width: 100%; }
.login-panel p { margin-top: 6px; color: #6c7881; }
.login-brand { color: #1c2733; padding: 0 0 18px; border-bottom-color: #dfe5e8; }
.login-error { min-height: 20px; color: #b03434; }
.language-switch { display: inline-flex; width: max-content; padding: 2px; border: 1px solid #bdc8ce; border-radius: 5px; background: #fff; }
.language-switch button { min-height: 28px; padding: 0 9px; border: 0; background: transparent; color: #52616a; }
.language-switch button.active { color: #fff; background: #176b78; }
.login-panel > .language-switch { justify-self: end; margin-top: -62px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.button-link { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; border-radius: 4px; padding: 0 13px; text-decoration: none; }
.app-shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar { background: #17232b; color: #e8eef1; padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; border-bottom: 1px solid #31414b; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; background: #e3a21a; color: #162028; font-weight: 800; border-radius: 6px; }
.brand strong, .brand small { display: block; }
.brand small { color: #9eafb8; margin-top: 3px; }
nav { padding-top: 16px; }
.nav-item { width: 100%; text-align: left; border: 0; border-radius: 5px; padding: 10px 12px; margin: 2px 0; color: #cbd6db; background: transparent; }
.nav-item:hover, .nav-item.active { color: #fff; background: #2a3c47; }
.nav-item.active { box-shadow: inset 3px 0 #e3a21a; }
.nav-label { color: #81939d; font-size: 12px; text-transform: uppercase; padding: 18px 12px 6px; }
.main { padding: 0 26px 36px; overflow: hidden; }
.topbar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; }
h1, h2, p { margin: 0; }
h1 { font-size: 23px; }
h2 { font-size: 16px; }
.topbar p, .panel-header p { color: #6c7881; margin-top: 5px; }
.system-status { color: #56636c; font-size: 13px; }
.system-status i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2e9b63; margin-right: 6px; }
.user-session { display: flex; align-items: center; gap: 10px; color: #56636c; }
.user-session span { font-weight: 600; }
.page { display: none; }
.page.active { display: block; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.metric, .panel { background: #fff; border: 1px solid #dce2e6; border-radius: 7px; }
.metric { padding: 18px; border-top: 3px solid #3d768a; }
.metric span { display: block; color: #69767f; }
.metric strong { display: block; font-size: 28px; margin-top: 8px; }
.panel { margin-bottom: 14px; }
.panel-header, .toolbar { min-height: 56px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e4e8eb; }
.toolbar { gap: 16px; }
.toolbar-actions { display: flex; gap: 8px; white-space: nowrap; }
.warehouse-switch { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.warehouse-switch button { min-width: 150px; }
.warehouse-switch button.active { color: #fff; background: #176b78; border-color: #176b78; }
.dispatch-warehouse-panel .panel-header { border-bottom: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
input, select { height: 34px; border: 1px solid #cbd3d8; border-radius: 4px; padding: 0 9px; background: #fff; color: #26343d; }
textarea { border: 1px solid #cbd3d8; border-radius: 4px; padding: 8px 9px; resize: vertical; color: #26343d; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bdd9e2; border-color: #3d768a; }
button { min-height: 34px; border-radius: 4px; padding: 0 13px; border: 1px solid transparent; }
.primary { color: #fff; background: #176b78; border-color: #176b78; }
.primary:hover { background: #105d69; }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.secondary { color: #2b3942; background: #fff; border-color: #bdc8ce; }
.danger { color: #b03434; background: #fff; border-color: #d9b3b3; min-height: 28px; padding: 0 9px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { color: #52616a; background: #f7f8f9; font-size: 12px; text-transform: uppercase; text-align: left; }
th, td { padding: 11px 13px; border-bottom: 1px solid #e5e9ec; vertical-align: top; white-space: nowrap; }
.order-pool-wrap { max-height: calc(100vh - 265px); position: relative; }
.order-pool-table { min-width: 1780px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.order-pool-table th { position: sticky; top: 0; z-index: 5; }
.order-pool-table th:first-child,
.order-pool-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 170px;
  min-width: 170px;
  max-width: 170px;
  background: #fff;
  box-shadow: 1px 0 0 #dce2e6;
}
.order-pool-table th:nth-child(2),
.order-pool-table td:nth-child(2) {
  position: sticky;
  left: 170px;
  z-index: 4;
  width: 170px;
  min-width: 170px;
  max-width: 170px;
  background: #fff;
  box-shadow: 1px 0 0 #dce2e6;
}
.order-pool-table th:first-child,
.order-pool-table th:nth-child(2) {
  z-index: 7;
  background: #f7f8f9;
}
.order-pool-table th:last-child,
.order-pool-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 4;
  width: 96px;
  min-width: 96px;
  max-width: 96px;
  background: #fff;
  box-shadow: -1px 0 0 #dce2e6;
}
.order-pool-table th:last-child { z-index: 7; background: #f7f8f9; }
.order-pool-table th:nth-child(14),
.order-pool-table td:nth-child(14) {
  position: sticky;
  right: 96px;
  z-index: 4;
  width: 112px;
  min-width: 112px;
  max-width: 112px;
  background: #fff;
  box-shadow: -1px 0 0 #dce2e6;
}
.order-pool-table th:nth-child(14) { z-index: 7; background: #f7f8f9; }
.order-pool-table tbody tr:hover td { background: #fafcfc; }
.order-pool-table tbody tr:hover td:first-child,
.order-pool-table tbody tr:hover td:nth-child(2),
.order-pool-table tbody tr:hover td:nth-child(14),
.order-pool-table tbody tr:hover td:last-child { background: #fafcfc; }
.order-pool-table th:nth-child(3), .order-pool-table td:nth-child(3) { width: 170px; }
.order-pool-table th:nth-child(4), .order-pool-table td:nth-child(4) { width: 130px; }
.order-pool-table th:nth-child(n+5):nth-child(-n+11),
.order-pool-table td:nth-child(n+5):nth-child(-n+11) { width: 92px; text-align: right; }
.order-pool-table th:nth-child(12), .order-pool-table td:nth-child(12) { width: 310px; }
.order-pool-table th:nth-child(13), .order-pool-table td:nth-child(13) { width: 230px; }
td.address { white-space: normal; min-width: 250px; line-height: 1.4; }
tbody tr:hover { background: #fafcfc; }
.badge { display: inline-block; border-radius: 4px; padding: 3px 7px; font-size: 12px; font-weight: 600; background: #edf2f4; }
.badge.active, .badge.unassigned { color: #176344; background: #e3f3eb; }
.badge.pending { color: #47545c; background: #e8edef; }
.badge.dispatched, .badge.completed { color: #176344; background: #e3f3eb; }
.badge.cancelled { color: #a02f2f; background: #f8e4e4; }
.badge.onsite { color: #145e79; background: #e3f1f6; }
.badge.offsite { color: #855617; background: #fbefd9; }
#alerts { padding: 8px 16px 16px; }
.alert-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #edf0f2; }
.alert-row:last-child { border: 0; }
.workflow ol { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0; padding: 18px 18px 18px 44px; }
.workflow li { padding-right: 18px; line-height: 1.5; }
.dispatch-flow { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 42px 20px; }
.dispatch-flow span { padding: 12px 16px; border: 1px solid #b8c8ce; background: #f8fafb; border-radius: 5px; }
.dispatch-flow b { color: #8a979e; font-size: 18px; }
.pending-pool { max-height: 280px; }
.pending-pool tbody tr.selected { background: #eaf4f6; }
.pending-pool input[type="checkbox"], .add-order-list input[type="checkbox"] { height: auto; }
.warehouse-section { margin-top: 18px; }
.warehouse-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; }
.warehouse-title h2 { font-size: 19px; }
.warehouse-title span { color: #71808a; }
.truck-card { background: #fff; border: 2px solid #687b85; border-radius: 7px; margin-bottom: 14px; overflow: hidden; }
.truck-card.overload { border-color: #c83d3d; box-shadow: 0 0 0 1px #c83d3d22; }
.truck-card.low-load { border-color: #d68b18; box-shadow: 0 0 0 1px #d68b1822; }
.truck-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: #f5f8f9; border-bottom: 1px solid #d7dfe3; }
.truck-identity { display: flex; align-items: center; gap: 10px; }
.truck-type { color: #fff; border-radius: 4px; padding: 4px 8px; font-weight: 700; }
.truck-type.box-truck { background: #278052; }
.truck-type.flatbed { background: #2673aa; }
.truck-stats { display: flex; align-items: center; gap: 14px; }
.truck-stats .recalculate-truck { min-height: 30px; padding: 0 10px; }
.capacity-bar { width: 160px; height: 8px; background: #dfe6e9; border-radius: 4px; overflow: hidden; }
.capacity-bar i { display: block; height: 100%; background: #2d8b65; }
.capacity-bar i.low { background: #d99a25; }
.capacity-bar i.over { background: #bf3d3d; }
.truck-warning { color: #9b5d0a; font-weight: 700; }
.truck-warning.over { color: #b32d2d; }
.order-lines span { display: block; line-height: 1.45; }
.dispatch-table th, .dispatch-table td { padding-top: 8px; padding-bottom: 8px; }
.dispatch-table tbody tr.dragging { opacity: .4; }
.dispatch-table tbody tr.drag-over { box-shadow: inset 0 2px #176b78; }
.dispatch-table .destination { white-space: normal; min-width: 270px; }
.quantity-button { min-height: 0; padding: 2px 5px; border: 1px dashed #91a5ae; background: #fff; color: #176b78; }
.truck-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid #e1e6e8; }
.truck-actions .spacer { flex: 1; }
.add-order-list { max-height: 420px; }
.pipe-cart-assignment-panel { display: grid; gap: 10px; padding: 12px; border: 1px solid #d9e2e6; background: #f8fafb; border-radius: 5px; }
.pipe-cart-assignment-title { display: grid; gap: 3px; }
.pipe-cart-assignment-list { display: grid; gap: 10px; max-height: 360px; overflow: auto; }
.pipe-cart-assignment-item { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(240px, 1fr); gap: 12px; padding: 10px; border: 1px solid #dde5e8; background: #fff; border-radius: 5px; }
.pipe-cart-select-grid { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 8px; }
.pipe-cart-select-grid label { display: grid; gap: 5px; color: #4c5b64; }
.plan-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 12px; padding: 14px 16px; border-bottom: 1px solid #e4e8eb; }
.plan-filter-grid label, .order-filter-grid label { display: grid; gap: 6px; color: #4c5b64; }
.plan-status-filter { display: grid; gap: 6px; color: #4c5b64; }
.status-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  padding: 5px;
  border: 1px solid #cbd3d8;
  border-radius: 4px;
  background: #fff;
}
.status-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 86px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid #d7dfe3;
  border-radius: 4px;
  background: #f8fafb;
  color: #26343d;
  cursor: pointer;
}
.status-checkboxes input { width: auto; height: auto; margin: 0; }
.status-checkboxes label:has(input:checked) {
  border-color: #1c7787;
  background: #e4f2f5;
  color: #0f5360;
  font-weight: 600;
}
.order-filter-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; padding: 14px 16px; border-bottom: 1px solid #e4e8eb; }
.master-filter-grid { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(150px, 1fr) minmax(120px, .7fr); gap: 12px; padding: 14px 16px; border-bottom: 1px solid #e4e8eb; }
.master-filter-grid label { display: grid; gap: 6px; color: #4c5b64; }
.address-filter-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)) minmax(120px, .7fr); }
.order-toolbar { border-top: 0; }
.filter-action { align-self: end; }
.filter-action button { width: 100%; }
.plans-table { table-layout: fixed; min-width: 0; }
.plans-table th, .plans-table td { padding-left: 8px; padding-right: 8px; }
.plans-table th, .plans-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}
.plans-table > thead th:nth-child(1) { width: 34px; }
.plans-table > thead th:nth-child(2) { width: 132px; }
.plans-table > thead th:nth-child(3) { width: 82px; }
.plans-table > thead th:nth-child(4) { width: 112px; }
.plans-table > thead th:nth-child(5) { width: 125px; }
.plans-table > thead th:nth-child(6) { width: 94px; }
.plans-table > thead th:nth-child(7) { width: 118px; }
.plans-table > thead th:nth-child(8) { width: 68px; }
.plans-table > thead th:nth-child(9) { width: 82px; }
.plans-table > thead th:nth-child(10) { width: 190px; }
.plans-table .truck-type { display: inline-block; max-width: 100%; white-space: normal; line-height: 1.15; }
.plan-row { border-bottom: 1px solid #dde4e7; }
.expand-plan { width: 27px; min-height: 27px; padding: 0; border: 1px solid #aebbc2; background: #fff; font-size: 18px; }
.plan-number { display: flex; align-items: center; gap: 8px; }
.plan-detail-row { display: none; }
.plan-detail-row.expanded { display: table-row; }
.plan-detail-cell { padding: 10px 14px 14px 48px; background: #f7f9fa; }
.plan-detail-cell table { background: #fff; border: 1px solid #d7e0e4; table-layout: auto; }
.plan-detail-cell tbody tr.dragging { opacity: .4; }
.plan-detail-cell tbody tr.drag-over { box-shadow: inset 0 2px #176b78; }
.plan-detail-cell th, .plan-detail-cell td { white-space: nowrap; }
.plan-detail-cell .address { white-space: normal; min-width: 300px; }
.plan-detail-cell .recipient-cell { white-space: normal; min-width: 150px; }
.plan-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.plan-actions button { min-height: 26px; padding: 0 6px; font-size: 12px; white-space: normal; line-height: 1.15; }
.drag-handle { color: #7c8990; font-size: 17px; cursor: grab; }
.empty-state { padding: 60px; text-align: center; color: #68757d; }
.empty-state h2 { color: #26343d; margin-bottom: 8px; }
dialog { width: 620px; border: 0; border-radius: 7px; padding: 0; box-shadow: 0 18px 50px #0004; }
.wide-dialog { width: min(820px, calc(100vw - 60px)); }
dialog::backdrop { background: #13212a99; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid #dfe5e8; }
.icon-button { width: 32px; padding: 0; border: 0; background: transparent; font-size: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px; }
.form-grid label { display: grid; gap: 6px; color: #4c5b64; }
.form-grid input, .form-grid select { width: 100%; }
.span-2 { grid-column: 1 / -1; }
.time-window-list { display: grid; gap: 8px; }
.time-window-row { display: grid; grid-template-columns: 1fr auto 1fr 32px; align-items: center; gap: 8px; }
.small-button { min-height: 32px; padding: 6px 10px; justify-self: start; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid #dfe5e8; }
.import-body { padding: 18px; }
.file-drop { min-height: 112px; display: grid; place-items: center; align-content: center; gap: 6px; border: 1px dashed #8ca0aa; background: #f7fafb; border-radius: 6px; cursor: pointer; }
.file-drop span, .import-columns span { color: #697780; }
.file-drop input { height: auto; margin-top: 8px; }
.import-columns { display: grid; gap: 5px; margin-top: 14px; padding: 12px; background: #f3f6f7; border-radius: 5px; }
.import-summary { display: flex; gap: 24px; padding: 14px 0 8px; }
.import-summary strong { font-size: 20px; display: block; }
.import-summary span { color: #697780; }
.import-issue-summary { border: 1px solid #e0e5e8; padding: 10px 12px; margin: 8px 0; background: #fbfcfc; }
.import-issue-summary ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.import-issue-summary li { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.import-issue-summary li strong { color: #0f2028; }
.import-errors { max-height: 230px; overflow: auto; border: 1px solid #e0e5e8; }
.import-warnings { border-color: #f0c36a; }
.import-errors td:last-child { white-space: normal; }
#toast { position: fixed; right: 24px; bottom: 24px; color: #fff; background: #24343d; padding: 11px 16px; border-radius: 5px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; }
#toast.show { opacity: 1; transform: translateY(0); }
.muted { color: #7b878e; }
.recipient-line { display: grid; gap: 2px; line-height: 1.35; }
.recipient-line + .recipient-line { margin-top: 6px; padding-top: 6px; border-top: 1px solid #e4eaed; }
.recipient-cell { min-width: 150px; white-space: normal; }
.app-shell.master-readonly .edit-dockdoor,
.app-shell.master-readonly .delete-dockdoor,
.app-shell.master-readonly .edit-truck-type,
.app-shell.master-readonly .delete-truck-type,
.app-shell.master-readonly .edit-unit,
.app-shell.master-readonly .delete-unit {
  display: none;
}
@media (max-width: 1200px) {
  .main { padding-left: 18px; padding-right: 18px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}
