:root {
  color-scheme: light;
  --ink: #05070b;
  --muted: #53565a;
  --line: #d7d4cc;
  --surface: #f4f3ef;
  --panel: #ffffff;
  --yellow: #f2c300;
  --yellow-dark: #c59d00;
  --green: #1f7a4d;
  --amber: #a36a00;
  --red: #c5192d;
  --shadow: 0 18px 42px rgba(15, 18, 22, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

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

h1 {
  font-size: 31px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 23px;
  margin-bottom: 14px;
}

h3 {
  margin: 18px 0 12px;
  font-size: 17px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  min-height: 104px;
  padding: 18px 24px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-lockup img {
  width: 330px;
  max-width: 38vw;
  height: auto;
}

.brand-lockup p,
.eyebrow,
.tiny {
  color: var(--muted);
}

.brand-lockup p,
.eyebrow {
  margin: 0 0 4px;
  color: var(--yellow-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-lockup h1:focus {
  outline: none;
}

nav,
.toolbar,
.dealer-login,
.customer-form,
.settings-grid,
.login-grid,
.filters,
.automation-controls,
.row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

nav {
  justify-content: flex-end;
}

.account-nav {
  display: grid;
  gap: 8px;
  justify-items: end;
  min-width: 0;
}

.signed-in-user {
  display: grid;
  gap: 2px;
  max-width: min(100%, 420px);
  text-align: right;
  overflow-wrap: anywhere;
}

.signed-in-user span,
.signed-in-user small {
  color: var(--muted);
  font-size: 12px;
}

.signed-in-user strong {
  font-size: 15px;
}

nav a,
button,
.button,
input,
select,
textarea {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font: inherit;
  font-size: 14px;
}

nav a,
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
}

nav a:hover,
button:hover,
.button:hover {
  border-color: #9d9a92;
}

button:disabled,
button:disabled:hover {
  border-color: var(--line);
  color: #8b8983;
  background: #efede8;
  cursor: wait;
}

nav a.active {
  background: #111;
  border-color: #111;
  color: #fff;
}

button.primary,
.button.primary {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #090909;
}

button.danger {
  color: var(--red);
}

button.small,
.button.small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

input,
select,
textarea {
  min-width: 220px;
  padding: 0 10px;
  background: #fff;
}

textarea {
  min-height: 66px;
  padding-top: 8px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

main {
  padding: 34px 28px 42px;
}

article {
  max-width: 1360px;
  margin: 0 auto;
}

.login-panel {
  width: min(440px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 280px;
  max-width: 100%;
  height: auto;
  margin-bottom: 18px;
}

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

.login-grid button {
  width: fit-content;
}

.password-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.password-panel summary {
  cursor: pointer;
  font-weight: 800;
}

.password-panel .login-grid {
  margin-top: 12px;
}

.statusline {
  min-height: 22px;
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.work-indicator {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 9px;
  align-items: center;
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid #dedbd2;
  border-top-color: var(--yellow-dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.progress-strip {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #ece9e0;
}

.progress-strip span {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: var(--yellow);
  animation: progress-slide 1.1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes progress-slide {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(270%);
  }
}

.band {
  margin-top: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 18, 22, 0.04);
}

.settings-list,
.automation-list,
.stack {
  display: grid;
  gap: 8px;
}

.connection-settings {
  padding: 12px 14px;
}

.connection-settings h2 {
  margin-bottom: 6px;
}

.connection-settings .statusline {
  min-height: 0;
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.25;
}

.connection-settings .settings-list {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: none;
}

.connection-settings .settings-list .button,
.connection-settings .settings-list button {
  min-height: 30px;
  padding: 0 12px;
  font-size: 12px;
  line-height: 30px;
  white-space: nowrap;
}

.customer-setup h2 {
  margin-bottom: 8px;
}

.customer-setup .statusline:empty {
  display: none;
}

.customer-setup .statusline {
  min-height: 0;
  margin: 0 0 8px;
}

.customer-setup .customer-form {
  margin-bottom: 8px;
}

.customer-setup table {
  table-layout: fixed;
  min-width: 1320px;
}

.customer-setup th:nth-child(1),
.customer-setup td:nth-child(1) {
  width: 205px;
}

.customer-setup th:nth-child(2),
.customer-setup td:nth-child(2) {
  width: 165px;
}

.customer-setup th:nth-child(3),
.customer-setup td:nth-child(3),
.customer-setup th:nth-child(4),
.customer-setup td:nth-child(4) {
  width: 205px;
}

.customer-setup th:nth-child(6),
.customer-setup td:nth-child(6) {
  width: 130px;
}

.customer-setup th:nth-child(7),
.customer-setup td:nth-child(7) {
  width: 82px;
  text-align: center;
}

.customer-setup th:nth-child(8),
.customer-setup td:nth-child(8) {
  width: 170px;
}

.customer-setup .row-actions {
  flex-wrap: nowrap;
  gap: 6px;
}

.customer-setup .row-actions button {
  min-width: 58px;
}

.auth-audit-log {
  max-width: none;
}

.automation-rule,
.audit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfaf7;
  font-size: 13px;
  line-height: 1.22;
}

.filters,
.customer-form {
  align-items: end;
  margin-bottom: 10px;
}

.tablewrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.shipments-table {
  table-layout: fixed;
  min-width: 1160px;
}

.customer-shipments-table {
  table-layout: fixed;
  min-width: 1140px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: top;
  font-size: 12px;
  line-height: 1.22;
}

th {
  background: #efede8;
  text-align: left;
  font-weight: 800;
}

.shipments-table th,
.shipments-table td {
  overflow: hidden;
}

.shipments-table th:nth-child(1),
.shipments-table td:nth-child(1) {
  width: 96px;
}

.shipments-table th:nth-child(2),
.shipments-table td:nth-child(2) {
  width: 124px;
  white-space: nowrap;
}

.shipments-table th:nth-child(5),
.shipments-table td:nth-child(5),
.shipments-table th:nth-child(6),
.shipments-table td:nth-child(6) {
  width: 84px;
  white-space: nowrap;
}

.shipments-table th:nth-child(9),
.shipments-table td:nth-child(9) {
  width: 86px;
}

.shipments-table th:nth-child(10),
.shipments-table td:nth-child(10) {
  width: 210px;
}

.shipments-table th:nth-child(11),
.shipments-table td:nth-child(11) {
  width: 86px;
}

.assign-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.assign-inline select {
  min-width: 0;
  width: 154px;
}

.assign-inline button {
  flex: 0 0 auto;
}

.customer-shipments-table th,
.customer-shipments-table td {
  overflow: hidden;
  overflow-wrap: anywhere;
}

.customer-shipments-table th:nth-child(1),
.customer-shipments-table td:nth-child(1) {
  width: 130px;
}

.customer-shipments-table th:nth-child(2),
.customer-shipments-table td:nth-child(2) {
  width: 185px;
}

.customer-shipments-table th:nth-child(5),
.customer-shipments-table td:nth-child(5),
.customer-shipments-table th:nth-child(6),
.customer-shipments-table td:nth-child(6) {
  width: 110px;
  white-space: nowrap;
}

.customer-shipments-table th:nth-child(7),
.customer-shipments-table td:nth-child(7) {
  width: 112px;
}

.customer-shipments-table th:nth-child(8),
.customer-shipments-table td:nth-child(8) {
  width: 130px;
  white-space: nowrap;
}

.customer-shipments-table th:nth-child(9),
.customer-shipments-table td:nth-child(9) {
  width: 92px;
}

.orders-table {
  table-layout: fixed;
  min-width: 1180px;
}

.customer-work-table {
  min-width: 980px;
}

.customer-work-table th:nth-child(1),
.customer-work-table td:nth-child(1) { width: 105px; }
.customer-work-table th:nth-child(2),
.customer-work-table td:nth-child(2) { width: 110px; }
.customer-work-table th:nth-child(3),
.customer-work-table td:nth-child(3) { width: 150px; }
.customer-work-table th:nth-child(4),
.customer-work-table td:nth-child(4) { width: auto; }
.customer-work-table th:nth-child(5),
.customer-work-table td:nth-child(5) { width: 105px; }
.customer-work-table th:nth-child(6),
.customer-work-table td:nth-child(6) { width: 115px; text-align: right; }
.customer-work-table th:nth-child(7),
.customer-work-table td:nth-child(7) { width: 110px; }
.customer-work-table th:nth-child(8),
.customer-work-table td:nth-child(8) { width: 85px; text-align: right; }
.orders-table.customer-work-table td:nth-child(4) { white-space: normal; overflow-wrap: anywhere; }
.quote-aged-row { background: #fff7e6; }

.nowrap {
  white-space: nowrap;
}

.orders-table th,
.orders-table td {
  overflow: hidden;
  overflow-wrap: anywhere;
}

.orders-table th {
  white-space: nowrap;
  overflow-wrap: normal;
}

.orders-table .nowrap,
.orders-table td:nth-child(2),
.orders-table td:nth-child(4),
.orders-table td:nth-child(5),
.orders-table td:nth-child(6),
.orders-table td:last-child {
  white-space: nowrap;
  overflow-wrap: normal;
}

.backorders-table {
  min-width: 1260px;
}

.dispatch-table {
  min-width: 1160px;
}

.backorders-table th:nth-child(1),
.backorders-table td:nth-child(1),
.dispatch-table th:nth-child(1),
.dispatch-table td:nth-child(1) {
  width: 74px;
}

.backorders-table th:nth-child(2),
.backorders-table td:nth-child(2),
.dispatch-table th:nth-child(2),
.dispatch-table td:nth-child(2) {
  width: 72px;
}

.backorders-table th:nth-child(3),
.backorders-table td:nth-child(3),
.dispatch-table th:nth-child(3),
.dispatch-table td:nth-child(3) {
  width: 164px;
}

.backorders-table th:nth-child(4),
.backorders-table td:nth-child(4),
.backorders-table th:nth-child(5),
.backorders-table td:nth-child(5),
.dispatch-table th:nth-child(4),
.dispatch-table td:nth-child(4),
.dispatch-table th:nth-child(5),
.dispatch-table td:nth-child(5) {
  width: 88px;
}

.backorders-table th:nth-child(6),
.backorders-table td:nth-child(6),
.dispatch-table th:nth-child(6),
.dispatch-table td:nth-child(6) {
  width: 88px;
}

.backorders-table th:nth-child(7),
.backorders-table td:nth-child(7),
.dispatch-table th:nth-child(7),
.dispatch-table td:nth-child(7) {
  width: auto;
}

.backorders-table th:nth-child(8),
.backorders-table td:nth-child(8),
.backorders-table th:nth-child(9),
.backorders-table td:nth-child(9),
.backorders-table th:nth-child(10),
.backorders-table td:nth-child(10),
.dispatch-table th:nth-child(8),
.dispatch-table td:nth-child(8),
.dispatch-table th:nth-child(9),
.dispatch-table td:nth-child(9),
.dispatch-table th:nth-child(10),
.dispatch-table td:nth-child(10),
.dispatch-table th:nth-child(12),
.dispatch-table td:nth-child(12) {
  width: 48px;
  text-align: right;
}

.backorders-table th:nth-child(11),
.backorders-table td:nth-child(11),
.dispatch-table th:nth-child(11),
.dispatch-table td:nth-child(11) {
  width: 118px;
  text-align: right;
}

.backorders-table th:nth-child(12),
.backorders-table td:nth-child(12) {
  width: 88px;
  white-space: nowrap;
}

.backorders-table th:nth-child(13),
.backorders-table td:nth-child(13),
.dispatch-table th:nth-child(13),
.dispatch-table td:nth-child(13) {
  width: 82px;
  text-align: right;
  white-space: nowrap;
}

.dispatch-table th:nth-child(9),
.dispatch-table td:nth-child(9) {
  width: 58px;
}

.dispatch-table th:nth-child(12),
.dispatch-table td:nth-child(12) {
  width: 76px;
}

.tiny {
  font-size: 11px;
  line-height: 1.25;
}

.empty {
  color: var(--muted);
  padding: 10px;
}

.pill {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1f0eb;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.pill.good {
  color: var(--green);
  background: #e9f4ee;
}

.pill.risk {
  color: var(--red);
  background: #fff0f2;
}

.pill.warn {
  color: var(--amber);
  background: #fff4d6;
}

.chips,
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.aged-kpi-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.tracking-dashboard-row {
  margin-top: 10px;
}

.tracking-dashboard-row h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.tracking-days-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.kpi {
  border: 1px solid var(--line);
  background: #fbfaf7;
  border-radius: 8px;
  padding: 10px;
}

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

.kpi strong {
  display: block;
  font-size: 20px;
  margin-top: 4px;
}

.kpi em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.account-summary-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.aged-kpi-grid .kpi {
  padding: 8px;
}

.tracking-days-grid .kpi {
  padding: 8px;
}

.aged-kpi-grid .kpi span {
  font-size: 11px;
}

.tracking-days-grid .kpi span {
  font-size: 11px;
}

.aged-kpi-grid .kpi strong {
  font-size: 15px;
}

.tracking-days-grid .kpi strong {
  font-size: 15px;
}

.kpi.warn {
  background: #fff4d6;
  border-color: #e2b855;
}

.kpi.risk {
  background: #fff0f2;
  border-color: #df7c8a;
}

.run-details {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.automation-audit-log {
  display: block;
  max-width: 980px;
  max-height: 220px;
  overflow: auto;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}

.automation-audit-log div {
  padding: 1px 0;
  border: 0;
}

.automation-audit-log span {
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
}

.row-actions {
  gap: 6px;
  align-items: center;
}

td input,
td select {
  min-width: 150px;
  width: 100%;
}

td button,
td .button {
  min-height: 30px;
  font-size: 12px;
}

.filters input {
  min-width: min(340px, 100%);
}

.filters select {
  min-width: 170px;
}

.customer-form input,
.customer-form select,
.customer-form textarea {
  min-width: 180px;
}

.automation-list,
.settings-list {
  max-width: 760px;
}

.automation-list {
  gap: 6px;
}

.automation-list .automation-rule {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  gap: 8px 14px;
  padding: 6px 8px;
  background: #fff;
}

.automation-list .automation-rule label.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.automation-list .automation-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.automation-list .automation-controls label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 238px;
  font-size: 11px;
  white-space: nowrap;
}

.automation-list input[type="time"],
.automation-list input[type="number"] {
  width: 88px;
  min-width: 88px;
  min-height: 30px;
  padding: 0 8px;
}

.check-row input {
  min-width: 0;
  width: 15px;
  min-height: 15px;
}

.automation-list button {
  min-height: 30px;
  padding: 0 10px;
  white-space: nowrap;
}

.automation-list > button.primary {
  width: fit-content;
  min-width: 132px;
  min-height: 32px;
  justify-self: start;
}

.band:has(table) {
  padding: 16px;
}

.orders-header {
  padding: 14px 16px;
}

.orders-header h2 {
  margin-bottom: 10px;
}

.orders-header .statusline:empty {
  display: none;
}

.orders-header .filters {
  margin-bottom: 6px;
}

.orders-header .tiny {
  margin-top: 0;
}

.orders-header .kpi-grid {
  margin-bottom: 10px;
}

.review-queue {
  padding: 12px 14px;
}

.review-queue h2 {
  margin-bottom: 6px;
}

.review-queue .statusline:empty {
  display: none;
}

.review-queue .statusline {
  min-height: 0;
  margin: 0 0 8px;
}

.review-queue .stack {
  gap: 6px;
}

.review-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  align-items: center;
  background: #fff;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.18;
}

.review-card > strong {
  font-size: 13px;
  line-height: 1.1;
}

.review-card .tiny {
  white-space: normal;
  font-size: 10px;
  line-height: 1.2;
}

.review-card .row-actions {
  grid-row: 1 / span 5;
  grid-column: 2;
  gap: 6px;
  flex-wrap: nowrap;
}

.review-card select {
  min-width: 170px;
  min-height: 30px;
  font-size: 12px;
}

.review-card button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.review-card .pill {
  justify-self: start;
  min-height: 18px;
  padding: 1px 7px;
  font-size: 10px;
}

.track-link {
  color: #05070b;
  font-weight: 800;
  text-decoration-color: var(--yellow-dark);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

#blazor-error-ui {
  color-scheme: light only;
  background: lightyellow;
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .brand-lockup img {
    max-width: 88vw;
  }

  nav {
    justify-content: flex-start;
    width: 100%;
  }

  .account-nav {
    justify-items: start;
    width: 100%;
  }

  .signed-in-user {
    text-align: left;
  }

  nav a {
    flex: 1 1 auto;
  }

  main {
    padding: 26px 14px 36px;
  }

  .automation-list .automation-rule {
    grid-template-columns: 1fr;
  }

  .automation-list .automation-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

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

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