/* ===== APP SHELL ===== */
.app-body {
  background: var(--bg);
  min-height: 100vh;
}

.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  height: 60px;
  background: rgba(12, 10, 9, 0.92);
  border-bottom: 1px solid rgba(168, 162, 158, 0.1);
  backdrop-filter: blur(12px);
}

.app-nav-brand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.app-nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.app-nav-link {
  font-size: 0.9rem;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.app-nav-link:hover { color: var(--fg); }

.app-nav-cta {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  padding: 8px 18px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
}
.app-nav-cta:hover { background: var(--accent-glow); transform: translateY(-1px); }

.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 40px 80px;
}

/* ===== PAGE HEADERS ===== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 48px;
  gap: 24px;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin-bottom: 8px;
}

.page-sub {
  color: var(--fg-muted);
  font-size: 1rem;
}

.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-decoration: none;
  margin-bottom: 12px;
  transition: color 0.2s;
}
.back-link:hover { color: var(--accent); }

/* ===== BUTTONS ===== */
.btn-primary {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  padding: 11px 24px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-glow); transform: translateY(-1px); }

.btn-secondary {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--bg-card);
  padding: 11px 24px;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid rgba(168, 162, 158, 0.2);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-secondary:hover { border-color: rgba(168, 162, 158, 0.5); color: var(--fg); }

.btn-ghost {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-muted);
  background: transparent;
  padding: 9px 20px;
  border-radius: 6px;
  border: 1px solid rgba(168, 162, 158, 0.15);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}
.btn-ghost:hover { border-color: rgba(168, 162, 158, 0.4); color: var(--fg); }

.btn-full { width: 100%; text-align: center; }

/* ===== ALERTS ===== */
.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 32px;
  color: #FCA5A5;
  font-size: 0.9rem;
}

/* ===== INTAKE FORM ===== */
.intake-page { max-width: 720px; }

.intake-form { display: flex; flex-direction: column; gap: 40px; }

.form-section {
  border-bottom: 1px solid rgba(168, 162, 158, 0.1);
  padding-bottom: 40px;
}
.form-section:last-of-type { border-bottom: none; }

.form-section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 24px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
}

.required { color: var(--accent); }

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-card);
  border: 1px solid rgba(168, 162, 158, 0.2);
  border-radius: 8px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  resize: vertical;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}
.form-group select option { background: var(--bg-card); }
.form-group input::placeholder,
.form-group textarea::placeholder { color: rgba(168, 162, 158, 0.5); }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  padding-top: 8px;
}

/* ===== PATHWAY VIEW ===== */
.pathway-page {}

.pathway-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
}

.pathway-header-left {}

.participant-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-top: 8px;
}

/* Stage pipeline */
.stage-pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 48px;
}

.pipeline-stage {
  background: var(--bg-card);
  border: 1px solid rgba(168, 162, 158, 0.1);
  border-radius: 10px;
  padding: 20px 18px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.pipeline-stage--active {
  opacity: 1;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.06);
}

.pipeline-stage--done {
  opacity: 0.75;
}

.pipeline-dot {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.pipeline-stage--done .pipeline-dot { color: var(--green); }

.pipeline-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 12px;
}

.pipeline-progress {
  height: 3px;
  background: rgba(168, 162, 158, 0.15);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}

.pipeline-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

.pipeline-stage--done .pipeline-bar { background: var(--green); }

.pipeline-pct {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

/* Pathway content grid */
.pathway-content {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  align-items: start;
}

/* Milestones panel */
.milestones-panel { display: flex; flex-direction: column; gap: 32px; }

.milestone-stage {
  background: var(--bg-card);
  border: 1px solid rgba(168, 162, 158, 0.1);
  border-radius: 12px;
  padding: 28px;
  opacity: 0.55;
  transition: opacity 0.2s;
}

.milestone-stage--active {
  opacity: 1;
  border-color: rgba(245, 158, 11, 0.25);
}

.milestone-stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.milestone-stage-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
}

.milestone-count {
  font-size: 0.8rem;
  color: var(--fg-muted);
  background: rgba(168, 162, 158, 0.1);
  padding: 3px 10px;
  border-radius: 20px;
}

.milestone-empty {
  font-size: 0.9rem;
  color: var(--fg-muted);
  font-style: italic;
}

.milestone-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.milestone-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(168, 162, 158, 0.07);
}
.milestone-item:last-child { border-bottom: none; }

.milestone-item--done .milestone-title { text-decoration: line-through; color: var(--fg-muted); }

.milestone-toggle-form { flex-shrink: 0; margin-top: 2px; }

.milestone-checkbox {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.milestone-checkbox:hover { opacity: 1; }

.milestone-text { flex: 1; min-width: 0; }

.milestone-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.4;
}

.milestone-desc {
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin-top: 3px;
  line-height: 1.5;
}

.milestone-date {
  font-size: 0.78rem;
  color: var(--green);
  margin-top: 4px;
}

/* Sidebar */
.pathway-sidebar { display: flex; flex-direction: column; gap: 20px; }

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid rgba(168, 162, 158, 0.1);
  border-radius: 12px;
  padding: 24px;
}

.sidebar-card-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

.sidebar-note {
  font-size: 0.9rem;
  color: var(--green);
  line-height: 1.5;
}

.sidebar-field { margin-bottom: 14px; }
.sidebar-field:last-child { margin-bottom: 0; }

.sidebar-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 4px;
}

.sidebar-field p {
  font-size: 0.88rem;
  color: var(--fg);
  line-height: 1.55;
}

.sidebar-card textarea {
  background: var(--bg-warm);
  border: 1px solid rgba(168, 162, 158, 0.15);
  border-radius: 6px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  resize: vertical;
  line-height: 1.55;
}
.sidebar-card textarea:focus { border-color: var(--accent); }

/* Stage badge */
.stage-badge {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.stage-badge--assessment { background: rgba(245, 158, 11, 0.15); color: var(--accent); }
.stage-badge--stabilization { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.stage-badge--economic_development { background: rgba(139, 92, 246, 0.15); color: #A78BFA; }
.stage-badge--independence { background: rgba(34, 197, 94, 0.15); color: var(--green); }

/* Housing tag */
.housing-tag {
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: capitalize;
  color: var(--fg-muted);
  background: rgba(168, 162, 158, 0.1);
  padding: 3px 10px;
  border-radius: 4px;
}

/* ===== DASHBOARD ===== */
.dashboard-page {}

.stage-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.stage-summary-card {
  background: var(--bg-card);
  border: 1px solid rgba(168, 162, 158, 0.1);
  border-left: 3px solid;
  border-radius: 10px;
  padding: 24px 20px;
}

.stage-summary-num {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}

.stage-summary-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--fg-muted);
}

/* Participant table */
.participant-table-wrapper {
  background: var(--bg-card);
  border: 1px solid rgba(168, 162, 158, 0.1);
  border-radius: 12px;
  overflow: hidden;
}

.participant-table {
  width: 100%;
  border-collapse: collapse;
}

.participant-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  padding: 16px 20px;
  border-bottom: 1px solid rgba(168, 162, 158, 0.1);
  background: rgba(168, 162, 158, 0.03);
}

.participant-table td {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(168, 162, 158, 0.06);
  vertical-align: middle;
  font-size: 0.9rem;
  color: var(--fg);
}

.participant-table tr:last-child td { border-bottom: none; }
.participant-table tbody tr:hover { background: rgba(168, 162, 158, 0.03); }

.participant-name { font-weight: 500; }
.participant-email { font-size: 0.8rem; color: var(--fg-muted); margin-top: 2px; }

.stage-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid;
  white-space: nowrap;
}

.progress-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar-small {
  width: 80px;
  height: 4px;
  background: rgba(168, 162, 158, 0.15);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.progress-fill-small {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}

.progress-label { font-size: 0.8rem; color: var(--fg-muted); }

.next-action { font-size: 0.82rem; color: var(--fg-muted); }

.table-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
  white-space: nowrap;
}
.table-link:hover { color: var(--accent-glow); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 40px;
  background: var(--bg-card);
  border: 1px solid rgba(168, 162, 158, 0.1);
  border-radius: 12px;
}

.empty-state-icon {
  font-size: 3rem;
  color: rgba(168, 162, 158, 0.3);
  margin-bottom: 20px;
  line-height: 1;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.empty-state p {
  color: var(--fg-muted);
  margin-bottom: 28px;
}

/* Error page */
.error-page {
  text-align: center;
  padding: 80px 40px;
  max-width: 500px;
  margin: 0 auto;
}

.error-icon {
  font-size: 3rem;
  color: rgba(168, 162, 158, 0.3);
  margin-bottom: 20px;
}

.error-page h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.error-page p {
  color: var(--fg-muted);
  margin-bottom: 28px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .app-main { padding: 32px 24px 60px; }
  .app-nav { padding: 0 24px; }

  .stage-pipeline {
    grid-template-columns: repeat(2, 1fr);
  }

  .pathway-content {
    grid-template-columns: 1fr;
  }

  .pathway-sidebar { order: -1; }

  .stage-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .participant-table-wrapper { overflow-x: auto; }

  .form-row { grid-template-columns: 1fr; }

  .page-header { flex-direction: column; }
  .pathway-header { flex-direction: column; gap: 16px; }
}

@media (max-width: 600px) {
  .stage-pipeline { grid-template-columns: 1fr 1fr; }
  .stage-summary { grid-template-columns: 1fr 1fr; }
}
