:root {
  color-scheme: light;
  font-family: "Nirmala UI", "Segoe UI", Arial, sans-serif;
  color: #14262d;
  background: #edf3f4;
  --ink: #14262d;
  --muted: #596b72;
  --line: #c8d5d8;
  --line-soft: #e4ebed;
  --panel: #ffffff;
  --primary: #0b5d52;
  --primary-dark: #08463e;
  --primary-soft: #e2f0ed;
  --navy: #173f59;
  --blue-soft: #e8f2f6;
  --amber: #8b5709;
  --amber-soft: #fff2d8;
  --red: #a9231b;
  --red-soft: #fdecea;
  --green: #1c6b3c;
  --green-soft: #e4f3e9;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { max-width: 100%; overflow-x: hidden; }
body { margin: 0; min-width: 320px; background: #edf3f4; color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-gate {
  display: grid;
  min-height: 100vh;
  padding: 22px 14px;
  place-items: center;
  background: #dfeaec;
}
.login-card {
  width: min(100%, 410px);
  padding: 26px 22px;
  border: 1px solid #bfd0d4;
  border-top: 5px solid var(--primary);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(24, 54, 65, .13);
}
.login-eyebrow { margin: 0 0 5px; color: var(--primary); font-size: 11px; font-weight: 900; }
.login-card h1 { font-size: 24px; }
.login-copy { margin: 7px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.login-card label + label { margin-top: 14px; }
.password-input-wrap { position: relative; display: block; }
.password-input-wrap input { padding-right: 82px; }
.password-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 70px;
  min-height: 38px;
  padding: 6px 9px;
  border: 0;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}
.login-message { min-height: 21px; margin: 9px 0 5px; color: var(--red); font-size: 13px; font-weight: 800; }
.login-button { width: 100%; margin-top: 3px; }

.app-shell { min-height: 100vh; padding-bottom: 82px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px 12px;
  border-top: 4px solid var(--primary);
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.topbar-actions { display: flex; align-items: center; gap: 7px; }
.access-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #b9ddd6;
  border-radius: 7px;
  background: #e8f6f2;
  color: #075f53;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.logout-button { min-height: 40px; padding: 8px 10px; border-color: #b85b54; background: #fff; color: #8a211b; }
.eyebrow { margin: 0 0 2px; color: var(--primary); font-size: 10px; font-weight: 800; }
h1 { margin: 0; font-size: 21px; line-height: 1.2; }
h2 { margin: 2px 0 0; font-size: 19px; }
h3 { margin: 0 0 12px; font-size: 16px; }

.master-status {
  padding: 8px 16px;
  border-bottom: 1px solid #b8d8cf;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.master-status.error { border-color: #efb7b3; background: var(--red-soft); color: var(--red); }

.stepper {
  position: sticky;
  top: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(9, minmax(78px, 1fr));
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.step-tab {
  min-width: 0;
  min-height: 56px;
  padding: 7px 4px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  scroll-snap-align: center;
}
.step-tab span {
  display: grid;
  width: 23px;
  height: 23px;
  margin: 0 auto 2px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #f5f8f9;
  font-size: 11px;
}
.step-tab.active { border-bottom-color: var(--primary); color: var(--primary); }
.step-tab.active span { border-color: var(--primary); background: var(--primary); color: #fff; }
.step-tab.done span { border-color: var(--green); background: var(--green-soft); color: var(--green); }

.content { width: min(100%, 780px); margin: 0 auto; padding: 14px 12px 26px; }
.step-panel { display: none; }
.step-panel.active { display: block; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 1px 1px 13px;
}
.section-head span { color: var(--primary); font-size: 11px; font-weight: 800; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}
.module-link { text-decoration: none; white-space: nowrap; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.button.secondary { background: #fff; color: var(--primary); }
.button.quiet { min-height: 40px; padding: 8px 10px; border-color: var(--line); background: #fff; color: #42545b; }
.button.compact { min-height: 42px; padding: 8px 12px; }

.lookup-row { display: flex; align-items: end; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
label { display: grid; gap: 6px; color: #24383f; font-size: 13px; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 11px;
  border: 1px solid #9fb2b9;
  border-radius: 6px;
  outline: none;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 82px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11, 93, 82, .13); }
input[readonly] { background: #eef3f4; color: #45575e; }
.invalid { border-color: var(--red) !important; background: #fff8f7 !important; }
.field-message { min-height: 20px; margin: 6px 1px 9px; color: var(--muted); font-size: 12px; }
.field-message.error { color: var(--red); font-weight: 700; }
.field-message.success { color: var(--green); font-weight: 700; }

.consumer-summary, .form-section, .review-summary {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
}
.consumer-summary { padding: 13px; border-left: 4px solid var(--primary); }
.identity-row, .section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.identity-row span, .summary-grid dt, .master-strip span { color: var(--muted); font-size: 11px; }
.identity-row strong { display: block; margin-top: 2px; font-size: 17px; }
.state-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f3;
  color: #53666d;
  font-size: 10px !important;
  font-weight: 800;
  white-space: nowrap;
}
.state-badge.good { background: var(--green-soft); color: var(--green); }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 12px 0 4px;
  border-top: 1px solid var(--line-soft);
}
.summary-grid div { min-width: 0; padding: 9px 7px; border-bottom: 1px solid var(--line-soft); }
.summary-grid dt, .summary-grid dd { margin: 0; }
.summary-grid dd { margin-top: 3px; overflow-wrap: anywhere; font-size: 13px; font-weight: 700; }
.text-button { min-height: 40px; padding: 5px 0; border: 0; background: transparent; color: var(--primary); font-weight: 800; }
.more-details { margin-top: 2px; }

.form-section { padding: 14px; }
.compact-section { padding: 13px; }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-grid { grid-column: 1 / -1; }
.meter-current-section { border-top: 4px solid var(--primary); }
.subsection-heading { margin: 18px -13px 0; padding: 11px 13px; border-top: 1px solid var(--line); background: #edf5f3; color: var(--primary-dark); font-size: 15px; }
.meter-history-questions { margin: 0 -1px; padding: 12px; border: 1px solid #b9d3cc; border-top: 0; background: #f7fbfa; }
.previous-meter-panel { margin-top: 12px; padding: 14px; border: 2px solid #8cb9ae; border-radius: 6px; background: #fff; box-shadow: inset 5px 0 0 var(--primary); }
.previous-meter-panel h4 { margin: 0 0 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line-soft); color: var(--primary-dark); font-size: 16px; }
.attribute-change-stack { display: grid; gap: 12px; }
.attribute-change-card { margin-top: 0; }
.conditional-date-grid, .witness-details-grid { margin-top: 12px; }
.current-load-equipment-builder {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px solid var(--primary);
}
.current-load-equipment-builder .section-title-row h4 { margin: 0; padding: 0; border: 0; }
.current-load-equipment-builder .section-title-row strong { color: var(--navy); font-size: 17px; }
.witness-signature-card { margin-top: 12px; background: #fff; }
.load-entry-section { border-top: 4px solid var(--navy); }
.load-builder-heading { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--navy); font-size: 16px; }
.inline-status { margin-top: 9px; color: var(--muted); font-size: 12px; }
.inline-status.good { color: var(--green); font-weight: 700; }

.profile-panel, .advanced-panel {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}
.profile-panel summary, .advanced-panel summary {
  min-height: 48px;
  padding: 13px 14px;
  color: var(--primary-dark);
  font-weight: 800;
  cursor: pointer;
}
.profile-body { padding: 0 14px 14px; }

.master-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
  border: 1px solid var(--line-soft);
  background: #f4f8f9;
}
.master-strip div { min-width: 0; padding: 9px; border-right: 1px solid var(--line-soft); }
.master-strip div:last-child { border-right: 0; }
.master-strip strong { display: block; margin-top: 3px; overflow-wrap: anywhere; font-size: 13px; }

.choice-field { margin: 12px 0; padding: 0; border: 0; }
.choice-field legend { margin-bottom: 7px; font-size: 13px; font-weight: 800; }
.choice-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.choice-row label { display: block; }
.choice-row input { position: absolute; opacity: 0; pointer-events: none; }
.choice-row span {
  display: grid;
  min-height: 46px;
  place-items: center;
  border: 1px solid #9fb2b9;
  border-radius: 6px;
  background: #fff;
}
.choice-row input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.photo-button {
  display: grid;
  min-height: 72px;
  padding: 10px;
  place-items: center;
  border: 1px dashed #7fa89f;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  text-align: center;
}
.photo-button.has-file { border-style: solid; border-color: var(--green); background: var(--green-soft); color: var(--green); }
.photo-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.route-notice { margin-top: 12px; padding: 10px 11px; border-left: 4px solid var(--amber); background: var(--amber-soft); color: #684207; font-size: 12px; font-weight: 700; }
.route-notice.danger { border-left-color: var(--red); background: var(--red-soft); color: var(--red); }
.dynamic-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.dynamic-fields:empty { margin: 0; }

.load-add-row { display: grid; grid-template-columns: minmax(150px, 2fr) 72px 90px auto; gap: 7px; align-items: end; margin-top: 12px; }
.load-items { display: grid; gap: 7px; margin-top: 10px; }
.load-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  background: #f7fafb;
}
.load-item strong, .load-item span { overflow-wrap: anywhere; }
.load-item span { color: var(--muted); font-size: 12px; }
.delete-load { min-width: 40px; min-height: 40px; border: 1px solid #e1aaa6; border-radius: 5px; background: #fff; color: var(--red); font-weight: 900; }
.load-total-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 12px;
  overflow: hidden;
  border: 2px solid var(--navy);
  border-radius: 7px;
  background: var(--navy);
}
.load-total-panel div { padding: 12px; background: #eef6f8; text-align: center; }
.load-total-panel span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.load-total-panel strong { display: block; margin-top: 3px; color: var(--navy); font-size: 20px; }

.review-summary { overflow: hidden; }
.review-header { padding: 14px; background: var(--navy); color: #fff; }
.review-header span { font-size: 11px; opacity: .82; }
.review-header strong { display: block; margin-top: 2px; font-size: 18px; }
.review-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.review-metrics div { padding: 12px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.review-metrics span { display: block; color: var(--muted); font-size: 11px; }
.review-metrics strong { display: block; margin-top: 3px; overflow-wrap: anywhere; font-size: 14px; }
.missing-list { margin: 0; padding: 10px 14px 13px 31px; color: var(--red); font-size: 12px; }
.confirm-row { grid-template-columns: 26px 1fr; align-items: center; min-height: 52px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.confirm-row input { width: 22px; min-height: 22px; margin: 0; }

.signing-section { display: grid; gap: 12px; }
.signing-section h3 { margin-bottom: 0; }
.signature-method { margin: 0 0 12px; }
.signature-card {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7fafb;
}
.staff-signature-card { margin-top: 2px; }
.signature-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--navy);
  font-size: 13px;
}
.signature-heading .button { min-height: 38px; padding: 6px 10px; }
.signature-pad {
  display: block;
  width: 100%;
  height: 150px;
  border: 2px dashed #8ca5ad;
  border-radius: 6px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}
.signature-pad.has-signature { border-style: solid; border-color: var(--green); background: #fbfffc; }
.signature-pad.invalid { border-color: var(--red); background: #fff8f7; }
.signature-help { margin: 7px 1px 0; color: var(--muted); font-size: 12px; }
.thumb-button { min-height: 64px; }
.thumb-preview {
  display: block;
  width: min(100%, 260px);
  max-height: 210px;
  margin: 10px auto 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
}
.full-width { width: 100%; margin-top: 8px; }

.readiness-box { margin: 12px 0; padding: 13px; border: 1px solid; border-radius: 7px; text-align: center; font-size: 15px; font-weight: 900; }
.readiness-box.incomplete { border-color: #e5a29d; background: var(--red-soft); color: var(--red); }
.readiness-box.ready { border-color: #9bceb0; background: var(--green-soft); color: var(--green); }
.output-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.output-actions .button:first-child { grid-column: 1 / -1; }
.output-actions .button:last-child { grid-column: 1 / -1; }
.submit-inspection-button { background: #075548; }
.submission-status { margin: 9px 2px 0; color: var(--muted); font-size: 12px; text-align: center; }
.submission-status.success { color: var(--green); font-weight: 800; }
.submission-status.error { color: var(--red); font-weight: 800; }
.continue-workflow-button { background: var(--green); border-color: var(--green); color: #fff; }

.bottom-actions {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px max(12px, env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 -5px 16px rgba(24, 54, 65, .09);
}
.bottom-actions span { color: var(--muted); font-size: 12px; font-weight: 800; }

.print-sheet { display: none; }

@media (max-width: 560px) {
  .login-card { padding: 23px 18px; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column; align-items: stretch; }
  .topbar-actions .button { min-height: 36px; padding: 6px 9px; font-size: 12px; }
  .content { padding-right: 10px; padding-left: 10px; }
  .form-grid.two, .dynamic-fields { grid-template-columns: 1fr; }
  .lookup-row { align-items: stretch; }
  .lookup-row .button { align-self: end; min-width: 84px; }
  .summary-grid { grid-template-columns: 1fr; }
  .master-strip { grid-template-columns: 1fr 1fr; }
  .master-strip div:nth-child(2) { border-right: 0; }
  .master-strip div:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line-soft); }
  .load-add-row { grid-template-columns: 1fr 80px; }
  .load-add-row .grow { grid-column: 1 / -1; }
  .load-add-row .button { align-self: end; }
  .signature-pad { height: 165px; }
}

@media (min-width: 760px) {
  .topbar { padding-right: 24px; padding-left: 24px; }
  .content { padding-top: 20px; }
  .stepper { width: min(100%, 780px); margin: 0 auto; border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
  .bottom-actions { right: 50%; left: auto; width: min(100%, 780px); transform: translateX(50%); border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
}

@media print {
  @page { size: A4 portrait; margin: 11mm; }
  body { background: #fff; color: #000; font-family: Arial, sans-serif; }
  .login-gate, .app-shell { display: none !important; }
  .print-sheet { display: block; font-size: 10.5pt; }
  .print-title { padding-bottom: 7px; border-bottom: 2px solid #000; text-align: center; }
  .print-title h1 { font-size: 17pt; }
  .print-title p { margin: 4px 0 0; }
  .print-section { margin-top: 10px; break-inside: avoid; }
  .print-section h2 { margin: 0; padding: 5px 7px; border: 1px solid #000; background: #e9e9e9; font-size: 11pt; }
  .print-table { width: 100%; border-collapse: collapse; }
  .print-table th, .print-table td { padding: 5px 6px; border: 1px solid #000; text-align: left; vertical-align: top; }
  .print-table th { width: 34%; font-weight: 700; }
  .print-table thead { display: table-header-group; }
  .print-table tfoot th, .print-table tfoot td { background: #e9e9e9; font-size: 11pt; font-weight: 800; }
  .print-meter-section, .print-load-section { break-before: page; page-break-before: always; }
  .signature-space { height: 52px; }
  .print-signatures { display: grid; grid-template-columns: repeat(var(--signature-columns, 2), minmax(0, 1fr)); border: 1px solid #000; border-top: 0; }
  .print-signature { min-height: 105px; padding: 7px; text-align: center; }
  .print-signature + .print-signature { border-left: 1px solid #000; }
  .print-signature strong { display: block; margin-bottom: 5px; font-size: 10pt; }
  .print-signature img { display: block; width: 100%; height: 66px; margin: 0 auto 4px; object-fit: contain; }
  .print-signature span { display: block; font-size: 9pt; }
  .print-conclusion-page { break-before: page; page-break-before: always; }
}
