:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #66736c;
  --line: #d9e2dc;
  --panel: #ffffff;
  --soft: #f4f7f5;
  --brand: #0f6f4f;
  --brand-dark: #0a513a;
  --accent: #c9482b;
  --focus: #175cdb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--soft);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px;
  background: #10251c;
  color: #fff;
  border-bottom: 4px solid var(--accent);
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.15;
}

.topbar h1,
.topbar p {
  margin: 0;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 13px;
  color: #b9d5c9;
  text-transform: uppercase;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(320px, 460px) minmax(340px, 1fr);
  gap: 16px;
  padding: 16px;
}

.panel {
  min-height: 220px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(20, 40, 30, 0.06);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h2,
h3,
h4,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

h3 {
  margin-bottom: 6px;
  font-size: 24px;
}

h4 {
  margin-bottom: 8px;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #2f3c35;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bdcbc3;
  border-radius: 6px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 3px solid rgba(23, 92, 219, 0.22);
  outline-offset: 1px;
  border-color: var(--focus);
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.wide {
  grid-column: 1 / -1;
}

.privacy-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.privacy-pill {
  color: #0d5139;
  background: #e0f2ea;
}

.status-pill {
  color: #5c3315;
  background: #fff0df;
}

.status-pill.status-verified {
  color: #0d5139;
  background: #d8eee2;
}

.status-pill.status-stub-active {
  color: #2b3f7a;
  background: #e2ebff;
}

.status-pill.status-stub-unverified {
  color: #5c3315;
  background: #fff0df;
}

.status-pill.status-no-program {
  color: #6b1d1d;
  background: #fde0e0;
}

.status-pill.status-partial {
  color: #5e4b00;
  background: #fdf3c6;
}

.programs-block {
  margin: 10px 0 4px;
  font-size: 13px;
  color: var(--ink);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.program-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.trust-banner {
  margin: 0 16px;
  margin-top: 12px;
  padding: 12px 16px;
  background: #e0f2ea;
  color: #0d3a28;
  border: 1px solid #b8dacb;
  border-left: 4px solid var(--brand);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.45;
}

.email-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.email-notice {
  margin: 8px 0;
  padding: 10px 12px;
  background: #fff7e6;
  border: 1px solid #f0d39a;
  border-radius: 6px;
  font-size: 13px;
  color: #5c3315;
  line-height: 1.4;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.save-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 13px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  cursor: pointer;
}
.save-toggle input[type="checkbox"] {
  width: 16px; height: 16px;
  margin: 0;
  accent-color: var(--brand);
}
.cookie-disclaimer {
  margin: 6px 28px 0;
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
@media (max-width: 760px) {
  .save-toggle { font-size: 12px; padding: 5px 8px; }
  .cookie-disclaimer { margin: 6px 14px 0; }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
}
.filters > label {
  flex: 1 1 140px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
.filters > label input,
.filters > label select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
.filters > label input:focus,
.filters > label select:focus {
  outline: 2px solid var(--focus);
  outline-offset: -1px;
}

.check-row {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink);
}
.check-row input {
  width: auto;
  flex: 0 0 auto;
}

/* School list: dropdown is the primary picker at every viewport.
   The card list is kept in the DOM but hidden — useful for future "all-visible" mode. */
.school-list {
  display: none;
}

.school-select-wrap {
  display: grid;
  gap: 4px;
  margin-top: 4px;
}

.school-select-wrap select {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.school-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.school-card-row strong { display: inline; margin-bottom: 0; }

.school-card {
  width: 100%;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.school-card:hover,
.school-card.active {
  border-color: var(--brand);
  box-shadow: inset 4px 0 0 var(--brand);
}

.school-card strong {
  display: block;
  margin-bottom: 4px;
}

.school-meta,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.detail-grid {
  display: grid;
  gap: 16px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 2px;
}

.primary-button,
.secondary-button,
.ghost-button,
.copy-button {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  background: var(--brand);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button,
.copy-button {
  color: var(--brand-dark);
  background: #eef7f2;
  border-color: #b8dacb;
}

.ghost-button {
  color: #fff;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.5);
}

.contact-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.contact-card p {
  margin-bottom: 4px;
}

.draft-box {
  width: 100%;
  min-height: 220px;
  white-space: pre-wrap;
}

.source-list {
  padding-left: 18px;
}

.empty-state {
  display: grid;
  min-height: 420px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.data-quality-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  font-size: 12px;
}

.dq-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f4f7f5;
  border: 1px solid var(--line);
  color: var(--ink);
  white-space: nowrap;
}

.dq-chip strong { margin-right: 4px; }

.empty-contacts {
  padding: 16px;
  background: #fffdf5;
  border: 1px dashed #e0c98a;
  border-radius: 8px;
  color: #5c3315;
  font-size: 14px;
  line-height: 1.5;
}

.info-missing-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 10px 0 4px;
  padding: 10px 12px;
  background: #f4f7f5;
  border: 1px solid var(--line);
  border-left: 3px solid #b9c8c0;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: #4a5751;
}

.info-missing-note strong { color: #2f3c35; font-weight: 700; }
.info-missing-note a { color: var(--brand-dark); font-weight: 700; }
.info-missing-icon {
  display: inline-block;
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--brand);
  font-weight: 700;
  letter-spacing: -2px;
  padding-top: 2px;
}

.empty-contacts strong { color: #3a2008; }

.empty-contacts a {
  color: var(--brand-dark);
  font-weight: 700;
}

/* ---------- Tablet ---------- */
@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr 1fr;
  }

  .detail-panel {
    grid-column: 1 / -1;
  }

  /* Filters: at tablet width, let labels grow a bit so 2-3 fit per row */
  .filters > label { flex: 1 1 180px; }
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    padding: 16px 16px 14px;
    gap: 10px;
  }

  .topbar h1 { font-size: 22px; }
  .eyebrow { font-size: 11px; }
  .ghost-button { padding: 8px 10px; font-size: 13px; }

  .trust-banner {
    margin: 10px 12px 0;
    padding: 10px 12px;
    font-size: 13px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .panel {
    padding: 14px;
    min-height: 0;
  }

  .detail-panel { grid-column: auto; }

  .profile-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Mobile filters: each label is full width, stacks cleanly */
  .filters {
    flex-direction: column;
    gap: 10px;
  }
  .filters > label { flex: 1 1 auto; width: 100%; }

  /* Stack detail action buttons full-width so they're tappable */
  .detail-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .detail-actions a.primary-button,
  .detail-actions button.secondary-button,
  .detail-actions a.secondary-button {
    width: 100%;
    text-align: center;
  }

  /* Email action row: stack and fill */
  .email-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .email-actions .copy-button,
  .email-actions .primary-button {
    width: 100%;
    text-align: center;
  }

  /* Larger tap targets */
  input,
  select,
  textarea {
    padding: 12px 12px;
    font-size: 16px; /* prevents iOS zoom-on-focus */
  }
  .primary-button,
  .secondary-button,
  .copy-button {
    min-height: 44px;
    font-size: 15px;
  }

  /* Section heading wraps to two rows so the status pill doesn't crush the title */
  .section-heading {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  /* Programs/data chips a touch larger */
  .program-chip { font-size: 11px; }

  /* Email draft area shorter so the action buttons stay visible */
  .draft-box { min-height: 180px; }

  /* Source list scrolls within its panel rather than expanding the page forever */
  .source-list { max-height: 200px; overflow-y: auto; padding-right: 8px; }

  /* School list cards: looser tap area, hide the long region/sport meta if it overflows */
  .school-card { padding: 14px; }
  .school-card .school-meta { font-size: 12px; }

  /* Contact card: full-width copy button, looser spacing */
  .contact-card .copy-button { display: block; width: 100%; margin-top: 6px; }

  /* Hide the empty-state min-height tower on mobile so the panel collapses cleanly */
  .empty-state { min-height: 200px; }
}

/* ---------- "Start here" callout + top-contact highlight ---------- */
.start-here {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff8d4;
  border: 1px solid #d8b836;
  border-left: 4px solid #d8b836;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 12px;
}
.start-here-star {
  font-size: 20px;
  color: #b88b00;
  line-height: 1.2;
  flex-shrink: 0;
}
.start-here-line { margin: 0; line-height: 1.4; }
.start-here-line + .start-here-line { margin-top: 4px; }

.contact-card.is-top-contact {
  border: 1px solid #d8b836;
  background: #fffdf3;
  box-shadow: 0 1px 0 #f4e7a4;
}
.tag-top {
  background: #fff5d4;
  color: #6a4c00;
  border: 1px solid #d8b836;
  font-weight: bold;
}

/* ---------- Contact sport / admin tag ---------- */
.contact-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.tag-sport { background: #e5f3ec; color: #0a513a; border: 1px solid #b3d9c3; }
.tag-admin { background: #f0eaf8; color: #4a2c83; border: 1px solid #d5c5ec; }

/* ---------- Form Helper modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 20, 16, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 1000;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  background: var(--panel);
  border-radius: 12px;
  max-width: 720px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: #10251c; color: #fff;
}
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-header .ghost-button {
  color: #fff; background: transparent; border: 1px solid #ffffff44;
  width: 32px; height: 32px; padding: 0; font-size: 18px; line-height: 1;
}
.modal-body { padding: 18px 22px 22px; }
.modal-body .helper-steps { padding-left: 22px; line-height: 1.55; }
.modal-body .helper-steps > li { margin: 10px 0; }
.modal-body .primary-button,
.modal-body .secondary-button { margin: 6px 4px 6px 0; }

.helper-tabs { display: flex; gap: 0; margin: 10px 0 0; }
.helper-tab {
  flex: 1; background: var(--soft); border: 1px solid var(--line);
  color: var(--ink); padding: 10px; cursor: pointer;
}
.helper-tab:first-child { border-radius: 8px 0 0 8px; }
.helper-tab:last-child { border-radius: 0 8px 8px 0; border-left: none; }
.helper-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.helper-pane { padding: 14px 2px 0; }
.helper-fields { list-style: none; padding: 0; margin: 8px 0 0; }
.helper-fields li {
  display: grid; grid-template-columns: minmax(140px, 1fr) 2fr auto;
  gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.helper-field-label { color: var(--muted); font-size: 13px; }
.helper-field-value {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: var(--soft); padding: 4px 8px; border-radius: 6px;
  font-size: 13px; word-break: break-word;
  border: 1px solid var(--line);
}
.helper-pane .small { font-size: 12px; }
.bookmarklet-link {
  display: inline-block;
  background: #fff5d4; color: #6a4c00;
  border: 1px dashed #c79a1f;
  padding: 8px 14px; border-radius: 6px;
  text-decoration: none; font-weight: bold;
  cursor: grab;
}
.bookmarklet-link:active { cursor: grabbing; }
.form-helper-btn { margin-left: 6px; }

@media (max-width: 760px) {
  .modal-card { border-radius: 8px; }
  .modal-body { padding: 14px; }
  .helper-fields li { grid-template-columns: 1fr; gap: 4px; }
  .helper-field-label { font-size: 12px; }
  .helper-tab { font-size: 13px; }
}

/* ---------- Small phones ---------- */
@media (max-width: 380px) {
  .topbar { padding: 14px; gap: 8px; }
  .topbar h1 { font-size: 20px; }
  .panel { padding: 12px; }
  h3 { font-size: 20px; }
}
