/* ─── portal.css ─────────────────────────────────────────────────────────────
   Rep-facing Community Finance Portal styles.
   Appended: budget allocation panel (.budget-panel / .budget-tier / .budget-slider-row)
   Appended: auth screen (.portal-auth / .portal-auth__*)
──────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  line-height: 1.6;
}

/* ── Portal shell ─────────────────────────────────────────────────────────── */
.portal {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.portal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid #e2e8f0;
  flex-wrap: wrap;
}
.portal__heading {
  margin: 0 0 0.2rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
}
.portal__subheading {
  margin: 0;
  font-size: 0.88rem;
  color: #64748b;
}
.portal__signout {
  padding: 0.45rem 1rem;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
}
.portal__signout:hover { background: #e2e8f0; }

/* ── Sections ─────────────────────────────────────────────────────────────── */
.portal__section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.portal__section-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}
.portal__section-desc {
  margin: 0 0 1.1rem;
  font-size: 0.88rem;
  color: #64748b;
}
.portal__section--budget { border-left: 4px solid #3b82f6; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.portal__tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.portal__tab {
  padding: 0.45rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  font-size: 0.88rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.portal__tab:hover { background: #f1f5f9; }
.portal__tab--active {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
  font-weight: 600;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.portal__form { display: flex; flex-direction: column; gap: 1rem; }
.portal__form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 540px) { .portal__form-row { grid-template-columns: 1fr; } }

.portal__field { display: flex; flex-direction: column; gap: 0.3rem; }
.portal__field label { font-size: 0.88rem; font-weight: 600; color: #475569; }
.portal__field input,
.portal__field textarea,
.portal__field select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95rem;
  color: #0f172a;
  background: #fff;
  transition: border-color .15s;
}
.portal__field input:focus,
.portal__field textarea:focus,
.portal__field select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.portal__field textarea { resize: vertical; min-height: 90px; }
.portal__field-hint { font-size: 0.78rem; color: #94a3b8; }

.portal__submit {
  align-self: flex-start;
  padding: 0.6rem 1.4rem;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.portal__submit:hover   { background: #1e293b; }
.portal__submit:disabled { background: #94a3b8; cursor: not-allowed; }

.portal__form-success {
  background: #f0fdf4; color: #15803d;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
}
.portal__form-error {
  background: #fef2f2; color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
}

/* ── History ──────────────────────────────────────────────────────────────── */
.portal__history { display: flex; flex-direction: column; gap: 0.6rem; }
.portal__history-empty { color: #94a3b8; font-size: 0.9rem; margin: 0; }

.portal__history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  flex-wrap: wrap;
}
.portal__history-item__meta { display: flex; flex-direction: column; gap: 0.15rem; }
.portal__history-item__type {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.portal__history-item__desc { font-size: 0.88rem; color: #475569; }
.portal__history-item__amount { font-size: 0.92rem; font-weight: 600; color: #0f172a; }

.portal__paid-badge {
  font-size: 0.78rem;
  font-weight: 600;
  background: #dcfce7;
  color: #15803d;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
}

.portal__status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  text-transform: capitalize;
}
.portal__status--pending         { background: #fef9c3; color: #854d0e; }
.portal__status--self_reported   { background: #e0f2fe; color: #0369a1; }
.portal__status--verified        { background: #ede9fe; color: #6d28d9; }
.portal__status--approved        { background: #dcfce7; color: #15803d; }
.portal__status--rejected        { background: #fee2e2; color: #b91c1c; }
.portal__status--returned        { background: #f1f5f9; color: #475569; }

/* ════════════════════════════════════════════════════════════════════════════
   BUDGET ALLOCATION PANEL  (.budget-panel / .budget-tier / .budget-slider-row)
   Portal section: drag sliders to allocate received funds to budget items.
════════════════════════════════════════════════════════════════════════════ */

/* Pool banner */
.budget-panel__pool {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.budget-pool__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.88rem;
}
.budget-pool__label { color: #475569; }
.budget-pool__value { font-weight: 700; color: #0f172a; }
.budget-pool__row--highlight .budget-pool__label { font-weight: 700; color: #0369a1; }
.budget-pool__row--highlight .budget-pool__value { color: #0369a1; font-size: 1rem; }

/* Tier groups */
.budget-panel__tiers {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  margin-bottom: 1.5rem;
}

.budget-tier {
  border-left: 3px solid #e2e8f0;
  padding-left: 1rem;
}
.budget-tier--expected    { border-left-color: #3b82f6; }
.budget-tier--desired     { border-left-color: #22c55e; }
.budget-tier--contingency { border-left-color: #f59e0b; }

.budget-tier__heading {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #475569;
}
.budget-tier--expected    .budget-tier__heading { color: #1d4ed8; }
.budget-tier--desired     .budget-tier__heading { color: #15803d; }
.budget-tier--contingency .budget-tier__heading { color: #b45309; }

/* Slider rows */
.budget-slider-row {
  margin-bottom: 1rem;
}
.budget-slider-row:last-child { margin-bottom: 0; }

.budget-slider-row__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  flex-wrap: wrap;
}
.budget-slider-row__label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
}
.budget-slider-row__values {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: #64748b;
  white-space: nowrap;
}
.budget-slider-row__allocated { font-weight: 700; color: #0f172a; }
.budget-slider-row__sep       { color: #cbd5e1; }
.budget-slider-row__goal      { color: #94a3b8; }
.budget-slider-row__pct       { color: #64748b; font-size: 0.78rem; }

.budget-slider-row__notes {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: #94a3b8;
  font-style: italic;
}

/* Range slider */
.budget-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 99px;
  outline: none;
  cursor: pointer;
  margin-bottom: 0.3rem;
  transition: background .15s;
}
.budget-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #3b82f6;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: background .15s, transform .1s;
}
.budget-slider::-webkit-slider-thumb:hover  { background: #2563eb; transform: scale(1.15); }
.budget-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  background: #3b82f6;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.budget-tier--desired     .budget-slider::-webkit-slider-thumb { background: #22c55e; }
.budget-tier--desired     .budget-slider::-webkit-slider-thumb:hover { background: #16a34a; }
.budget-tier--desired     .budget-slider::-moz-range-thumb { background: #22c55e; }
.budget-tier--contingency .budget-slider::-webkit-slider-thumb { background: #f59e0b; }
.budget-tier--contingency .budget-slider::-webkit-slider-thumb:hover { background: #d97706; }
.budget-tier--contingency .budget-slider::-moz-range-thumb { background: #f59e0b; }

/* Visual fill bar under slider */
.budget-slider-row__bar {
  height: 4px;
  background: #f1f5f9;
  border-radius: 99px;
  overflow: hidden;
}
.budget-slider-row__fill {
  height: 100%;
  background: #3b82f6;
  border-radius: 99px;
  transition: width .15s;
}
.budget-tier--desired     .budget-slider-row__fill { background: #22c55e; }
.budget-tier--contingency .budget-slider-row__fill { background: #f59e0b; }

/* Footer */
.budget-panel__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
}

.budget-panel__visibility-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #475569;
  cursor: pointer;
}
.budget-panel__visibility-toggle input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: #3b82f6;
  cursor: pointer;
}

.budget-panel__save {
  padding: 0.55rem 1.3rem;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.budget-panel__save:hover    { background: #1e293b; }
.budget-panel__save:disabled { background: #94a3b8; cursor: not-allowed; }

.budget-panel--empty {
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
}
.budget-panel--empty p { margin: 0; font-size: 0.9rem; color: #94a3b8; }

/* Responsive */
@media (max-width: 540px) {
  .budget-panel__footer  { flex-direction: column; align-items: flex-start; }
  .budget-panel__save    { width: 100%; text-align: center; }
  .budget-slider-row__header { flex-direction: column; align-items: flex-start; }
}

/* ════════════════════════════════════════════════════════════════════════════
   AUTH SCREEN  (.portal-auth / .portal-auth__*)
   Magic-link login, check-email, access-denied, admin-notice, and loading
   screens — all rendered by portal-auth.js into #portal-root.
════════════════════════════════════════════════════════════════════════════ */

.portal-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 2rem 1rem;
}

.portal-auth__card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 440px;
  text-align: center;
}

.portal-auth__logo {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.portal-auth__title {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
}

.portal-auth__subtitle {
  margin: 0 0 1.25rem;
  font-size: 0.92rem;
  color: #475569;
  line-height: 1.55;
}

.portal-auth__notice {
  border-radius: 7px;
  padding: 0.65rem 0.9rem;
  font-size: 0.88rem;
  margin-bottom: 1rem;
  text-align: left;
}
.portal-auth__notice--info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.portal-auth__notice--warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.portal-auth__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  margin-bottom: 0.6rem;
}

.portal-auth__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.portal-auth__input {
  padding: 0.6rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-size: 0.95rem;
  color: #0f172a;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.portal-auth__input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.portal-auth__error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  text-align: left;
  margin-bottom: 0.6rem;
}

.portal-auth__btn {
  display: block;
  width: 100%;
  padding: 0.65rem 1.25rem;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  margin-bottom: 0.6rem;
}
.portal-auth__btn:hover    { background: #1e293b; }
.portal-auth__btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}
.portal-auth__btn--secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.portal-auth__btn--secondary:hover { background: #e2e8f0; }

.portal-auth__hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* Loading card */
.portal-auth__card--loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 2rem;
}

.portal-auth__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: portal-spin 0.7s linear infinite;
}
@keyframes portal-spin {
  to { transform: rotate(360deg); }
}

.portal-auth__loading-label {
  margin: 0;
  font-size: 0.9rem;
  color: #64748b;
}

@media (max-width: 480px) {
  .portal-auth__card {
    padding: 1.75rem 1.25rem;
  }
}
