:root {
  --navy: #17243b;
  --navy-2: #233a63;
  --red: #d33b32;
  --signal: #f2b632;
  --paper: #ffffff;
  --gray-50: #f4f6f9;
  --gray-100: #e9edf3;
  --gray-300: #ccd3de;
  --gray-600: #647084;
  --text: #17243b;
  --success: #27633c;
  --danger: #a92b25;
  --radius: 12px;
  --shadow: 0 16px 38px rgba(23, 36, 59, 0.11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(23, 36, 59, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 36, 59, 0.035) 1px, transparent 1px),
    var(--gray-50);
  background-size: 24px 24px;
  font-family: Bahnschrift, "DIN Alternate", "Arial Narrow", sans-serif;
  line-height: 1.5;
}

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

button, input, select, textarea, .button {
  min-height: 44px;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 12px max(12px, calc((100% - 980px) / 2));
  background: #fff;
  border-bottom: 4px solid var(--red);
  box-shadow: 0 4px 16px rgba(23, 36, 59, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  max-width: 590px;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.15;
  text-decoration: none;
}

.brand img { display: block; width: 120px; height: auto; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.site-header nav a, .site-header nav button { min-height: 40px; padding: 8px 10px; color: var(--navy); background: transparent; border: 1px solid transparent; border-radius: 6px; font-weight: 700; text-decoration: none; }
.site-header nav a:hover, .site-header nav button:hover { background: var(--gray-100); border-color: var(--gray-300); }
.site-header nav form { margin: 0; }

.site-footer {
  padding: 18px 12px;
  color: #dce5f2;
  background: var(--navy);
  font-size: 0.82rem;
  text-align: center;
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 150px);
  padding: 30px 12px;
  place-items: center;
}

.login-card {
  width: min(100%, 520px);
  padding: 26px;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-top: 7px solid var(--red);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card > .eyebrow { color: var(--red); }
.login-card h1 { margin: 4px 0 8px; font-size: clamp(2rem, 8vw, 3.2rem); line-height: 0.95; }
.login-card form { display: grid; gap: 16px; margin-top: 22px; }
.login-card label { display: grid; gap: 6px; font-weight: 800; }
.install-card { width: min(100%, 760px); }
.install-card fieldset { display: grid; gap: 13px; padding: 18px; border: 1px solid var(--gray-300); border-radius: 8px; }
.install-card legend { padding: 0 8px; color: var(--red); font-weight: 800; }
.form-alert, .form-success { margin: 14px 0; padding: 13px 15px; border-left: 5px solid; border-radius: 4px 8px 8px 4px; font-weight: 700; }
.form-alert { color: var(--danger); background: #fff0ef; border-color: var(--danger); }
.form-success { color: var(--success); background: #eaf7ee; border-color: var(--success); }

.survey-shell, .dashboard-shell {
  width: min(100% - 24px, 980px);
  margin: 0 auto;
  padding: 18px 0 96px;
}

.survey-progress {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  padding: 14px 16px 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  border-bottom: 4px solid var(--red);
  box-shadow: 0 8px 24px rgba(23, 36, 59, 0.22);
}

.eyebrow {
  margin: 0 0 2px;
  color: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.step-counter { margin: 0; font-size: 1.2rem; font-weight: 800; }
.save-state { align-self: center; font-size: 0.86rem; text-align: right; }
.save-state[data-tone="success"] { color: #bff0c9; }
.save-state[data-tone="error"] { color: #ffd1cd; }
.save-state[data-tone="warning"] { color: #ffe5a3; }

.progress-track {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.progress-track span {
  display: block;
  height: 100%;
  background: var(--signal);
  transition: width 260ms ease;
}

.locked-notice, .empty-state {
  margin: 18px 0;
  padding: 16px;
  background: #fff7dd;
  border-left: 5px solid var(--signal);
  border-radius: 4px var(--radius) var(--radius) 4px;
}

.step-panel { padding-top: 22px; }
.step-panel[hidden] { display: none; }

.step-heading {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 14px;
  align-items: start;
  margin: 0 0 18px;
}

.step-index {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: #fff;
  background: var(--red);
  clip-path: polygon(0 0, 100% 0, 100% 72%, 72% 100%, 0 100%);
  font-size: 1.25rem;
  font-weight: 800;
}

.step-heading h1, .dashboard-heading h1 {
  margin: 0;
  font-size: clamp(1.7rem, 6vw, 3.2rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
}

.step-heading p { margin: 8px 0 0; color: var(--gray-600); }

.question-card, .photo-card, .position-card, .confirmation-list, .project-card {
  margin: 0 0 14px;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: 0 5px 16px rgba(23, 36, 59, 0.06);
}

.question-card:focus-within { border-color: var(--navy-2); box-shadow: var(--shadow); }
.field-label { display: flex; gap: 8px; align-items: center; font-weight: 800; }
.required-mark, .optional-badge { padding: 2px 7px; border-radius: 999px; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; }
.required-mark { color: #fff; background: var(--red); }
.optional-badge { color: var(--navy); background: var(--gray-100); }
.field-purpose { margin: 5px 0 12px; color: var(--gray-600); }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid #9aa6b8;
  border-radius: 8px;
}

textarea { min-height: 110px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { color: #4f5b6c; background: var(--gray-100); opacity: 1; }
.input-with-unit { display: flex; align-items: stretch; }
.input-with-unit input { min-width: 0; border-radius: 8px 0 0 8px; }
.unit-chip { display: grid; place-items: center; min-width: 58px; padding: 0 10px; color: #fff; background: var(--navy); border-radius: 0 8px 8px 0; font-weight: 700; }

.measurement-help { margin-top: 12px; border-top: 1px solid var(--gray-100); }
.measurement-help summary { padding: 12px 0 4px; color: var(--navy-2); cursor: pointer; font-weight: 700; }
.measurement-help dl { margin-bottom: 0; }
.measurement-help dl div { padding: 8px 0; border-top: 1px dashed var(--gray-300); }
.measurement-help dt { font-size: 0.77rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.measurement-help dd { margin: 3px 0 0; }
.unknown-option { display: grid; gap: 8px; margin-top: 10px; padding: 12px; background: #f8f2e5; border-radius: 8px; }
.unknown-option label, .option-grid label { display: flex; gap: 9px; align-items: center; }
.unknown-option input[type="checkbox"], .option-grid input { width: 22px; min-height: 22px; }
.option-grid { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--gray-300); border-radius: 8px; }
.field-error { min-height: 1px; margin: 8px 0 0; color: var(--danger); font-weight: 700; }

.coordinate-section { margin: 28px 0; }
.coordinate-section h2, .confirmation-list h2 { margin-top: 0; }
.axis-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.axis-legend span { padding: 6px 10px; color: #fff; background: var(--navy-2); border-radius: 4px; }
.position-card h3, .photo-card h3 { margin-top: 0; }
.coordinate-grid { display: grid; gap: 12px; }
.coordinate-grid label { font-weight: 700; }

.photo-card { border-left: 5px solid var(--navy-2); }
.photo-card p { color: var(--gray-600); }
.photo-preview { margin-top: 10px; padding: 10px; color: var(--gray-600); background: var(--gray-50); border-radius: 8px; }
.confirmation-list label { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.confirmation-list input { width: 24px; min-height: 24px; }

.wizard-actions { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; padding: 12px 0; background: linear-gradient(transparent, var(--gray-50) 18%); }
.button { display: inline-flex; align-items: center; justify-content: center; padding: 11px 16px; border: 0; border-radius: 8px; font-weight: 800; text-decoration: none; cursor: pointer; }
.button.primary { color: #fff; background: var(--red); box-shadow: 0 8px 18px rgba(211, 59, 50, 0.22); }
.button.secondary { color: var(--navy); background: #fff; border: 1px solid var(--navy); }
.button:disabled { cursor: not-allowed; opacity: 0.45; }

.dashboard-heading { margin: 26px 0; padding: 26px 22px; color: #fff; background: var(--navy); border-radius: var(--radius); box-shadow: var(--shadow); }
.dashboard-heading .eyebrow { color: var(--signal); }
.dashboard-heading p:last-child { margin-bottom: 0; color: #dce5f2; }
.project-card { position: relative; overflow: hidden; padding-top: 50px; }
.project-card__status { position: absolute; inset: 0 0 auto; padding: 9px 18px; color: #fff; background: var(--navy-2); font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.project-code { color: var(--red); font-weight: 800; }
.project-card h2 { margin: 0 0 8px; }
.export-card { margin-top: 20px; padding-top: 24px; border-left: 6px solid var(--success); }
.export-card .eyebrow { color: var(--success); }
.export-grid { display: grid; gap: 10px; margin-top: 18px; }

@media (min-width: 768px) {
  .survey-shell, .dashboard-shell { padding-top: 28px; }
  .survey-progress { border-radius: var(--radius); }
  .question-card, .photo-card, .position-card, .confirmation-list, .project-card { padding: 24px; }
  .coordinate-grid { grid-template-columns: repeat(3, 1fr); }
  .option-grid { grid-template-columns: repeat(2, 1fr); }
  .export-grid { grid-template-columns: repeat(2, 1fr); }
  .brand { grid-template-columns: 160px 1fr; font-size: 0.94rem; }
  .brand img { width: 160px; }
  .wizard-actions { position: static; justify-content: end; grid-template-columns: 180px 240px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media print {
  .site-header, .site-footer, .wizard-actions { display: none !important; }
  body { background: #fff; }
  .question-card, .photo-card, .position-card, .project-card { box-shadow: none; break-inside: avoid; }
}
