/* ═══════════ FORM-SPECIFIC STYLES ═══════════ */

/* ── Member card (Family Demographic Profile) ── */
.member-card {
  border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 1rem 1.15rem 1.15rem; margin: 0 0 1rem; background: var(--c-surface);
}
.member-card:nth-of-type(even) { background: var(--c-surface-alt); }
.member-card > legend {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  font-family: var(--font-body); font-size: .82rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--c-accent);
  padding: 0; margin-bottom: .5rem;
}
.member-card__num { flex: 1; }
.member-card__grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 1rem; }
.member-card__grid .field { margin-bottom: .85rem; }
.member-card__grid .field > label { font-size: .76rem; font-weight: 600; margin-bottom: .25rem; }
.member-card__grid input, .member-card__grid select { padding: .5rem .6rem; font-size: .88rem; }

/* Hide the remove button when only one member row remains. */
#members:has(> .member-card:only-child) [data-remove-member] { display: none; }

/* ── Profiling summary grid ── */
.summary-section { margin-bottom: 2rem; }
.summary-section__head {
  display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  padding-bottom: .6rem; margin-bottom: .85rem; border-bottom: 2px solid var(--c-primary);
}
.summary-section__head h3 { margin: 0; font-size: 1.05rem; }
.summary-section__total {
  margin-left: auto; font-size: .82rem; font-weight: 700;
  color: var(--c-accent); letter-spacing: .04em; text-transform: uppercase;
}

.count-grid th.num, .count-grid td.num { text-align: right; width: 110px; }
.count-grid tfoot td {
  border-top: 2px solid var(--c-border); font-weight: 700;
  background: var(--c-surface-alt); color: var(--c-ink);
}

/* Small screens: the count grid becomes stacked rows with visible labels. */
@media (max-width: 600px) {
  .count-grid, .count-grid tbody, .count-grid tr, .count-grid td, .count-grid tfoot { display: block; width: 100%; }
  .count-grid thead { display: none; }
  .count-grid tr {
    border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: .6rem .75rem; margin-bottom: .6rem; background: var(--c-surface);
  }
  .count-grid tbody tr:nth-child(even) { background: var(--c-surface-alt); }
  .count-grid td { border: 0; padding: .3rem 0; display: flex; align-items: center; gap: .75rem; }
  .count-grid td::before {
    content: attr(data-label); flex: 1 1 auto; min-width: 0;
    text-align: left; white-space: nowrap;
    font-size: .8rem; font-weight: 600; color: var(--c-text-muted);
  }
  .count-grid td:first-child {
    font-weight: 700; color: var(--c-ink); padding-bottom: .5rem;
    margin-bottom: .35rem; border-bottom: 1px solid var(--c-border); display: block;
  }
  .count-grid td:first-child::before { content: none; }
  /* Beat the desktop `.count-grid td.num { width: 110px }` rule (same specificity). */
  .count-grid td.num { width: 100%; justify-content: flex-end; text-align: left; }
  .count-grid th.num { width: auto; }
  .count-grid input[type=number] { max-width: 110px; }
  .count-grid .total-cell { background: transparent; }

  .member-card__grid { grid-template-columns: 1fr; }
}

/* ── Print: forms should print cleanly as a paper record ── */
@media print {
  .member-card { break-inside: avoid; border: 1px solid #999; background: #fff !important; }
  fieldset { break-inside: avoid; }
  .summary-section { break-inside: avoid; }
}
