:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #d8dee7;
  --border-strong: #aeb8c6;
  --text: #14213f;
  --muted: #64748b;
  --brand-navy: #17234e;
  --brand-navy-soft: #243765;
  --brand-red: #c51b10;
  --teal: #0f766e;
  --good: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --shadow: 0 18px 45px rgba(20, 33, 63, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(23, 35, 78, 0.07), rgba(23, 35, 78, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.12;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 15px;
}

label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  padding: 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

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

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-logo {
  width: min(260px, 100%);
  height: auto;
}

.credential-hints {
  display: grid;
  gap: 4px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.portal-shell {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(270px, auto) 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--brand-navy);
  color: #ffffff;
  box-shadow: 0 16px 40px rgba(23, 35, 78, 0.18);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-lockup img {
  width: 134px;
  height: 54px;
  object-fit: contain;
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 7px;
  background: #ffffff;
}

.brand-lockup h1,
.brand-lockup h2 {
  color: inherit;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-header .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.section-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
}

.section-nav button,
.portal-chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-weight: 850;
}

.section-nav button.active {
  background: #ffffff;
  color: var(--brand-navy);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  display: grid;
  gap: 1px;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.user-pill span {
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  font-weight: 700;
}

.primary-action,
.secondary-action,
.ghost-button,
.icon-button,
.link-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 850;
  text-decoration: none;
}

.primary-action {
  padding: 8px 14px;
  background: var(--brand-red);
  color: #ffffff;
}

.secondary-action {
  padding: 8px 14px;
  background: var(--teal);
  color: #ffffff;
}

.ghost-button {
  padding: 8px 12px;
  border-color: var(--border);
  background: #ffffff;
  color: #334155;
}

.app-header .ghost-button {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.icon-button {
  width: 36px;
  padding: 0;
  border-color: var(--border);
  background: #ffffff;
  color: #334155;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  display: grid;
  gap: 3px;
  min-height: 72px;
  align-content: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.metric-card strong {
  font-size: 25px;
}

.metric-card span {
  color: var(--muted);
  font-weight: 850;
}

.workspace {
  display: grid;
  gap: 14px;
}

.workspace-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.muted-line {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 650;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(5, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.compact {
  align-self: end;
}

.load-list {
  display: grid;
  gap: 10px;
}

.ops-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(20, 33, 63, 0.06);
}

.ops-table {
  width: 100%;
  min-width: 1940px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.ops-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  background: #eef2f7;
  color: #475569;
  font-size: 11px;
  font-weight: 950;
  text-align: left;
  text-transform: uppercase;
}

.ops-table thead tr:first-child th {
  top: 0;
}

.ops-table .column-filter-row th {
  top: 31px;
  z-index: 3;
  padding: 4px 6px;
  background: #f8fafc;
  text-transform: none;
}

.column-filter-input {
  min-height: 26px;
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #ffffff;
  color: #0f172a;
  font-size: 11px;
  font-weight: 800;
}

.column-filter-input:focus {
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 2px rgba(30, 44, 84, 0.14);
}

.clear-column-button {
  min-height: 26px;
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #ffffff;
  color: #334155;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.ops-table td {
  height: 34px;
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.42);
  background: var(--status-row-bg, #ffffff);
  vertical-align: middle;
  overflow: hidden;
  color: var(--status-row-text, var(--text));
  font-size: 12px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-table tr {
  cursor: pointer;
}

.ops-table tr:hover td {
  background: var(--status-row-hover, #f8fafc);
}

.ops-table tr td:first-child {
  border-left: 5px solid var(--status-color, var(--brand-navy));
}

.ops-table strong,
.ops-table span {
  display: inline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-table strong {
  color: inherit;
  font-size: inherit;
  font-weight: 900;
}

.ops-table span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.ops-actions {
  white-space: nowrap;
}

.row-button {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.88);
  color: #0f172a;
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}

.row-link {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  margin-left: 5px;
  padding: 2px 7px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: #0f172a;
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}

.primary-row-button {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.money-cell {
  color: inherit;
  font-size: 12px;
  font-weight: 950;
}

.positive {
  color: inherit !important;
}

.negative {
  color: inherit !important;
}

.latest-cell {
  max-width: 320px;
}

.ops-table th:nth-child(1) { width: 82px; }
.ops-table th:nth-child(2) { width: 108px; }
.ops-table th:nth-child(3) { width: 210px; }
.ops-table th:nth-child(4) { width: 190px; }
.ops-table th:nth-child(5) { width: 150px; }
.ops-table th:nth-child(6) { width: 250px; }
.ops-table th:nth-child(7) { width: 250px; }
.ops-table th:nth-child(8) { width: 190px; }
.ops-table th:nth-child(9) { width: 190px; }
.ops-table th:nth-child(10) { width: 120px; }
.ops-table th:nth-child(11) { width: 90px; }
.ops-table th:nth-child(12) { width: 90px; }
.ops-table th:nth-child(13) { width: 125px; }
.ops-table th:nth-child(14) { width: 145px; }
.ops-table th:nth-child(15) { width: 115px; }
.ops-table th:nth-child(16) { width: 145px; }
.ops-table th:nth-child(17) { width: 320px; }

.customer-table {
  min-width: 1360px;
}

.customer-table th:nth-child(1) { width: 82px; }
.customer-table th:nth-child(2) { width: 108px; }
.customer-table th:nth-child(3) { width: 180px; }
.customer-table th:nth-child(4) { width: 150px; }
.customer-table th:nth-child(5) { width: 250px; }
.customer-table th:nth-child(6) { width: 250px; }
.customer-table th:nth-child(7) { width: 110px; }
.customer-table th:nth-child(8) { width: 135px; }
.customer-table th:nth-child(9) { width: 185px; }
.customer-table th:nth-child(10) { width: 115px; }
.customer-table th:nth-child(11) { width: 320px; }

.single-line-board .badge {
  min-height: 21px;
  padding: 2px 7px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.88);
  color: #0f172a;
  font-size: 11px;
}

.load-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--status-color, var(--brand-navy));
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(20, 33, 63, 0.06);
}

.load-card-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.load-identity {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.load-identity h3 {
  font-size: 18px;
}

.load-identity p {
  color: var(--muted);
  font-weight: 800;
}

.status-dot {
  width: 11px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: var(--status-color, var(--brand-navy));
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.good {
  background: #dcfce7;
  color: #166534;
}

.badge.warn {
  background: #fef3c7;
  color: #92400e;
}

.badge.bad {
  background: #fee2e2;
  color: #991b1b;
}

.status-needs-booked { --status-color: #b91c1c; --status-row-bg: #b91c1c; --status-row-hover: #991b1b; --status-row-text: #ffffff; }
.status-booked { --status-color: #2563eb; --status-row-bg: #2563eb; --status-row-hover: #1d4ed8; --status-row-text: #ffffff; }
.status-dispatched { --status-color: #7e22ce; --status-row-bg: #7e22ce; --status-row-hover: #6b21a8; --status-row-text: #ffffff; }
.status-on-site-for-pickup { --status-color: #ea580c; --status-row-bg: #ea580c; --status-row-hover: #c2410c; --status-row-text: #ffffff; }
.status-loaded-and-rolling { --status-color: #15803d; --status-row-bg: #15803d; --status-row-hover: #166534; --status-row-text: #ffffff; }
.status-on-site-for-delivery { --status-color: #d97706; --status-row-bg: #fbbf24; --status-row-hover: #f59e0b; --status-row-text: #111827; }
.status-empty-clean { --status-color: #475569; --status-row-bg: #64748b; --status-row-hover: #475569; --status-row-text: #ffffff; }
.status-on-hold { --status-color: #111827; --status-row-bg: #111827; --status-row-hover: #030712; --status-row-text: #ffffff; }

.load-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.info-block {
  min-height: 62px;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 10px;
  border: 1px solid #e6ebf2;
  border-radius: 7px;
  background: var(--surface-muted);
}

.info-block span,
.readonly-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.info-block strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.load-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.customer-card,
.document-row,
.bol-center {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.customer-card p,
.document-row span {
  color: var(--muted);
  font-weight: 750;
}

.document-list {
  display: grid;
  gap: 8px;
}

.document-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.bol-center {
  max-width: 560px;
}

.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(920px, 100vw);
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-head,
.dialog-head,
.drawer-actions,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-actions,
.dialog-actions {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  justify-content: flex-end;
}

.detail-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.detail-tabs button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: #334155;
  font-weight: 850;
}

.detail-tabs button.active {
  border-color: var(--teal);
  background: #ecfdf5;
  color: #115e59;
}

.drawer-body {
  overflow: auto;
  padding: 16px;
}

.detail-grid {
  display: grid;
  gap: 12px;
}

.detail-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-stack {
  display: grid;
  gap: 12px;
}

.span-full {
  grid-column: 1 / -1;
}

.readonly-field {
  min-height: 64px;
  display: grid;
  gap: 5px;
  align-content: start;
  padding: 10px;
  border: 1px solid #e6ebf2;
  border-radius: 7px;
  background: var(--surface-muted);
}

.readonly-field strong {
  overflow-wrap: anywhere;
}

.inline-link {
  color: var(--brand-navy);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.note-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.notes-list {
  display: grid;
  gap: 8px;
}

.note-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.note-item div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.customer-note {
  border-left: 4px solid var(--teal);
}

.embedded {
  padding: 0;
}

.bol-dialog {
  width: min(1060px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.bol-dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
}

.dialog-brand h2 {
  color: var(--text);
}

.dialog-brand .eyebrow {
  color: var(--muted);
}

.dialog-brand img {
  border: 1px solid var(--border);
}

.bol-fields {
  max-height: calc(100vh - 175px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  overflow: auto;
  padding: 16px;
}

.bol-fields label:has(textarea) {
  grid-column: span 2;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

.form-error {
  min-height: 18px;
  color: var(--bad);
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--brand-navy);
  color: #ffffff;
  box-shadow: var(--shadow);
  font-weight: 850;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1100px) {
  .app-header {
    grid-template-columns: 1fr;
  }

  .section-nav {
    justify-content: flex-start;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar,
  .load-card-grid,
  .detail-grid.two,
  .detail-grid.three,
  .bol-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .portal-shell {
    padding: 10px;
  }

  .app-header,
  .workspace-head,
  .load-card-main,
  .document-row,
  .note-composer,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .brand-lockup img {
    width: 118px;
    height: 48px;
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }

  .drawer-panel {
    width: 100vw;
  }
}
