:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1e40af;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

.container { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; }
.container:has(.wizard-layout) { max-width: 1200px; }

.wizard-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.75rem;
  align-items: start;
}
.wizard-nav {
  position: sticky;
  top: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0;
  padding: 1rem 0.75rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.wizard-nav-title {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.5rem;
}
.wizard-nav-group {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  margin: 0.85rem 0.5rem 0.35rem;
  font-weight: 700;
}
.wizard-nav-item {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.35rem 0.5rem;
  text-decoration: none;
  color: var(--color-text);
  border-radius: 0;
  line-height: 1.3;
}
.wizard-nav-item.level-0 { font-size: 0.88rem; font-weight: 700; margin-top: 0.35rem; }
.wizard-nav-item.level-1 { font-size: 0.8rem; font-weight: 600; padding-left: 1rem; }
.wizard-nav-item.level-2 { font-size: 0.74rem; font-weight: 400; padding-left: 1.75rem; color: #475569; }
a.wizard-nav-item:hover { background: #eff6ff; color: var(--color-primary-dark); }
.wizard-nav-item.is-active {
  background: #dbeafe;
  color: var(--color-primary-dark);
}
.wizard-nav-item.is-disabled { opacity: 0.55; cursor: default; }
.wizard-nav-step {
  flex: 0 0 1.4rem;
  font-weight: 700;
  color: var(--color-muted);
}
.wizard-nav-item.is-active .wizard-nav-step { color: var(--color-primary-dark); }
.wizard-nav-label { flex: 1; }
.wizard-main { min-width: 0; }

@media (max-width: 900px) {
  .wizard-layout { grid-template-columns: 1fr; }
  .wizard-nav { position: static; max-height: none; }
}

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0;
  padding-bottom: 0;
}

.logo {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-primary);
  text-decoration: none;
}

.logout-form { display: flex; align-items: center; gap: 1rem; }
.user-email { color: var(--color-muted); font-size: 0.875rem; }

.auth-card {
  max-width: 420px;
  margin: 3rem auto;
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.subtitle { color: var(--color-muted); margin-bottom: 1.5rem; }
.auth-footer { margin-top: 1.5rem; text-align: center; color: var(--color-muted); }

.form label { display: block; font-weight: 600; margin: 1rem 0 0.375rem; font-size: 0.875rem; }
.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="number"],
.form select,
.form textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
}

.form textarea { resize: vertical; min-height: 120px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.form-group label { margin-top: 0; }

.radio-group { border: none; margin: 1rem 0; }
.radio-group legend { font-weight: 600; font-size: 0.875rem; margin-bottom: 0.5rem; }
.radio-group label { display: inline-flex; align-items: center; gap: 0.375rem; font-weight: 400; margin-right: 1.5rem; }

.btn {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-block { width: 100%; margin-top: 1.5rem; }

.form-actions { margin-top: 2rem; display: flex; gap: 0.75rem; justify-content: flex-end; }
.form-actions-spread { justify-content: space-between; align-items: center; }
.action-group { display: flex; gap: 0.75rem; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.program-list { display: flex; flex-direction: column; gap: 1rem; }
.program-card {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--color-surface); padding: 1.25rem 1.5rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.program-card h2 { font-size: 1.125rem; }
.meta { color: var(--color-muted); font-size: 0.875rem; margin-top: 0.25rem; }

.badge { display: inline-block; padding: 0.125rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; margin-left: 0.5rem; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-progress { background: #dbeafe; color: #1e40af; }
.badge-optional { background: #f1f5f9; color: #475569; }

.empty-state { text-align: center; padding: 4rem 2rem; color: var(--color-muted); }
.empty-state p { margin-bottom: 1.5rem; }

.wizard-header { margin-bottom: 2rem; }
.wizard-header h1 { font-size: 1.75rem; }
.step-indicator { color: var(--color-primary); font-weight: 600; font-size: 0.875rem; }

.county-toolbar { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 200px; padding: 0.5rem 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius); }

.county-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--color-surface);
}

.county-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem 0.5rem; border-radius: 4px; cursor: pointer;
}
.county-item:hover { background: var(--color-bg); }

.report-screen .screen-header { font-size: 1.5rem; margin-bottom: 0.25rem; }
.report-screen .screen-subheader { font-size: 1.125rem; color: var(--color-muted); font-weight: 500; margin-bottom: 1.5rem; }
.screen-progress { color: var(--color-muted); font-size: 0.875rem; margin-bottom: 1rem; }

.visualization { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 0; padding: 1rem; margin-bottom: 1rem; text-align: center; }
.chart-image { max-width: 100%; height: auto; }
.chart-interactive { text-align: left; }
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: var(--color-muted);
}
.chart-controls[hidden] { display: none !important; }
.chart-control { display: inline-flex; align-items: center; gap: 0.35rem; }
.chart-control select {
  margin-left: 0.35rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--color-border);
  background: #fff;
}
.chart-control-check { cursor: pointer; user-select: none; }
.chart-control-series {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  width: 100%;
  align-items: center;
}
.chart-control-series-label {
  font-weight: 600;
  color: var(--color-text);
  margin-right: 0.25rem;
}
.echart-canvas { width: 100%; height: 360px; }
.chart-error { color: #b91c1c; font-size: 0.9rem; padding: 1rem 0; }

.block-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.block-split-visual, .block-split-text { min-width: 0; }
.block-split-text textarea { width: 100%; }
.mock-badge {
  display: inline-block;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fdba74;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: 0;
}
.alert-mock {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fdba74;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 0;
}
.help-text { color: var(--color-muted); font-size: 0.875rem; margin: 0 0 1rem; }
.chart-color-row { flex-wrap: wrap; }

@media (max-width: 900px) {
  .block-split { grid-template-columns: 1fr; }
}

.table-preview { overflow-x: auto; margin-bottom: 1.5rem; }
.table-preview table { width: 100%; border-collapse: collapse; background: var(--color-surface); }
.table-preview th, .table-preview td { border: 1px solid var(--color-border); padding: 0.5rem 0.75rem; text-align: center; }
.table-preview th { background: var(--color-bg); font-weight: 600; }
.summary-row { background: #f1f5f9; font-weight: 600; }

.tool-text { margin: 0.75rem 0 1rem; }
.tool-text p { margin-bottom: 0.5rem; }
.user-prompt {
  display: block;
  font-weight: 400;
  font-style: italic;
  color: #4b5563;
  margin: 0.75rem 0 0.35rem;
}
.alert-incomplete {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 0.9rem 1rem;
  margin-bottom: 1.25rem;
}
.alert-incomplete a { color: #991b1b; font-weight: 600; }
.alert-incomplete ul { margin: 0.5rem 0 0 1.25rem; }
.review-document { display: flex; flex-direction: column; gap: 1.5rem; margin: 1.5rem 0 2rem; }
.review-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 1.25rem 1.5rem;
}
.review-user-text { margin-top: 0.75rem; white-space: pre-wrap; }
.confirm-dialog {
  border: 1px solid var(--color-border);
  padding: 0;
  max-width: 420px;
}
.confirm-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.confirm-dialog-inner { padding: 1.25rem 1.5rem; }
.style-checks { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; padding-top: 1.5rem; }
.check-inline { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 400; }
.style-row { align-items: end; }

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; margin-top: 1rem; }
.section-title { font-size: 1.125rem; margin-bottom: 0.5rem; }

.btn-primary:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.dev-email {
  background: #f8fafc;
  border: 1px dashed var(--color-border);
  padding: 1rem;
  margin: 1rem 0;
  border-radius: var(--radius);
  overflow-x: auto;
}
.dev-email pre { white-space: pre-wrap; font-size: 0.8125rem; }

.header-nav { display: flex; align-items: center; gap: 1rem; }
.nav-link { color: var(--color-primary); text-decoration: none; font-weight: 600; font-size: 0.875rem; }

.content-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
}
/* Room for the absolute-positioned switch in the card corner */
.content-block:has(.status-toggle) {
  padding-right: 2.75rem;
}
.content-block.block-excluded .block-headings,
.content-block.block-excluded .block-body {
  opacity: 0.55;
}
.content-block.block-excluded .block-body {
  pointer-events: none;
  filter: grayscale(0.35);
  user-select: none;
}
.block-top {
  display: block;
  margin-bottom: 0.75rem;
}
.block-headings { min-width: 0; }
.block-header { font-size: 1.35rem; margin-bottom: 0.25rem; font-weight: 700; }
.block-subheader { font-size: 1.1rem; color: var(--color-text); margin: 0.5rem 0 0.25rem; font-weight: 700; }
.block-subsubheader { font-size: 0.95rem; color: #000; margin: 0.25rem 0 0; font-weight: 700; }
.screen-header { font-weight: 700; }
.pre-written-text { margin: 0.75rem 0; }
.pre-written-text p { margin-bottom: 0.75rem; }
.hold-text { color: #b45309; font-style: italic; }

/* iPhone-style switch — pinned inside the white card, upper right */
.status-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  margin: 0;
  padding: 0;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.status-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  pointer-events: none;
}
.status-toggle-track {
  display: block;
  width: 26px;
  height: 16px; /* half of prior 31px iOS height */
  background: #e9e9eb; /* iOS off-state grey “slide” */
  border-radius: 999px;
  position: relative;
  box-sizing: border-box;
  transition: background 0.22s ease;
  border: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}
.status-toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.22s ease;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.18),
    0 1px 1px rgba(0, 0, 0, 0.08);
}
.status-toggle-input:checked + .status-toggle-track {
  background: #34c759; /* iOS on-state green */
}
.status-toggle-input:checked + .status-toggle-track .status-toggle-thumb {
  transform: translateX(10px);
}
.status-toggle-input:focus-visible + .status-toggle-track {
  outline: 2px solid #34c759;
  outline-offset: 3px;
}
.support-banner {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}
.support-banner a { color: #9a3412; font-weight: 600; }
.exclude-toggle { margin-bottom: 1rem; }
.section-block { margin-top: 1rem; }
.section-block h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.program-card h3 { font-size: 1.125rem; }
.header-actions { display: flex; gap: 0.75rem; }
.text-danger { color: #991b1b; }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--color-surface); font-size: 0.875rem; }
.admin-table th, .admin-table td { border: 1px solid var(--color-border); padding: 0.5rem 0.6rem; text-align: left; vertical-align: top; }
.admin-table th { background: var(--color-bg); }
.admin-actions { display: flex; flex-direction: column; gap: 0.35rem; min-width: 220px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }
.mark-paid-form select, .mark-paid-form input { font-size: 0.75rem; padding: 0.25rem; max-width: 140px; }
.tier-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.container { max-width: 1100px; }
