/* ── RESET & BASE ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
:root {
  --black: #0a0a0a;
  --green: #7dc52a;
  --green-deep: #3d6b0f;
  --green-glow: rgba(125, 197, 42, 0.18);
  --green-subtle: rgba(125, 197, 42, 0.08);
  --white: #ffffff;
  --page-bg: #f7f7f7;
  --card-bg: #ffffff;
  --border: #e8e8e8;
  --border-strong: #c8c8c8;
  --border-focus: #7dc52a;
  --label: #5a5a5a;
  --text: #111111;
  --text-muted: #888888;
  --error: #d92d20;
  --success: #3d6b0f;
  --unfilled-bg: #fffbeb;
  --unfilled-border: #f59e0b;
  --r-input: 6px;
  --r-card: 10px;
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-focus: 0 0 0 3px var(--green-glow);
  --transition: 140ms ease;
}
html {
  font-size: 15px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page-bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ── APP SHELL ─────────────────────────────────────────────── */
#app {
  max-width: 860px;
  margin: 0 auto;
}

/* ── HEADER ─────────────────────────────────────────────────── */
#header {
  background: var(--black);
  padding: 16px 24px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
#header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
#logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
#logo img {
  height: 32px;
  width: auto;
  display: block;
}
#logo-sub {
  color: rgba(255, 255, 255, 0.45);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
#save-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #6b8baa;
}
#save-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6b8baa;
  transition: background var(--transition);
}
#save-dot.saved {
  background: var(--success);
}
#save-dot.dirty {
  background: var(--green);
}

/* ── PROGRESS ──────────────────────────────────────────────── */
#prog-bar-wrap {
  margin-bottom: 14px;
}
#prog-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
#prog-section {
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
#prog-pct {
  color: rgba(255, 255, 255, 0.35);
  font-size: 11px;
}
#prog-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
#prog-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── SECTION TABS ──────────────────────────────────────────── */
#tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 2px;
}
#tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  flex-shrink: 0;
  padding: 8px 14px 9px;
  font-size: 11px;
  font-weight: 500;
  color: #6b8baa;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition:
    color var(--transition),
    border-color var(--transition);
  display: flex;
  align-items: center;
  gap: 5px;
}
.tab.active {
  color: #fff;
  border-bottom-color: var(--green);
}
.tab.done {
  color: var(--green);
}
.tab.done::before {
  content: "✓";
  font-size: 10px;
}
.tab.err {
  color: #ef5350;
}

/* ── PAGE ──────────────────────────────────────────────────── */
#form-body {
  padding: 28px 28px 140px;
  min-height: 60vh;
}
.page {
  display: none;
}
.page.active {
  display: block;
}
.page-header {
  margin-bottom: 28px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.page-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 5px;
  font-weight: 400;
}

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 14px;
}
.card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* COMPLETED SECTION CARD */
.section-done-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 14px 18px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.section-done-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-done-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e8f5ee;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.section-done-check svg {
  color: var(--success);
}
.section-done-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.section-done-summary {
  font-size: 11px;
  color: var(--label);
  margin-top: 1px;
}
.section-done-edit {
  font-size: 11px;
  font-weight: 600;
  color: var(--navy-mid);
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
}

/* ── FIELD ROWS & COLS ─────────────────────────────────────── */
.field-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.field-row:last-child {
  margin-bottom: 0;
}
.f-col + .f-col {
  margin-top: 0;
}
.f-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.f-col.grow {
  flex: 1;
}
.f-col.shrink {
  flex-shrink: 0;
}

/* ── LABELS ────────────────────────────────────────────────── */
.f-label {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin-bottom: 7px;
  line-height: 1.3;
  display: flex;
  align-items: baseline;
  gap: 3px;
  letter-spacing: 0.01em;
}
.req {
  color: var(--error);
  font-size: 11px;
}
.f-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}
.f-hint.talking-point {
  color: #5a7a99;
  font-style: italic;
  margin-top: 8px;
}

/* ── INPUTS ────────────────────────────────────────────────── */
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-input);
  font-size: 15px;
  color: var(--text);
  background: #fff;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
input.error,
select.error,
textarea.error {
  border-color: var(--error);
  border-left: 3px solid var(--error);
  padding-left: 10px;
}
input.unfilled,
select.unfilled,
textarea.unfilled {
  background: var(--unfilled-bg);
  border-color: var(--unfilled-border);
}
.btn-grid.unfilled .btn-grid-item:not(.active) {
  background: var(--unfilled-bg);
  border-color: var(--unfilled-border);
}
textarea {
  min-height: 80px;
  resize: vertical;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23697386'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
.f-err {
  font-size: 11px;
  color: var(--error);
  margin-top: 4px;
  display: none;
}
.f-err.on {
  display: block;
}

/* ── RADIO PILLS (legacy, kept for compat) ─────────────────── */
.pill-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.pill {
  position: relative;
}
.pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.pill label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 24px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  background: #fff;
  transition: all var(--transition);
  min-height: 42px;
  white-space: nowrap;
  user-select: none;
  letter-spacing: -0.01em;
}
.pill input:checked + label {
  background: var(--black);
  border-color: var(--black);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.pill label:hover {
  border-color: #aaa;
  color: var(--text);
}
.pill label:active {
  transform: scale(0.97);
}

/* ── OR PAIR ───────────────────────────────────────────────── */
.or-pair {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.or-badge {
  font-size: 11px;
  font-weight: 700;
  color: #b0bec5;
  flex-shrink: 0;
}
.or-field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.or-field-suffix {
  font-size: 12px;
  color: var(--label);
  white-space: nowrap;
}

/* ── FEE TABLE ─────────────────────────────────────────────── */
.fee-table-wrap {
  overflow-x: auto;
}
.fee-table {
  width: 100%;
  border-collapse: collapse;
}
.fee-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--label);
  padding: 0 8px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.fee-table td {
  padding: 6px 8px;
  vertical-align: top;
}
.fee-table tr:first-child td {
  padding-top: 10px;
}
.fee-table input {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 14px;
}
.fee-row-del {
  background: none;
  border: none;
  color: #b0bec5;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
}
.fee-row-del:hover {
  color: var(--error);
}
.btn-add-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--green-deep);
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 0 0;
}
.btn-add-row:hover {
  color: var(--green);
}
.btn-add-row::before {
  content: "+";
  font-size: 15px;
  font-weight: 700;
}

/* ── CONTEXT BANNER ────────────────────────────────────────── */
.ctx-banner {
  background: #eef4ff;
  border: 1px solid #c7d7ff;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 12px;
  color: #2d4a8a;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.ctx-banner .ctx-icon {
  font-size: 13px;
  flex-shrink: 0;
}

/* ── STACKED FIELD SPACING ─────────────────────────────────── */
.card > [id^="fg-"] + [id^="fg-"] {
  margin-top: 20px;
}
.card > .field-row + [id^="fg-"] {
  margin-top: 20px;
}
.card > [id^="fg-"] + .field-row {
  margin-top: 20px;
}

/* ── DIVIDER ───────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}

/* ── SUMMARY CARD ──────────────────────────────────────────── */
.summary-section {
  margin-bottom: 10px;
}
.summary-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--label);
  margin-bottom: 8px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid #f2f4f7;
  font-size: 13px;
}
.summary-row:last-child {
  border-bottom: none;
}
.summary-key {
  color: var(--label);
  flex-shrink: 0;
  margin-right: 12px;
}
.summary-val {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

/* ── NAV FOOTER ────────────────────────────────────────────── */
#nav-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  gap: 10px;
  max-width: 860px;
  margin: 0 auto;
}
.btn {
  min-height: 42px;
  padding: 10px 22px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
#btn-back {
  flex: 0 0 90px;
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
  font-weight: 500;
}
#btn-back:hover {
  background: #f6f9fc;
}
#btn-next {
  flex: 1;
  background: var(--green);
  color: var(--black);
  font-weight: 700;
}
#btn-next:hover {
  background: #8dd438;
}
#btn-next:active {
  transform: scale(0.98);
}
#btn-next:disabled {
  background: #9aa8b9;
  cursor: not-allowed;
}
.btn-success {
  background: var(--success) !important;
}
.btn-submit-main {
  width: 100%;
  background: var(--green);
  color: var(--black);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 15px;
  min-height: 48px;
}
.btn-submit-main:hover {
  background: #8dd438;
}

/* ── BUTTON GRIDS ──────────────────────────────────────────── */
/* All option sets (Yes/No, short lists, utility picker) use one unified flex pattern.
   Buttons size to their content — "Yes" is narrow, "Rural Electric Cooperative" is wider. */
.btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.btn-grid-item {
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  line-height: 1.3;
  min-height: 44px;
  white-space: nowrap;
  width: auto;
  font-family: inherit;
}
.btn-grid-item:hover {
  border-color: #aaa;
  color: var(--text);
}
.btn-grid-item.active {
  background: var(--black);
  border-color: var(--black);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.btn-grid-item:active {
  transform: scale(0.97);
}

/* ── TOAST ─────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: #1a1f36;
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s;
  z-index: 999;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
#toast.on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── LOADING ───────────────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  background: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.spin {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
#loading p {
  color: #6b8baa;
  font-size: 12px;
  text-align: center;
}

/* ── OFFLINE/PENDING BANNERS ───────────────────────────────── */
.sys-banner {
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 500;
  display: none;
}
.sys-banner.on {
  display: block;
}
.sys-banner.warn {
  background: #fff8e1;
  border: 1px solid #ffd54f;
  color: #7a5800;
}
.sys-banner.ok {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #1b5e20;
  cursor: pointer;
}

/* ── ERROR SHAKE ───────────────────────────────────────────── */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  15% {
    transform: translateX(-6px);
  }
  30% {
    transform: translateX(5px);
  }
  45% {
    transform: translateX(-4px);
  }
  60% {
    transform: translateX(3px);
  }
  75% {
    transform: translateX(-2px);
  }
}
@keyframes errorFlash {
  0% {
    background: rgba(217, 45, 32, 0.07);
  }
  100% {
    background: transparent;
  }
}
.field-error-anim {
  animation:
    shake 0.35s ease,
    errorFlash 0.7s ease forwards;
  border-radius: 8px;
}

.hidden {
  display: none !important;
}

/* ── SECTION COMPLETE BADGE ────────────────────────────────── */
/* ── SUCCESS OVERLAY ───────────────────────────────────────── */
#success-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--black);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

#success-overlay.on {
  display: flex;
}

#success-card {
  text-align: center;
  max-width: 380px;
}

#success-check {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--green);
  color: var(--black);
  font-size: 36px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

#success-card h1 {
  color: var(--white);
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
}

#success-card p {
  color: #aaaaaa;
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 8px;
}

#success-timer {
  color: var(--green);
  font-size: 18px;
  font-weight: 600;
  margin: 24px 0 0;
}

#success-call {
  margin-top: 24px;
}

#success-call p {
  color: #aaaaaa;
  margin-bottom: 12px;
}

#call-btn {
  display: inline-block;
  background: var(--green);
  color: var(--black);
  font-size: 20px;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 10px;
  text-decoration: none;
}

#btn-received {
  display: block;
  width: 100%;
  margin-top: 32px;
  padding: 16px;
  background: transparent;
  border: 1px solid #444;
  color: #888;
  font-size: 15px;
  border-radius: 10px;
  cursor: pointer;
}

/* ── SECTION COMPLETE BADGE ────────────────────────────────── */
.complete-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e8f5ee;
  color: var(--success);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  margin-left: 10px;
  vertical-align: middle;
}
