:root {
  --ink: #17211e;
  --muted: #66736d;
  --line: #dbe5df;
  --surface: #ffffff;
  --canvas: #f4f7f4;
  --green: #17745a;
  --green-dark: #10513f;
  --green-soft: #e3f1ea;
  --amber: #e9a341;
  --amber-soft: #fff3d9;
  --coral: #c65b4f;
  --shadow: 0 12px 32px rgba(28, 56, 45, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar__inner,
.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar__inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0;
}

.brand__mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
}

.brand strong,
.brand small { display: block; }
.brand strong { font-size: 15px; line-height: 1.1; letter-spacing: .04em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .18em; font-weight: 700; }

.topbar__status,
.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-dot,
.sync-state__dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--amber);
}

.page-shell { padding: 44px 0 64px; }

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(30px, 4vw, 46px); line-height: 1.04; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 22px; line-height: 1.15; letter-spacing: 0; }
h3 { margin-bottom: 4px; font-size: 16px; line-height: 1.2; }
.intro__meta { margin: 0; color: var(--muted); font-size: 14px; }

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.button svg { width: 16px; height: 16px; }
.button--primary { background: var(--green); color: #fff; }
.button--primary:hover { background: var(--green-dark); }
.button--primary:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .46; }

.filter-strip {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  align-items: end;
  gap: 22px;
  padding: 18px 20px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field span,
.context-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  height: 38px;
  border: 1px solid #bfcfc6;
  border-radius: 6px;
  padding: 0 11px;
  color: var(--ink);
  background: #fbfdfb;
  outline: none;
}

.field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 116, 90, .13); }
.context-label { margin-bottom: 2px; }
.filter-strip__context strong { font-size: 14px; }
.sync-state { justify-self: end; padding-bottom: 10px; white-space: nowrap; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 42px;
}

.metric {
  min-height: 104px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric--accent { background: var(--amber-soft); border-color: #f2d7a4; }
.metric--dark { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.metric__label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric--dark .metric__label { color: #c9e4d7; }
.metric__value { font-size: 26px; letter-spacing: 0; }

.content-section { width: 100%; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 16px; }
.section-count { color: var(--muted); font-size: 13px; font-weight: 800; }

.loads { display: grid; gap: 16px; }
.load-card { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.load-card__header { display: flex; justify-content: space-between; gap: 24px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.load-card__title { display: flex; align-items: center; gap: 10px; }
.load-card__title h3 { margin: 0; font-size: 19px; }
.load-card__sub { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.load-card__badges { display: flex; align-items: center; justify-content: end; flex-wrap: wrap; gap: 7px; }

.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge--green { background: var(--green-soft); color: var(--green-dark); }
.badge--amber { background: var(--amber-soft); color: #8b5a10; }

.orders { padding: 0 22px; }
.order-row { display: grid; grid-template-columns: minmax(210px, 1.4fr) minmax(180px, 1fr) auto; align-items: center; gap: 20px; padding: 19px 0; border-bottom: 1px solid var(--line); }
.order-row:last-child { border-bottom: 0; }
.order-row__identity { min-width: 0; }
.order-row__identity h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-row__identity p, .order-row__address { margin: 0; color: var(--muted); font-size: 12px; }
.order-row__address { line-height: 1.35; }
.order-row__address strong { display: block; margin-bottom: 3px; color: var(--ink); font-size: 12px; }
.order-row__action { display: flex; align-items: center; justify-content: end; gap: 14px; }
.order-row__total { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.order-row__total strong { display: block; color: var(--ink); font-size: 15px; }
.button--quiet { min-height: 34px; padding: 0 10px; border-color: var(--line); background: #fff; color: var(--green-dark); }
.button--quiet:hover { border-color: var(--green); background: var(--green-soft); }

.order-detail { grid-column: 1 / -1; display: none; padding: 0 0 18px; }
.order-detail.is-open { display: block; }
.order-detail__grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; padding: 16px; border-left: 3px solid var(--green); background: #f8fbf9; }
.detail-block__label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.detail-block p { margin: 0; font-size: 13px; }
.items-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.items-table th { padding: 0 0 8px; color: var(--muted); font-size: 10px; text-align: left; text-transform: uppercase; letter-spacing: .05em; }
.items-table td { padding: 8px 8px 0 0; border-top: 1px solid var(--line); vertical-align: top; }
.items-table td:last-child, .items-table th:last-child { padding-right: 0; text-align: right; }
.detail-footer { display: flex; justify-content: end; margin-top: 14px; }

.loading-state, .empty-state, .error-state { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 10px; padding: 30px; color: var(--muted); text-align: center; background: var(--surface); border: 1px dashed #c8d7ce; border-radius: 8px; }
.error-state { color: var(--coral); border-color: #efc1bb; }
.spinner { width: 22px; height: 22px; border: 3px solid #cfe0d6; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer-note { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px 28px; color: var(--muted); font-size: 12px; text-align: center; }
.footer-note svg { width: 15px; height: 15px; color: var(--green); flex: 0 0 auto; }

@media (max-width: 760px) {
  .topbar__inner, .page-shell { width: min(100% - 28px, 620px); }
  .topbar__inner { min-height: 64px; }
  .topbar__status { font-size: 10px; }
  .page-shell { padding-top: 30px; }
  .intro { align-items: start; flex-direction: column; }
  .intro .button { width: 100%; }
  .filter-strip { grid-template-columns: 1fr 1fr; gap: 14px; padding: 15px; }
  .filter-strip__context { grid-column: 1 / -1; order: 3; }
  .sync-state { justify-self: end; align-self: center; padding: 0; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 32px; }
  .metric { min-height: 92px; padding: 14px; }
  .metric__value { font-size: 22px; }
  .load-card__header { align-items: start; flex-direction: column; gap: 14px; padding: 17px; }
  .load-card__badges { justify-content: start; }
  .orders { padding: 0 17px; }
  .order-row { grid-template-columns: 1fr auto; gap: 12px; }
  .order-row__address { grid-column: 1 / -1; }
  .order-row__action { grid-column: 1 / -1; justify-content: space-between; }
  .order-row__total { text-align: left; }
  .order-detail__grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .topbar__status { max-width: 128px; text-align: right; }
  .filter-strip { grid-template-columns: 1fr; }
  .sync-state { justify-self: start; }
  .filter-strip__context { grid-column: auto; }
  .metrics { gap: 8px; }
  .metric__label { font-size: 11px; }
}

.is-hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.topbar__actions { display: flex; align-items: center; gap: 16px; }
.topbar__actions .button { min-height: 34px; }
.button--full { width: 100%; }
.button--quiet svg, .button--primary svg { flex: 0 0 auto; }
.rotate-180 { transform: rotate(180deg); }

.login-view { min-height: 100vh; background: var(--canvas); }
.login-shell { width: min(1040px, calc(100% - 40px)); min-height: calc(100vh - 73px); margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 420px); align-items: center; gap: 76px; padding: 68px 0; }
.login-intro { max-width: 590px; }
.login-intro h1 { max-width: 560px; margin-bottom: 18px; font-size: clamp(34px, 5vw, 58px); }
.login-intro > p:not(.eyebrow) { max-width: 530px; color: var(--muted); font-size: 16px; }
.login-trust { display: inline-flex; align-items: center; gap: 9px; margin-top: 24px; padding: 11px 13px; border: 1px solid #c9ded3; border-radius: 8px; background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 800; }
.login-trust svg { width: 17px; height: 17px; flex: 0 0 auto; }
.login-card { padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.login-card__heading { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand__mark--small { width: 38px; height: 38px; }
.login-card h2 { font-size: 23px; }
.login-card .eyebrow { margin-bottom: 4px; }
.field--stacked { display: block; margin-bottom: 16px; }
.field--stacked span { margin-bottom: 7px; }
.field--stacked input, .field--stacked textarea { width: 100%; border: 1px solid #bfcfc6; border-radius: 6px; padding: 10px 11px; color: var(--ink); background: #fbfdfb; outline: none; }
.field--stacked input { height: 44px; }
.field--stacked textarea { resize: vertical; line-height: 1.45; }
.field--stacked input:focus, .field--stacked textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 116, 90, .13); }
.form-error { min-height: 21px; margin: 0 0 8px; color: var(--coral); font-size: 12px; font-weight: 800; }
.login-card__note { margin: 17px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.evidence-panel { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); scroll-margin-top: 20px; }
.section-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.evidence-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 16px; }
.evidence-form, .aside-card, .signature-card { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.capture-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.capture-card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: #fbfdfb; }
.capture-card__heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.capture-card__heading > div { min-width: 0; }
.capture-card__heading strong, .capture-card__heading span { display: block; }
.capture-card__heading strong { font-size: 14px; }
.capture-card__heading span { margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 700; }
.capture-card__heading .button { min-height: 34px; padding: 0 10px; font-size: 11px; }
.capture-empty { min-height: 154px; margin-top: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; padding: 18px; border: 1px dashed #bfd4c7; border-radius: 6px; color: var(--muted); font-size: 11px; font-weight: 700; text-align: center; }
.capture-empty svg { width: 26px; height: 26px; color: var(--green); }
.capture-preview { width: 100%; height: 154px; margin-top: 13px; display: block; border-radius: 6px; background: #eef4f0; object-fit: cover; }
.signature-card { margin-top: 12px; }
.signature-card canvas { width: 100%; height: 150px; margin-top: 12px; display: block; border: 1px dashed #bfd4c7; border-radius: 6px; background: #fff; touch-action: none; }
.evidence-form > .field { margin-top: 14px; margin-bottom: 0; }
.evidence-form__actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.evidence-form__actions .button { min-height: 46px; }
.form-hint { color: var(--muted); font-size: 11px; line-height: 1.35; }
.evidence-aside { display: grid; align-content: start; gap: 12px; }
.aside-card { box-shadow: none; }
.aside-card__text { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.aside-card .button { margin-top: 15px; }
.location-result { display: grid; gap: 4px; margin-top: 14px; padding: 11px; border-left: 3px solid var(--green); background: var(--green-soft); color: var(--green-dark); font-size: 11px; }
.location-result a { color: var(--green-dark); font-weight: 800; }
.checklist { display: grid; gap: 10px; margin: 15px 0 0; padding: 0; list-style: none; }
.checklist li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.checklist svg { width: 16px; height: 16px; }
.checklist li.is-done { color: var(--green-dark); }
.checklist li.is-done svg { color: var(--green); }

.history-section { margin-top: 48px; }
.history-list { display: grid; gap: 8px; }
.history-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 18px; padding: 15px 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.history-row > div:first-child { min-width: 0; }
.history-row strong, .history-row span { display: block; }
.history-row strong { font-size: 13px; }
.history-row > div:first-child span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.history-row__location { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.history-row__location svg { width: 15px; height: 15px; color: var(--green); }
.history-row__actions { display: flex; align-items: center; gap: 9px; }
.history-row__actions .badge { font-size: 10px; }
.icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--green-dark); }
.icon-button:hover { border-color: var(--green); background: var(--green-soft); }
.icon-button svg { width: 16px; height: 16px; }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 18px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(23, 33, 30, .62); }
.modal__card { position: relative; width: min(560px, 100%); padding: 20px; background: var(--surface); border-radius: 8px; box-shadow: 0 18px 60px rgba(0, 0, 0, .24); }
.modal__heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.modal__heading h2 { font-size: 20px; }
.modal__heading .eyebrow { margin-bottom: 4px; }
.camera-video { width: 100%; max-height: 58vh; display: block; border-radius: 6px; background: #101817; object-fit: contain; }
.camera-status { min-height: 22px; margin: 12px 0 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.modal__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 30; display: grid; gap: 8px; width: min(360px, calc(100% - 36px)); }
.toast { display: flex; align-items: start; gap: 9px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font-size: 12px; font-weight: 800; }
.toast svg { width: 17px; height: 17px; flex: 0 0 auto; }
.toast--success svg { color: var(--green); }
.toast--error { border-color: #efc1bb; color: var(--coral); }
.toast--error svg { color: var(--coral); }
.spinner--small { width: 16px; height: 16px; border-width: 2px; }

@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; gap: 30px; max-width: 620px; padding: 42px 0 58px; }
  .login-intro h1 { font-size: clamp(34px, 9vw, 52px); }
  .evidence-layout { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .topbar__actions { gap: 8px; }
  .topbar__actions .topbar__status { max-width: 130px; }
  .topbar__actions .button span { display: none; }
  .login-shell { width: min(100% - 28px, 620px); padding-top: 30px; }
  .login-card { padding: 21px; }
  .capture-grid { grid-template-columns: 1fr; }
  .evidence-form, .aside-card, .signature-card { padding: 15px; }
  .evidence-form__actions { align-items: stretch; flex-direction: column; }
  .evidence-form__actions .button { width: 100%; }
  .history-row { grid-template-columns: 1fr auto; gap: 10px; }
  .history-row__location { grid-column: 1 / -1; }
}
