:root {
  color-scheme: light;
  --bg: #fff5f5;
  --surface: #ffffff;
  --line: #dfe6e2;
  --line-strong: #c7d1cc;
  --text: #1c2522;
  --muted: #6d5d60;
  --primary: #b11226;
  --primary-dark: #7f0d1b;
  --accent: #d79b22;
  --warning: #b7791f;
  --danger: #b42318;
  --soft: #fff0f2;
  --shadow: 0 14px 38px rgba(87, 16, 27, 0.16);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 40px;
  padding: 0 16px;
  font-weight: 700;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 40px;
  padding: 9px 10px;
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(177, 18, 38, 0.14);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.password-toggle:hover {
  background: var(--soft);
  color: var(--primary-dark);
}

.password-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle::after {
  content: "";
  position: absolute;
  width: 21px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0;
  transform: rotate(-42deg);
}

.password-toggle.is-visible::after {
  opacity: 1;
}

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

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f8faf9;
}

td {
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.credential-note {
  display: block;
  font-weight: 900;
}

.credential-note + small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

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

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  background: var(--soft);
  color: var(--primary-dark);
  border: 1px solid #f0cbd0;
}

.ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-strong);
}

.compact {
  min-height: 34px;
  padding: 0 12px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 42%),
    linear-gradient(315deg, rgba(72, 0, 12, 0.30), transparent 38%),
    #b11226;
}

.login-panel {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 12px 0 4px;
  font-size: 30px;
  line-height: 1.08;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #b11226;
  color: #ffffff;
  font-weight: 900;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.demo-logins {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

.error-text {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  background: #9d1021;
  color: #fff2f3;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.company-lockup {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 6px 22px;
}

.company-lockup span {
  display: block;
  margin-top: 2px;
  color: #ffd9de;
  font-size: 13px;
}

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

.nav-list button {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  width: 100%;
  color: #ffe8eb;
  background: transparent;
  border: 1px solid transparent;
  font-weight: 700;
}

.nav-list button:hover,
.nav-list button.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.10);
}

.nav-icon {
  width: 22px;
  text-align: center;
  color: #ffd15d;
}

.workspace {
  min-width: 0;
  padding: 22px;
  background: linear-gradient(#b11226 0 182px, #fff5f5 182px 100%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: #ffd9de;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar h2 {
  margin: 0;
  color: #ffffff;
  font-size: 28px;
  line-height: 1.12;
}

.user-strip {
  display: flex;
  gap: 12px;
  align-items: center;
}

.user-meta {
  text-align: right;
}

.user-meta span {
  display: block;
  margin-top: 2px;
  color: #ffd9de;
  font-size: 13px;
}

.topbar .user-meta strong {
  color: #ffffff;
}

.topbar .ghost {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.55);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

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

.metric {
  min-height: 112px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.metric strong {
  display: block;
  margin-top: 9px;
  font-size: 28px;
  line-height: 1.1;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

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

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

.contact-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffafa;
  padding: 14px;
}

.contact-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.contact-card small {
  display: block;
  margin-top: 6px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 900;
}

.contact-card strong {
  display: block;
  margin-top: 7px;
  font-size: 17px;
}

.founder-card strong {
  font-size: 19px;
}

.contact-phone,
.field-hint a {
  display: inline-block;
  margin-top: 7px;
  color: var(--primary-dark);
  font-weight: 900;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.rate-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.route-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 16px;
}

.rate-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefd;
  padding: 16px;
}

.route-card span,
.rate-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.route-card strong {
  display: block;
  margin-top: 8px;
  font-size: 17px;
  line-height: 1.25;
}

.route-card dl {
  display: grid;
  gap: 7px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.route-card div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
}

.route-card dt {
  font-weight: 900;
}

.route-card dd {
  margin: 0;
  color: var(--text);
  font-weight: 800;
  text-align: left;
  overflow-wrap: anywhere;
}

.rate-card dl {
  display: grid;
  gap: 9px;
  margin: 12px 0 0;
}

.rate-card dl > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rate-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.rate-card dd {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
}

.rate-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rate-scale {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  max-height: 220px;
  overflow: auto;
}

.rate-scale span {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  background: #f7f4f2;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.field-hint {
  margin-top: -4px;
  padding: 11px 12px;
  border: 1px solid #f0cbd0;
  border-radius: 8px;
  background: #fffafa;
  color: var(--muted);
  font-size: 13px;
}

.field-hint strong {
  color: var(--text);
}

.price-hint {
  background: #fbfcfb;
  border-color: var(--line);
}

.contact-inline {
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.section-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.section-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.filters {
  display: flex;
  gap: 10px;
  width: min(440px, 100%);
}

.filters input,
.filters select {
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.form-grid.single {
  grid-template-columns: 1fr;
  padding: 0;
  margin-top: 22px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.span-2 {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.loading,
.badge.on_road {
  background: #fff4df;
  color: #8a4b00;
}

.badge.problem {
  background: #fde7e4;
  color: var(--danger);
}

.badge.delivered,
.badge.arrived {
  background: #fff0f2;
  color: var(--primary-dark);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  padding: 3px;
  background: #eef3f1;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-height: 34px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(26, 42, 36, 0.08);
}

.entity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.entity-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfb;
}

.entity-card strong {
  display: block;
  font-size: 18px;
  margin-bottom: 6px;
}

.entity-card dl {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #7f0d1b;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.toast.error {
  background: var(--danger);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .nav-list button {
    justify-content: center;
  }

  .metric-grid,
  .contact-grid,
  .route-grid,
  .rate-grid,
  .entity-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 14px;
  }

  .topbar,
  .section-head,
  .user-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .user-meta {
    text-align: left;
  }

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

  .metric-grid,
  .contact-grid,
  .route-grid,
  .rate-grid,
  .entity-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .filters {
    width: 100%;
    flex-direction: column;
  }

  .login-panel {
    padding: 24px;
  }
}
