:root {
  --navy: #041A4D;
  --blue: #0D6EFD;
  --blue-dark: #0756C5;
  --blue-soft: #EAF2FF;
  --surface: #FFFFFF;
  --background: #F4F7FB;
  --border: #D8E0EC;
  --text: #152038;
  --muted: #64748B;
  --warning: #FFF6E5;
  --warning-border: #E5A100;
  --danger: #B42318;
  --shadow: 0 8px 24px rgba(4, 26, 77, 0.08);
  font-family: Aptos, "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body { margin: 0; min-height: 100%; padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.brand-row {
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(110px, 150px) 1fr 44px;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 5px;
}
.brand-logo { width: 100%; max-height: 46px; object-fit: contain; object-position: left center; }
.header-title { min-width: 0; display: flex; flex-direction: column; text-align: center; }
.header-title strong { color: var(--navy); font-size: 17px; line-height: 1.15; }
.header-title span { color: var(--blue); font-size: 11px; font-weight: 700; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 12px; background: var(--blue-soft); color: var(--navy); font-size: 25px; }

.status-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 14px 7px; color: var(--muted); font-size: 11px; }
.status-pill { color: #067647; background: #ECFDF3; border-radius: 999px; padding: 3px 8px; font-weight: 700; }
.status-pill.offline { color: #9A3412; background: #FFF7ED; }
.progress-track { height: 3px; background: #E5EAF2; }
#progressBar { width: 16.66%; height: 100%; background: linear-gradient(90deg, var(--blue), #4EA0FF); transition: width .25s ease; }
.step-nav { display: flex; overflow-x: auto; scrollbar-width: none; padding: 7px 10px; gap: 6px; }
.step-nav::-webkit-scrollbar { display: none; }
.step-chip { flex: 0 0 auto; border: 0; border-radius: 999px; padding: 7px 11px; background: #EEF2F7; color: var(--muted); font-size: 12px; font-weight: 700; }
.step-chip.is-active { background: var(--navy); color: #fff; }
.step-chip.is-complete { background: var(--blue-soft); color: var(--blue-dark); }

main { width: min(100%, 980px); margin: 0 auto; padding: 16px 12px 30px; }
.form-step { display: none; animation: step-in .2s ease-out; }
.form-step.is-active { display: block; }
@keyframes step-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.section-heading { display: flex; align-items: center; gap: 12px; margin: 4px 2px 14px; }
.section-number { flex: 0 0 38px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: white; background: var(--navy); font-weight: 800; font-size: 18px; }
.section-heading h1 { margin: 0; color: var(--navy); font-size: 22px; line-height: 1.15; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; color: var(--navy); font-size: 15px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-title-row h2 { margin: 0; }
.muted { color: var(--muted); font-size: 12px; }
.top-gap { margin-top: 12px; }

.field-grid { display: grid; gap: 12px; }
.field-grid label, .signature-card > label { display: grid; gap: 6px; color: var(--navy); font-size: 12px; font-weight: 750; }
input, select, textarea {
  width: 100%;
  border: 1px solid #B9C6D8;
  border-radius: 10px;
  min-height: 46px;
  padding: 11px 12px;
  color: var(--text);
  background: #FFF;
  outline: none;
  font-size: 16px;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(13,110,253,.14); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); background: #FFF7F6; }

.choice-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.choice { position: relative; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 11px; background: #FBFCFE; color: var(--text); font-size: 14px; font-weight: 650; }
.choice input { appearance: none; flex: 0 0 23px; width: 23px; min-height: 23px; height: 23px; padding: 0; margin: 0; border: 2px solid #9BACBF; border-radius: 6px; background: #fff; }
.choice input[type="radio"] { border-radius: 50%; }
.choice input:checked { border-color: var(--blue); background: var(--blue); box-shadow: inset 0 0 0 4px #fff; }
.choice:has(input:checked) { border-color: #8FB8FF; background: var(--blue-soft); color: var(--navy); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented label { min-width: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: grid; place-items: center; min-height: 48px; padding: 6px; border: 1px solid var(--border); border-radius: 11px; text-align: center; font-size: 13px; font-weight: 750; }
.segmented input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }

.table-card { padding: 0; overflow: hidden; }
.table-card > h2, .table-card > .card-title-row { padding: 14px 14px 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mobile-table { width: 100%; min-width: 650px; border-collapse: collapse; }
.mobile-table th { background: var(--blue-soft); color: var(--navy); font-size: 12px; text-align: left; }
.mobile-table th, .mobile-table td { border: 1px solid var(--border); padding: 7px; }
.mobile-table td:first-child { min-width: 200px; font-size: 13px; font-weight: 700; }
.mobile-table td:last-child { color: var(--muted); font-size: 12px; }
.mobile-table input { min-height: 42px; padding: 8px; }

.repeat-list { display: grid; gap: 9px; padding: 0 12px 14px; }
.repeat-row { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #FBFCFE; }
.repeat-row .row-title { grid-column: 1 / -1; color: var(--navy); font-size: 13px; font-weight: 800; padding-right: 36px; }
.repeat-row label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.repeat-row input { min-height: 42px; font-size: 14px; padding: 8px; }
.remove-row { position: absolute; right: 7px; top: 7px; width: 34px; height: 34px; border: 0; border-radius: 9px; background: #FEE4E2; color: var(--danger); font-size: 20px; }

.small-button, .text-button { border: 0; color: var(--blue-dark); background: var(--blue-soft); border-radius: 9px; padding: 8px 10px; font-size: 12px; font-weight: 750; }
.warning-card { display: grid; gap: 4px; margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--warning-border); border-radius: 13px; background: var(--warning); color: #7A4B00; font-size: 13px; }

.test-list { padding: 0 12px 14px; }
.test-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.test-row:last-child { border-bottom: 0; }
.test-name { grid-column: 1; font-size: 13px; font-weight: 650; }
.test-toggle { display: grid; place-items: center; gap: 2px; color: var(--muted); font-size: 9px; }
.test-toggle input { width: 25px; min-height: 25px; height: 25px; padding: 0; }
.test-note { grid-column: 1 / -1; min-height: 40px; font-size: 14px; }

.photo-button { display: grid; place-items: center; min-height: 50px; border: 1px dashed var(--blue); border-radius: 12px; color: var(--blue-dark); background: var(--blue-soft); font-weight: 750; }
.photo-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.photo-item { position: relative; aspect-ratio: 4/3; overflow: hidden; border-radius: 11px; background: #E5EAF2; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-item button { position: absolute; top: 5px; right: 5px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(4,26,77,.86); color: #fff; font-size: 18px; }

.signature-grid { display: grid; gap: 12px; }
.signature-card { display: grid; gap: 10px; }
.signature-pad { width: 100%; height: 150px; border: 1px dashed #8FA1B9; border-radius: 10px; background: #fff; touch-action: none; }
.clear-signature { justify-self: end; }
.confirmation { margin-bottom: 26px; }

.action-bar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.97); backdrop-filter: blur(16px); border-top: 1px solid var(--border); }
.action-bar button { min-height: 48px; border-radius: 12px; padding: 8px 14px; font-weight: 800; }
.primary-button { border: 0; background: var(--blue); color: #fff; }
.primary-button:active { background: var(--blue-dark); }
.secondary-button { border: 1px solid #B8C6D8; background: #fff; color: var(--navy); }
.pdf-button { background: #087A54; }

dialog { width: min(calc(100% - 28px), 480px); border: 0; border-radius: 20px; padding: 0; box-shadow: 0 30px 80px rgba(4,26,77,.28); }
dialog::backdrop { background: rgba(4,15,40,.55); backdrop-filter: blur(3px); }
.dialog-content { position: relative; padding: 24px; }
.dialog-content h2 { margin: 0 0 14px; color: var(--navy); }
.dialog-content li { margin-bottom: 9px; }
.dialog-close { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #EEF2F7; color: var(--navy); font-size: 24px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translate(-50%, 14px); max-width: calc(100% - 28px); padding: 10px 14px; border-radius: 999px; background: var(--navy); color: #fff; opacity: 0; pointer-events: none; transition: .2s; font-size: 13px; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .brand-row { padding-left: 24px; padding-right: 24px; }
  .status-row { padding-left: 24px; padding-right: 24px; }
  .step-nav { justify-content: center; }
  main { padding: 24px 20px 50px; }
  .two-column { grid-template-columns: 1fr 1fr; }
  .two-column .wide { grid-column: 1 / -1; }
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .signature-grid { grid-template-columns: 1fr 1fr; }
  .repeat-row { grid-template-columns: repeat(4, 1fr); }
  .repeat-row .row-title { grid-column: 1 / -1; }
  .action-bar { left: 50%; right: auto; width: min(100%, 980px); transform: translateX(-50%); border: 1px solid var(--border); border-bottom: 0; border-radius: 18px 18px 0 0; }
}

@media print {
  .app-header, .action-bar, .toast, dialog { display: none !important; }
  body { padding: 0; background: white; }
  main { width: 100%; padding: 0; }
  .form-step { display: block !important; page-break-after: always; }
  .card { box-shadow: none; break-inside: avoid; }
}
