:root {
  --navy: #1F3864;
  --navy-dark: #16294a;
  --navy-tint: #EAF0FA;
  --amber: #B45309;
  --amber-tint: #FDEBD0;
  --green: #2E6B2E;
  --green-tint: #E5F0E5;
  --ink: #1A1F29;
  --gray: #6B7280;
  --gray-light: #9AA1AC;
  --border: #E2E5EA;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --danger: #B3261E;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
}

/* ---------- Top bar ---------- */

.topbar {
  background: var(--navy);
  color: white;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-text { flex: 1; min-width: 0; }
.brand-text h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-text p {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: rgba(255,255,255,0.65);
}

.version-tag {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 3px 9px;
  flex-shrink: 0;
}

.doc-download-link {
  flex-shrink: 0;
  font-size: 12.5px;
  color: white;
  text-decoration: none;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.doc-download-link:hover { background: rgba(255,255,255,0.22); }
@media (max-width: 480px) {
  .doc-download-link span { display: none; }
  .brand-text p { display: none; }
}

.progress-track {
  height: 3px;
  background: rgba(255,255,255,0.15);
}
.progress-fill {
  height: 100%;
  background: var(--amber);
  width: 4%;
  transition: width 0.25s ease;
}

/* ---------- Layout ---------- */

.app-shell {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  gap: 28px;
  align-items: flex-start;
  padding: 22px 18px 80px;
}

.step-rail {
  width: 210px;
  flex-shrink: 0;
  position: sticky;
  top: 74px;
  display: none;
}

@media (min-width: 780px) {
  .step-rail { display: block; }
}

/* Tablet portrait / narrow window: give the form column more breathing
   room and slightly larger touch targets than phone, since there's
   more width to work with but the rail is still hidden. */
@media (min-width: 480px) and (max-width: 779px) {
  .app-shell { padding: 24px 28px 90px; }
  .field-grid { gap: 18px; }
}

/* Phone: tighten padding so content isn't squeezed, and make sure
   nothing relies on hover-only affordances. */
@media (max-width: 479px) {
  .app-shell { padding: 16px 12px 90px; }
  .site-id-card, .section-card { padding: 16px 14px 18px; }
  .section-head h2 { font-size: 17px; }
  .step-nav { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 4px; margin: 0 -12px -8px; padding-left: 12px; padding-right: 12px; }
}

.step-rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--gray);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.step-rail-item .dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  color: var(--gray-light);
}
.step-rail-item.active {
  background: var(--navy-tint);
  color: var(--navy);
  font-weight: 600;
}
.step-rail-item.active .dot {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}
.step-rail-item.done .dot {
  background: var(--green);
  border-color: var(--green);
  color: white;
}
.step-rail-item.done .dot::after { content: "✓"; }
.step-rail-item.done .dot { font-size: 0; }
.step-rail-item.done .dot::after { font-size: 11px; }

.form-column {
  flex: 1;
  min-width: 0;
}

/* ---------- Draft banner ---------- */

.draft-banner {
  background: var(--amber-tint);
  border: 1px solid #F0C888;
  color: #7A4A0A;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.link-btn {
  background: none;
  border: none;
  color: var(--navy);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  font-size: 13.5px;
  padding: 0;
}

/* ---------- Cards ---------- */

.site-id-card, .section-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 22px;
  margin-bottom: 16px;
}

.site-id-card h2 {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--navy);
}

.section-head {
  margin-bottom: 4px;
}
.section-head h2 {
  font-size: 19px;
  margin: 0 0 6px;
  color: var(--navy);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--navy);
  color: white;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  transform: translateY(1px);
}
.section-subnote {
  font-size: 13px;
  color: var(--gray);
  font-style: italic;
  margin: 0 0 18px;
  line-height: 1.5;
}

/* ---------- Fields ---------- */

.field-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field { display: block; }
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  line-height: 1.4;
}
.field-id {
  color: var(--navy);
  font-weight: 700;
  margin-right: 6px;
}

input[type="text"], input[type="date"], input[type="number"], textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--ink);
  background: #FCFCFD;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
  border-color: var(--navy);
}
textarea { resize: vertical; min-height: 60px; }

.yesno-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.yesno-btn {
  flex: 1;
  padding: 12px 10px;
  min-height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
}
.yesno-btn.selected-yes {
  background: var(--green-tint);
  border-color: var(--green);
  color: var(--green);
}
.yesno-btn.selected-no {
  background: #FBEAEA;
  border-color: var(--danger);
  color: var(--danger);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.chip {
  padding: 10px 16px;
  min-height: 40px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 13px;
  color: var(--gray);
  cursor: pointer;
}
.chip.selected {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}

/* ---------- Photo requirements ---------- */

.section-photo-tally {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-tint);
  border-radius: 20px;
  padding: 5px 12px;
  margin-bottom: 16px;
}

.inline-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin: -6px 0 4px;
}

/* Multi-photo groups (a single required photo that allows several
   uploads, e.g. "all sides of the building"). Spans the full grid row
   so its internal thumbnails have room, even when sitting next to
   single-photo slots in the same inline-photo-grid. */
.photo-slot-group {
  grid-column: 1 / -1;
  border: 1.5px dashed #E8C596;
  background: var(--amber-tint);
  border-radius: 8px;
  padding: 10px 12px 12px;
}
.photo-slot-group.filled {
  border-style: solid;
  border-color: var(--green);
  background: var(--green-tint);
}
.photo-slot-group-label {
  font-size: 12px;
  font-weight: 600;
  color: #7A4A0A;
  margin-bottom: 8px;
}
.photo-slot-group.filled .photo-slot-group-label { color: var(--green); }
.photo-slot-group-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.photo-slot.mini {
  width: 84px;
  height: 84px;
  min-height: 84px;
  padding: 6px;
  flex-shrink: 0;
}
.photo-slot.mini.filled { padding: 0; }
.photo-slot.mini img { height: 100%; }
.photo-slot.mini .photo-slot-icon { font-size: 22px; }

.photo-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}
.photo-section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--amber);
  margin-bottom: 10px;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.photo-slot {
  border: 1.5px dashed #E8C596;
  background: var(--amber-tint);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  position: relative;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.photo-slot.drag-over {
  border-style: solid;
  border-color: var(--navy);
  background: var(--navy-tint);
  transform: scale(1.02);
}
.photo-slot.filled {
  border-style: solid;
  border-color: var(--green);
  background: var(--green-tint);
  padding: 0;
  overflow: hidden;
}
.photo-slot img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}
.photo-slot-label {
  font-size: 11px;
  color: #7A4A0A;
  line-height: 1.3;
  padding: 0 4px;
}
.photo-slot.filled .photo-slot-label {
  color: var(--green);
  padding: 4px 6px 6px;
}
.photo-slot-icon { font-size: 20px; }
.photo-slot input[type="file"] { display: none; }
.retake-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
}

/* ---------- Goal block ---------- */

.goal-block {
  margin-top: 20px;
  background: var(--green-tint);
  border: 1px solid #B7D6B7;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  font-size: 13px;
  color: var(--green);
  line-height: 1.5;
}
.goal-block .goal-icon { flex-shrink: 0; }

/* ---------- Nav buttons ---------- */

.step-nav {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.btn {
  flex: 1;
  padding: 13px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.btn-secondary {
  background: white;
  border: 1.5px solid var(--border);
  color: var(--ink);
}
.btn-primary {
  background: var(--navy);
  color: white;
}
.btn-submit {
  background: var(--amber);
  color: white;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.photo-count-readout {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}

.submit-status {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
}
.submit-status.info { background: var(--navy-tint); color: var(--navy); }
.submit-status.success { background: var(--green-tint); color: var(--green); }
.submit-status.error { background: #FBEAEA; color: var(--danger); }

.section-card[hidden], .site-id-card[hidden] { display: none; }

/* ---------- Misc / additional photos ---------- */

.misc-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.misc-photo-tile {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: white;
  position: relative;
}
.misc-photo-tile img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}
.misc-label-input {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding: 8px 10px;
  font-size: 12.5px;
}
.misc-label-input:focus { outline: none; border-top-color: var(--navy); }
.misc-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.misc-add-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 110px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--gray);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.misc-add-tile:hover, .misc-add-tile.drag-over {
  border-color: var(--navy);
  background: var(--navy-tint);
  color: var(--navy);
}
.misc-add-tile input[type="file"] { display: none; }
