:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f2f4f7;
  --surface-quiet: rgba(255, 255, 255, 0.8);
  --ink: #111827;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: rgba(17, 24, 39, 0.1);
  --line-soft: rgba(17, 24, 39, 0.06);
  --accent: #0f766e;
  --accent-strong: #0b5a54;
  --ok: #157347;
  --warn: #9a6700;
  --bad: #b93815;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-soft: 0 14px 38px rgba(17, 24, 39, 0.045);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.06), transparent 24%),
    radial-gradient(circle at top left, rgba(17, 24, 39, 0.05), transparent 30%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(17, 24, 39, 0.018) 1px, transparent 1px);
  background-size: 100% 40px;
  opacity: 0.4;
}

.app-shell {
  width: min(1520px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.overline,
.status-key,
.stat-label,
label span,
.feedback,
summary,
th,
.pill {
  font-family: "IBM Plex Mono", monospace;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
  gap: 28px;
  align-items: end;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.overline {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 10px;
}

h1 {
  font-size: clamp(2.2rem, 3.6vw, 3.8rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
}

.subline {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 1rem;
  max-width: 56ch;
}

.status-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  justify-content: flex-end;
  align-items: flex-end;
  padding-bottom: 8px;
}

.status-item {
  display: inline-grid;
  gap: 4px;
  min-width: 120px;
}

.status-item strong {
  font-size: 0.96rem;
  font-weight: 700;
}

.status-detail {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.status-item-wide {
  min-width: 180px;
}

.status-key {
  color: var(--muted-2);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  padding: 24px 0 28px;
}

.metric {
  min-height: 72px;
  display: grid;
  align-content: center;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.metric:first-child {
  border-left: none;
  padding-left: 0;
}

.stat-label {
  display: block;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
}

.stat-value {
  display: block;
  margin-top: 8px;
  font-size: 2.45rem;
  line-height: 0.94;
  letter-spacing: -0.04em;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(360px, 0.95fr);
  gap: 36px;
  align-items: start;
}

.primary-zone {
  display: grid;
  gap: 32px;
}

.task-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(270px, 0.8fr);
  gap: 28px;
  padding: 22px 0 26px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stage-main,
.stage-side {
  padding-right: 8px;
}

.section-head {
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 1.38rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.section-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.section-head-compact h2 {
  font-size: 1.04rem;
}

.section-head-compact p {
  font-size: 0.82rem;
}

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

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted-2);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

input,
textarea,
button {
  width: 100%;
  border-radius: var(--radius-sm);
  font-size: 0.98rem;
}

input,
textarea {
  padding: 12px 13px;
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
  background: var(--surface);
  border: 1px solid var(--line);
}

select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 11px 12px;
  font-size: 0.92rem;
  font-family: "Space Grotesk", sans-serif;
  background: var(--surface);
  color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.08);
}

button {
  cursor: pointer;
  border: 1px solid rgba(15, 118, 110, 0.12);
  padding: 11px 14px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.button-link {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  background: transparent;
}

.bag-calculator {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin: 4px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.bag-calculator-results {
  display: grid;
  gap: 8px;
}

.bag-calculator-note {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.condition-panel {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 118, 110, 0.16);
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.06), rgba(15, 118, 110, 0.03));
}

.condition-panel.is-hidden {
  display: none;
}

.condition-kicker {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.condition-code {
  margin-top: 4px;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.condition-copy {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.condition-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.confirm-ok {
  background: #1f7a45;
}

.confirm-ok:hover {
  background: #15663a;
}

.confirm-damaged {
  background: #ab3f2c;
}

.confirm-damaged:hover {
  background: #913523;
}

.feedback {
  min-height: 1.1rem;
  margin-top: 10px;
  color: var(--muted-2);
  font-size: 0.78rem;
}

.feedback.success {
  color: var(--ok);
}

.feedback.error {
  color: var(--bad);
}

.data-surface {
  padding-top: 4px;
}

.assignments-search-wrap {
  margin: 8px 0 14px;
  max-width: 560px;
}

.surface-divider {
  height: 1px;
  background: var(--line);
  margin: 22px 0;
}

.table-wrap {
  overflow: auto;
  border: none;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.assignments-table-wrap {
  max-height: 360px;
}

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

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

thead th {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  background: transparent;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: rgba(17, 24, 39, 0.018);
}

.insight-rail {
  position: sticky;
  top: 10px;
  display: grid;
  gap: 28px;
}

.report-surface {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}

.protected-surface .is-hidden {
  display: none;
}

.lock-panel {
  display: grid;
  gap: 12px;
  padding: 18px 0 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line-soft);
}

.report-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}

.report-date-picker {
  min-width: 220px;
  display: grid;
  gap: 6px;
  align-self: end;
}

.report-date-picker span {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.protected-actions {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 12px;
}

.secondary-button {
  width: auto;
  min-width: 200px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.report-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.report-upload {
  margin-top: 4px;
  padding: 14px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  background: transparent;
}

.report-upload-copy h3 {
  font-size: 0.98rem;
}

.report-upload-copy p {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.file-trigger {
  position: relative;
  min-width: 156px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.file-trigger input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.report-accordion {
  margin-top: 18px;
}

.report-accordion summary,
.utility-surface summary {
  cursor: pointer;
  list-style: none;
  color: var(--accent-strong);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.report-accordion summary::-webkit-details-marker,
.utility-surface summary::-webkit-details-marker {
  display: none;
}

.report-section + .report-section {
  margin-top: 18px;
}

.report-section-head {
  margin-bottom: 10px;
}

.report-section-head h3 {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.report-section-head p {
  margin-top: 3px;
  font-size: 0.82rem;
  color: var(--muted);
}

.report-summary {
  display: grid;
  gap: 2px;
}

.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
  margin: 14px 0 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.discrepancy-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 6px 0 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}

.checkbox-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
  color: var(--muted);
}

.checkbox-row input {
  width: auto;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 12px 0;
  background: transparent;
}

.summary-main {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.summary-meta,
.report-meta,
.report-product-metric,
.order-title {
  color: var(--muted);
  font-size: 0.8rem;
}

.report-list {
  display: grid;
  gap: 12px;
}

.report-list-compact {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.company-report {
  padding: 14px 0;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
}

.company-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.company-summary {
  display: block;
  list-style: none;
  cursor: pointer;
}

.company-summary::-webkit-details-marker {
  display: none;
}

.company-name {
  font-size: 1rem;
  font-weight: 700;
}

.driver-report {
  margin-top: 12px;
  padding: 12px 0 0;
  border: none;
  border-top: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
}

.driver-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.report-name {
  font-size: 0.92rem;
  font-weight: 700;
}

.report-boxes {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.order-report {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.report-product-list {
  display: grid;
  gap: 6px;
}

.report-product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
}

.utility-surface {
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.detail-grid {
  margin-top: 16px;
  display: grid;
  gap: 18px;
}

.detail-card {
  border: none;
  border-top: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
  padding: 14px 0 0;
}

.empty-state {
  color: var(--muted-2);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.7rem;
  font-weight: 500;
}

.pill.ok {
  color: #165b36;
  border-color: rgba(21, 115, 71, 0.18);
  background: rgba(21, 115, 71, 0.08);
}

.pill.warn {
  color: #7d5b00;
  border-color: rgba(154, 103, 0, 0.18);
  background: rgba(154, 103, 0, 0.08);
}

.pill.bad {
  color: #8d321a;
  border-color: rgba(185, 56, 21, 0.18);
  background: rgba(185, 56, 21, 0.08);
}

.pill.neutral {
  color: #475467;
  border-color: rgba(71, 84, 103, 0.16);
  background: rgba(71, 84, 103, 0.08);
}

@media (max-width: 1220px) {
  .workspace,
  .topbar {
    grid-template-columns: 1fr;
  }

  .status-inline {
    justify-content: flex-start;
  }

  .insight-rail {
    position: static;
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 16px, 1520px);
    padding-top: 16px;
  }

  .task-stage,
  .metrics-strip,
  .report-upload,
  .discrepancy-filters,
  .analytics-kpi-grid,
  .condition-actions,
  .inline-fields,
  .summary-row,
  .report-product-row {
    grid-template-columns: 1fr;
  }

  .status-inline {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .metric {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--line-soft);
    padding-top: 12px;
  }

  .metric:first-child {
    border-top: none;
    padding-top: 0;
  }

  .report-actions {
    justify-content: stretch;
  }

  .report-date-picker,
  .secondary-button,
  .file-trigger {
    width: 100%;
  }
}
