body.portal-centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--brand);
  padding: var(--space-8);
}

.card {
  background: var(--card-bone);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  padding: var(--space-16) var(--space-12);
  max-width: 420px;
  width: 100%;
}

.card h1 { text-align: center; font-size: 1.75rem; margin-bottom: var(--space-8); }
.card h1 em { color: var(--accent); font-style: italic; }

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack[hidden] { display: none; }
.stack label { display: flex; flex-direction: column; gap: var(--space-1); font-size: 0.9rem; color: var(--muted); }
.stack input {
  font: inherit;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}
.stack input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.stack button {
  font: inherit;
  font-weight: 600;
  padding: var(--space-3) var(--space-4);
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--brand-deep);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.stack button:hover { background: var(--accent-hover); }
.stack button:active { transform: scale(0.98); }

.error { color: #b3261e; font-size: 0.9rem; margin: 0; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0; text-align: center; }

.dashboard-status {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.dashboard-status.active { background: #dff0d8; color: #2f6b2f; }
.dashboard-status.past_due { background: #fbe8c8; color: #8a5a12; }
.dashboard-status.suspended { background: #f7d3d3; color: #a12727; }
.dashboard-status.pending_payment { background: #e4e0f5; color: #4b3d8f; }

/* App shell — dashboard, stats, roadmap, reports (wider than the auth pages' centered card) */
body.app-shell { background: var(--bg); min-height: 100vh; }

.app-header {
  background: var(--brand);
  padding: var(--space-4) var(--space-8);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-4);
}
.app-header .brand-mark {
  font-family: 'Fraunces', serif;
  color: var(--on-brand);
  font-size: 1.1rem;
  white-space: nowrap;
}
.app-header .brand-mark em { color: var(--accent); font-style: italic; }

.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-4); flex-wrap: wrap; }

.header-verse {
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-size: 0.7rem;
  line-height: 1.3;
  color: var(--on-brand);
  opacity: 0.65;
  max-width: 32em;
}
.header-verse cite {
  font-style: normal;
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 1;
  margin-left: var(--space-2);
}

@media (max-width: 720px) {
  .app-header { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .header-verse { max-width: none; }
  .header-actions { justify-content: center; }
}

#portal-nav { display: flex; gap: var(--space-2); flex-wrap: wrap; }
#portal-nav a {
  color: var(--on-brand);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: var(--space-3);
  border-radius: 999px;
  transition: background var(--dur-fast) var(--ease);
  display: inline-flex;
  align-items: center;
}
#portal-nav a:hover { background: var(--highlight-ondark); }
#portal-nav a.active { background: var(--accent); color: var(--brand-deep); }

.app-header form { margin: 0; }
.app-header button {
  font: inherit;
  font-size: 0.85rem;
  padding: var(--space-3);
  border: 1px solid var(--border-ondark);
  border-radius: 999px;
  background: transparent;
  color: var(--on-brand);
  cursor: pointer;
}
.app-header button:hover { background: var(--highlight-ondark); }

.app-content {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.app-content h1 { font-size: 1.5rem; }
.app-content h1 em { color: var(--accent); font-style: italic; }

.panel {
  background: var(--card-bone);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--space-6);
}
.panel h2 { font-size: 1.1rem; margin: 0 0 var(--space-4); }

.stat-row { display: flex; gap: var(--space-6); flex-wrap: wrap; }
.stat-tile { min-width: 140px; }
.stat-tile .value { font-family: 'Fraunces', serif; font-size: 2rem; color: var(--ink); line-height: 1; }
.stat-tile .label { color: var(--muted); font-size: 0.85rem; margin-top: var(--space-1); }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
}
.data-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); }
.data-table tr:last-child td { border-bottom: none; }

.status-pill {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-pill.live { background: #dff0d8; color: #2f6b2f; }
.status-pill.planned { background: #ece9e0; color: var(--muted); }

.empty-state { color: var(--muted); font-size: 0.95rem; }
.error-state { color: #b3261e; font-size: 0.95rem; }

/* Admin page — tabs, badges, small buttons, inline edit rows */
.actions-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  min-width: 90px;
}

.role-badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: var(--bg-alt);
  color: var(--muted);
}
.role-badge.admin { background: var(--accent); color: var(--brand-deep); }

.btn-sm {
  /* Under the 44px touch-target guideline even at this padding (deliberate
     exception: 3 stacked actions per admin table row — full 44px would
     roughly triple row height in a dense, desktop/mouse-driven internal
     view). Bumped from the original 4px for partial improvement. */
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.btn-sm:hover { background: var(--bg-alt); }
.btn-sm.danger { border-color: #e2b3b3; color: #a12727; }
.btn-sm.danger:hover { background: #fbe9e9; }
.btn-sm.primary { background: var(--accent); border-color: var(--accent); color: var(--brand-deep); }
.btn-sm.primary:hover { background: var(--accent-hover); }

.tabs { display: flex; gap: var(--space-2); border-bottom: 1px solid var(--line); margin-bottom: var(--space-4); }
.tabs[hidden] { display: none; }
.tabs button {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); }
.field-grid label { display: flex; flex-direction: column; gap: var(--space-1); font-size: 0.85rem; color: var(--muted); }
.field-grid input, .field-grid select {
  font: inherit;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}

.feature-toggles { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.feature-toggles label { display: flex; align-items: center; gap: 4px; font-size: 0.85rem; color: var(--body); }

.edit-row { background: var(--bg-alt); }
.edit-row td { padding: var(--space-4) var(--space-3); }

/* Footer — legal links, present on every page */
.portal-footer {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  font-size: 0.8rem;
  color: var(--muted);
}
.portal-footer a { color: var(--muted); text-decoration: underline; }
.portal-footer a:hover { color: var(--brand-soft); }
.portal-footer .sep { margin: 0 var(--space-2); opacity: 0.5; }

/* On the auth pages (login/setup), the card is centered in a flex row —
   pin the footer to the viewport bottom instead of disrupting that layout */
body.portal-centered .portal-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  color: var(--on-brand);
  opacity: 0.7;
}
body.portal-centered .portal-footer a { color: var(--on-brand); }

/* Legal pages — simple prose, reusing the .panel card look */
.legal-content { max-width: 720px; margin: 0 auto; }
.legal-content h2 { font-size: 1.15rem; margin-top: var(--space-8); }
.legal-content p, .legal-content li { color: var(--body); line-height: 1.65; }
.legal-content .effective-date { color: var(--muted); font-style: italic; margin-top: calc(-1 * var(--space-2)); }
