/*
  Zoechea Academy portal system
  Shared visual foundation for login, signup, dashboard, and admin pages.
  Matches the homepage paper-grid, serif heading, mono-label, orange/coral system.
*/

:root {
  --stage: #0e0d0c;
  --stage-2: #1a1714;
  --stage-3: #211d18;
  --paper: #f8f0e5;
  --paper-2: #fffaf2;
  --ink: #11100f;
  --muted: #6c6660;
  --soft: #7f7469;
  --line: #ded5c8;
  --accent: #f28b1c;
  --accent-2: #ff6b3d;
  --tile-yellow: #ffe9bf;
  --tile-peach: #ffe1d9;
  --tile-lilac: #f3e6ff;
  --tile-green: #d2eecb;
  --tile-pink: #ffd6f1;
  --glyph-coral: #ff7a52;
  --glyph-gold: #f0b54a;
  --glyph-violet: #b08bf2;
  --glyph-green: #6cba5b;
  --cream-text: #fff7ed;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --site-width: 1360px;
  --radius: 8px;
  --radius-lg: 24px;
  --shadow-paper: 0 22px 54px rgba(26, 23, 20, 0.13);
  --shadow-soft: 0 14px 30px rgba(26, 23, 20, 0.08);
  --grid-light:
    linear-gradient(90deg, rgba(17, 16, 15, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(17, 16, 15, 0.045) 1px, transparent 1px);
  --grid-size: 64px 64px;

  /* Compatibility aliases used by existing PHP inline styles and admin.css. */
  --page: var(--paper-2);
  --panel: var(--paper-2);
  --panel-warm: var(--tile-yellow);
  --line-strong: rgba(242, 139, 28, 0.42);
  --teal: var(--accent);
  --teal-dark: #9b520b;
  --teal-soft: var(--tile-yellow);
  --coral: var(--accent-2);
  --coral-dark: #a63d22;
  --coral-soft: var(--tile-peach);
  --mustard: var(--accent);
  --mustard-soft: var(--tile-yellow);
  --rose: var(--tile-pink);
  --clinical-blue: var(--tile-lilac);
  --clinical-violet: var(--glyph-violet);
  --forest: var(--stage);
  --lake: var(--accent);
  --mint: var(--tile-green);
  --sky: var(--tile-lilac);
  --butter: var(--tile-yellow);
  --honey: var(--accent);
  --clay: var(--accent-2);
  --lavender: var(--tile-lilac);
  --plum: var(--glyph-violet);
  --safe: var(--glyph-green);
  --cream: var(--tile-yellow);
  --card-shadow: var(--shadow-soft);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  padding-top: 8px;
  overflow-x: clip;
  background: var(--grid-light), var(--paper);
  background-size: var(--grid-size);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  font-weight: 560;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--stage-3);
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

body::selection {
  background: var(--tile-yellow);
  color: var(--ink);
}

/* Shared page shells */
.container,
.portal-layout {
  width: min(var(--site-width), calc(100% - 48px));
  margin: 0 auto;
}

.container {
  padding: 0;
}

.portal-layout {
  padding: 40px 0 64px;
}

/* Homepage-style navigation for auth and portal pages */
.nav,
.portal-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248, 240, 229, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 28px rgba(26, 23, 20, 0.06);
}

.nav {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 0 0;
}

.portal-nav-inner {
  width: min(var(--site-width), calc(100% - 48px));
  min-height: 88px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav-brand,
.portal-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 28px;
  font-style: italic;
  line-height: 1;
  white-space: nowrap;
}

.logo,
.portal-nav-logo,
.nav-brand .logo,
.admin-nav-brand .logo {
  width: 44px !important;
  height: 44px !important;
  display: inline-grid !important;
  place-items: center !important;
  flex: 0 0 auto;
  border-radius: 13px !important;
  background: var(--accent) !important;
  color: var(--ink) !important;
  font: 900 22px/1 var(--sans) !important;
}

.nav-links,
.portal-nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-links a,
.portal-nav-links a,
.portal-nav-links span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.78);
  color: var(--ink);
  font: 950 10px/1 var(--mono);
  letter-spacing: 2px;
  text-transform: uppercase;
  box-shadow: 0 1px 0 rgba(255, 253, 248, 0.82) inset;
}

.nav-links a:hover,
.portal-nav-links a:hover,
.portal-nav-links a.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--ink);
}

/* Cards and panels */
.card,
.portal-card,
.portal-stat-card,
.data-table-wrap,
.auth-card {
  border: 1px solid rgba(26, 23, 20, 0.16);
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 242, 0.92);
  box-shadow:
    0 1px 0 rgba(255, 253, 248, 0.82) inset,
    var(--shadow-paper);
}

.card,
.portal-card {
  padding: 28px;
}

.portal-card-sub,
.portal-card-sub-inactive,
.portal-tool-card,
.portal-stat-card,
.card {
  position: relative;
  overflow: hidden;
}

.portal-card-sub::before,
.portal-card-sub-inactive::before,
.portal-stat-card::before,
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  border-top: 4px solid rgba(242, 139, 28, 0.28);
}

.portal-card-sub-inactive::before {
  border-top-color: rgba(255, 107, 61, 0.34);
}

/* Auth pages */
.auth-shell {
  min-height: 100vh;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 520px);
  gap: 28px;
  align-items: stretch;
  margin: 30px 0 56px;
  max-width: 100%;
}

.auth-story {
  min-width: 0;
  max-width: 100%;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px;
  border: 1px solid rgba(26, 23, 20, 0.16);
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 242, 0.84);
  box-shadow:
    0 1px 0 rgba(255, 253, 248, 0.82) inset,
    var(--shadow-paper);
}

.auth-story .eyebrow {
  width: fit-content;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border: 1px solid rgba(242, 139, 28, 0.42);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--stage-3);
  font: 950 10px/1.3 var(--mono);
  letter-spacing: 2.2px;
  text-transform: uppercase;
}

.auth-story .eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
}

.auth-story h1 {
  max-width: 680px;
  margin: 42px 0 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 56px;
  font-style: italic;
  font-weight: 900;
  line-height: 1.1;
}

.auth-story p {
  max-width: 560px;
  margin: 18px 0 0;
  color: var(--stage-3);
  font-size: 16px;
  font-weight: 620;
  line-height: 1.6;
}

.auth-proof-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 34px;
}

.auth-proof-grid div {
  min-height: 112px;
  padding: 18px;
  border: 1px solid rgba(26, 23, 20, 0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.auth-proof-grid div:nth-child(1) {
  background: var(--tile-yellow);
}

.auth-proof-grid div:nth-child(2) {
  background: var(--tile-green);
}

.auth-proof-grid div:nth-child(3) {
  background: var(--tile-lilac);
}

.auth-proof-grid strong {
  display: block;
  color: var(--ink);
  font-size: 20px;
  font-weight: 950;
  line-height: 1.15;
}

.auth-proof-grid span {
  display: block;
  margin-top: 10px;
  color: var(--stage-3);
  font: 950 10px/1.35 var(--mono);
  letter-spacing: 1.7px;
  text-transform: uppercase;
}

.auth-card {
  align-self: center;
  min-width: 0;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 42px;
}

.logo-wrap {
  text-align: center;
  margin-bottom: 22px;
}

.logo-wrap .logo {
  width: 56px !important;
  height: 56px !important;
  font-size: 24px !important;
}

.auth-card h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 48px;
  font-style: italic;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}

.auth-card .sub {
  max-width: 360px;
  margin: 12px auto 28px;
  color: var(--stage-3);
  font-size: 16px;
  font-weight: 620;
  line-height: 1.6;
  text-align: center;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.form-label,
.portal-eyebrow {
  color: var(--stage-3);
  font: 950 10px/1.25 var(--mono);
  letter-spacing: 2.2px;
  text-transform: uppercase;
}

.portal-eyebrow {
  margin: 0 0 10px;
}

.form-input,
.search-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  font: 650 16px/1.3 var(--sans);
  box-shadow: 0 1px 0 rgba(255, 253, 248, 0.82) inset;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.search-input:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 4px rgba(242, 139, 28, 0.14);
}

/* Buttons */
.btn-pill,
.portal-btn,
.search-btn,
.action-btn {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 24px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font: 900 15px/1 var(--sans);
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn-pill:hover,
.portal-btn:hover,
.search-btn:hover,
.action-btn:hover {
  transform: translateY(-1px);
  color: var(--ink);
}

.btn-pill-full {
  width: 100%;
}

.portal-btn-fill,
.action-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}

.portal-btn-line,
.portal-btn-sm {
  background: rgba(255, 250, 242, 0.78);
  border-color: var(--line);
  color: var(--ink);
}

.portal-btn-line:hover,
.portal-btn-sm:hover {
  border-color: var(--accent);
  background: var(--accent);
}

.portal-btn-sm,
.action-btn {
  min-height: 36px;
  padding: 0 16px;
  font-size: 13px;
}

/* Badges and alerts */
.portal-badge,
.badge,
.badge-dmit {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 11px;
  border: 1px solid rgba(26, 23, 20, 0.08);
  border-radius: 999px;
  background: var(--tile-yellow);
  color: var(--ink);
  font: 950 10px/1 var(--mono);
  letter-spacing: 1.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.portal-badge-active,
.badge-active,
.badge-dmit.yes {
  background: var(--tile-green);
}

.portal-badge-inactive,
.badge-expired,
.badge-dmit.no {
  background: var(--tile-peach);
}

.portal-badge-tier {
  background: var(--tile-lilac);
}

.alert,
.portal-flash {
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--tile-yellow);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
}

.alert-error,
.portal-flash-error {
  background: var(--tile-peach);
  border-color: rgba(255, 107, 61, 0.3);
}

.alert-success,
.portal-flash-success {
  background: var(--tile-green);
}

.alert-info,
.portal-flash-info {
  background: var(--tile-lilac);
}

/* Dashboard */
.portal-dashboard {
  display: block;
}

.portal-dashboard > * {
  min-width: 0;
}

.portal-dashboard .portal-card-sub,
.portal-dashboard .portal-card-sub-inactive,
.portal-dashboard .tool-section,
.portal-dashboard .portal-footer {
  width: 100%;
}

.portal-hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 28px;
  padding: 34px;
  border: 1px solid rgba(26, 23, 20, 0.16);
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 242, 0.88);
  box-shadow:
    0 1px 0 rgba(255, 253, 248, 0.82) inset,
    var(--shadow-paper);
}

.portal-hero-copy h1 {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 48px;
  font-style: italic;
  font-weight: 900;
  line-height: 1.2;
}

.portal-hero-copy p:not(.portal-eyebrow) {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--stage-3);
  font-size: 16px;
  font-weight: 620;
  line-height: 1.6;
}

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

.portal-mini-tile {
  min-height: 96px;
  padding: 18px;
  border: 1px solid rgba(26, 23, 20, 0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.portal-mini-tile:nth-child(1) {
  background: var(--tile-yellow);
}

.portal-mini-tile:nth-child(2) {
  background: var(--tile-green);
}

.portal-mini-tile:nth-child(3) {
  background: var(--tile-lilac);
}

.portal-mini-tile strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
  font-weight: 950;
  line-height: 1.15;
}

.portal-mini-tile span {
  display: block;
  margin-top: 10px;
  color: var(--stage-3);
  font: 950 10px/1.35 var(--mono);
  letter-spacing: 1.7px;
  text-transform: uppercase;
}

.portal-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.portal-stat-card {
  min-height: 118px;
  padding: 22px;
}

.portal-stat-value,
.stat-card .value {
  color: var(--ink) !important;
  font-family: var(--serif);
  font-size: 38px;
  font-style: italic;
  font-weight: 900;
  line-height: 1;
}

.portal-stat-label,
.stat-card .label {
  margin-top: 10px;
  color: var(--stage-3);
  font: 950 10px/1.25 var(--mono);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.portal-section-title {
  margin: 0 0 20px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 34px;
  font-style: italic;
  font-weight: 900;
  line-height: 1.1;
}

.tool-section {
  margin-bottom: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.tool-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.portal-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 18px;
  align-items: stretch;
  justify-content: stretch;
  margin-bottom: 28px;
}

.portal-dashboard .portal-tools-grid:has(> .portal-tool-card:only-child) {
  grid-template-columns: minmax(min(100%, 300px), 420px);
  justify-content: start;
}

.portal-tool-card {
  border: 1px solid rgba(26, 23, 20, 0.16);
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 242, 0.92);
  box-shadow: 0 1px 0 rgba(255, 253, 248, 0.82) inset, var(--shadow-paper);
  padding: 24px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.portal-tool-card > .portal-btn {
  margin-top: auto;
  align-self: flex-start;
}

.portal-tool-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.portal-tool-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--stage) !important;
  color: var(--paper-2) !important;
  font-weight: 900;
}

.portal-tool-title {
  color: var(--ink);
  font-size: 21px;
  font-weight: 950;
}

.portal-tool-sub {
  margin-top: 4px;
  color: var(--stage-3);
  font: 950 10px/1.4 var(--mono);
  letter-spacing: 1.6px;
  text-transform: uppercase;
}

.portal-tool-desc {
  margin: 14px 0 18px;
  color: var(--stage-3);
  font-size: 16px;
  font-weight: 620;
  line-height: 1.6;
}

.portal-footer,
.footer-note {
  margin: 28px 0 0;
  padding-top: 22px;
  border-top: 1px solid rgba(26, 23, 20, 0.1);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  font-weight: 620;
}

.footer-note {
  border-top: 0;
  padding-top: 0;
}

.portal-footer p {
  margin: 8px 0 0;
}

/* Tables shared with admin.css */
.data-table-wrap {
  overflow-x: auto;
  background: var(--paper-2);
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 15px;
}

.data-table th,
.data-table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table thead th,
.data-table th {
  background: var(--stage);
  color: var(--paper-2);
  font: 950 10px/1 var(--mono);
  letter-spacing: 1.8px;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tbody tr:nth-child(odd) {
  background: var(--tile-yellow);
}

.data-table tbody tr:nth-child(even) {
  background: var(--paper-2);
}

.data-table td strong {
  color: var(--ink);
  font-weight: 900;
}

.data-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

/* PHQ-9 free-tier tool */
.phq9-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.phq9-page-head h1 {
  margin: 6px 0 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 46px;
  font-style: italic;
  font-weight: 900;
  line-height: 1.08;
}

.phq9-page-head p:not(.portal-eyebrow) {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--stage-3);
  font-size: 16px;
  font-weight: 620;
}

.phq9-error-list {
  margin: 8px 0 0;
  padding-left: 20px;
}

.phq9-tabs {
  display: inline-flex;
  gap: 5px;
  margin: 0 0 22px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.78);
}

.phq9-tabs a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--ink);
  font: 950 10px/1 var(--mono);
  letter-spacing: 1.6px;
  text-transform: uppercase;
}

.phq9-tabs a.active,
.phq9-tabs a:hover {
  background: var(--accent);
  color: var(--ink);
}

.phq9-flow {
  display: grid;
  gap: 16px;
}

.phq9-step-card {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 26px;
}

.phq9-step-card[hidden] {
  display: none !important;
}

.phq9-step-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.phq9-step-kicker span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--stage);
  color: var(--paper-2);
  font: 950 10px/1 var(--mono);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.phq9-step-card .phq9-question {
  padding: 0;
  border: 0;
}

.phq9-flow-controls {
  max-width: 980px;
  width: 100%;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 auto;
}

.phq9-flow-controls .portal-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.phq9-review-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
}

.phq9-review-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  font-weight: 950;
  line-height: 1.2;
}

.phq9-score-meaning,
.phq9-answer-table,
.phq9-answer-summary,
.phq9-report-note {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(26, 23, 20, 0.12);
}

.phq9-score-meaning h3,
.phq9-answer-table h3 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 950;
}

.phq9-meaning-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.phq9-meaning-card {
  min-height: 138px;
  padding: 14px;
  border: 1px solid rgba(26, 23, 20, 0.12);
  border-radius: var(--radius);
  background: var(--paper-2);
}

.phq9-meaning-card.active {
  border-color: var(--accent);
  background: var(--tile-yellow);
  box-shadow: 0 0 0 3px rgba(242, 139, 28, 0.13);
}

.phq9-meaning-card strong,
.phq9-meaning-card span {
  display: block;
}

.phq9-meaning-card strong {
  color: var(--ink);
  font: 950 11px/1 var(--mono);
  letter-spacing: 1.5px;
}

.phq9-meaning-card span {
  margin-top: 8px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 950;
}

.phq9-meaning-card p,
.phq9-report-note p {
  margin: 8px 0 0;
  color: var(--stage-3);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
}

.phq9-answer-summary {
  display: grid;
  gap: 8px;
}

.phq9-answer-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(140px, auto);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid rgba(26, 23, 20, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 250, 242, 0.72);
}

.phq9-answer-row strong {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(17, 16, 15, 0.08);
  font: 950 11px/1 var(--mono);
}

.phq9-answer-row span {
  color: var(--ink);
  font-weight: 760;
  line-height: 1.35;
}

.phq9-answer-row em {
  color: var(--stage-3);
  font-style: normal;
  font-weight: 850;
  text-align: right;
}

.phq9-report-detail {
  max-width: 1120px;
  margin: 0 auto;
}

.phq9-result-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  border-top: 4px solid var(--glyph-green);
}

.phq9-result-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 950;
}

.phq9-result-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.phq9-result-score {
  min-width: 150px;
  padding: 14px 16px;
  border: 1px solid rgba(26, 23, 20, 0.12);
  border-radius: var(--radius);
  background: var(--tile-green);
  text-align: center;
}

.phq9-result-score strong {
  display: block;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 44px;
  font-style: italic;
  font-weight: 900;
  line-height: 0.95;
}

.phq9-result-score strong span {
  font-family: var(--sans);
  font-size: 18px;
  font-style: normal;
}

.phq9-result-score p {
  margin: 8px 0 0;
  color: var(--stage-3);
  font: 950 10px/1.35 var(--mono);
  letter-spacing: 1.7px;
  text-transform: uppercase;
}

.phq9-item9-alert {
  grid-column: 1 / -1;
  padding: 13px 16px;
  border: 1px solid rgba(255, 107, 61, 0.3);
  border-radius: var(--radius);
  background: var(--tile-peach);
  color: var(--ink);
  font-weight: 850;
}

.phq9-form-card {
  padding: 30px;
}

.phq9-form-section + .phq9-form-section {
  margin-top: 30px;
  padding-top: 28px;
  border-top: 1px solid rgba(26, 23, 20, 0.12);
}

.phq9-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.phq9-section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 950;
  line-height: 1.2;
}

.phq9-score-strip {
  min-width: 210px;
  padding: 13px 16px;
  border: 1px solid rgba(26, 23, 20, 0.12);
  border-radius: var(--radius);
  background: var(--tile-yellow);
}

.phq9-score-strip span,
.phq9-score-strip em {
  display: block;
  color: var(--stage-3);
  font: 950 10px/1.35 var(--mono);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.phq9-score-strip strong {
  display: block;
  margin: 5px 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 34px;
  font-style: italic;
  font-weight: 900;
  line-height: 1;
}

.phq9-score-strip em {
  font-style: normal;
}

.phq9-client-mode {
  width: fit-content;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.78);
}

.phq9-client-mode label {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.phq9-client-mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.phq9-client-mode span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--ink);
  font: 950 10px/1 var(--mono);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.phq9-client-mode input:checked + span {
  background: var(--accent);
}

.phq9-client-mode input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.phq9-client-mode input:disabled + span {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.phq9-client-grid {
  margin-top: 18px;
}

.phq9-new-client {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 0.8fr);
  gap: 16px;
}

.phq9-existing-client[hidden],
.phq9-new-client[hidden] {
  display: none !important;
}

.phq9-question-list {
  border-top: 1px solid rgba(26, 23, 20, 0.12);
}

.phq9-question-list.phq9-wizard-ready {
  border-top: 0;
}

.phq9-question {
  min-width: 0;
  margin: 0;
  padding: 22px 0;
  border: 0;
  border-bottom: 1px solid rgba(26, 23, 20, 0.12);
}

.phq9-question[hidden] {
  display: none !important;
}

.phq9-question-list.phq9-wizard-ready .phq9-question {
  min-height: 0;
  padding: var(--phq9-card-padding, 22px);
  border: 1px solid rgba(26, 23, 20, 0.16);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.94);
  box-shadow:
    0 1px 0 rgba(255, 253, 248, 0.82) inset,
    var(--shadow-soft);
}

.phq9-question-card-compact {
  --phq9-card-padding: 22px;
}

.phq9-question legend {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.4;
}

.phq9-question legend > span:first-child {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--stage);
  color: var(--paper-2);
  font: 950 11px/1 var(--mono);
}

.phq9-field-error {
  margin: 10px 0 0 40px;
  color: var(--coral-dark);
  font-size: 13px;
  font-weight: 850;
}

.phq9-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.phq9-question-list.phq9-wizard-ready .phq9-options {
  margin-top: 18px;
}

.phq9-option {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 780;
  line-height: 1.25;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 253, 248, 0.82) inset;
}

.phq9-question-list.phq9-wizard-ready .phq9-option {
  min-height: 46px;
  padding: 9px 12px;
}

.phq9-option:hover {
  border-color: rgba(242, 139, 28, 0.58);
}

.phq9-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--tile-yellow);
}

.phq9-option input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.phq9-option-value {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(17, 16, 15, 0.08);
  font: 950 11px/1 var(--mono);
}

.phq9-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 26px;
}

.phq9-wizard-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
}

.phq9-wizard-controls[hidden] {
  display: none !important;
}

.phq9-wizard-status {
  min-width: 0;
}

.phq9-wizard-status span {
  display: block;
  color: var(--stage-3);
  font: 950 10px/1.35 var(--mono);
  letter-spacing: 1.7px;
  text-transform: uppercase;
}

.phq9-wizard-status strong {
  display: block;
  max-width: 620px;
  margin-top: 5px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.45;
}

.phq9-wizard-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.phq9-wizard-actions .portal-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.phq9-history {
  margin-top: 28px;
}

.phq9-history .phq9-section-head {
  margin-bottom: 12px;
}

.phq9-history-table {
  min-width: 560px;
}

.phq9-empty-history {
  padding: 18px 0 0;
  border-top: 1px solid rgba(26, 23, 20, 0.12);
}

.phq9-empty-history p:not(.portal-eyebrow) {
  margin: 6px 0 0;
  color: var(--stage-3);
  font-weight: 680;
}

@media (max-width: 980px) {
  .nav,
  .portal-nav-inner {
    width: min(var(--site-width), calc(100% - 36px));
  }

  .portal-nav-inner,
  .nav {
    min-height: 80px;
  }

  .portal-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-hero-panel {
    grid-template-columns: 1fr;
  }

  .phq9-new-client {
    grid-template-columns: 1fr 1fr;
  }

  .phq9-meaning-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .phq9-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-story {
    min-height: 0;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 15.5px;
  }

  .container,
  .portal-layout,
  .portal-nav-inner,
  .nav {
    width: calc(100% - 24px);
  }

  .nav,
  .portal-nav-inner {
    align-items: stretch;
    flex-direction: column;
    min-height: 80px;
    padding: 14px 0;
  }

  .nav-brand,
  .portal-nav-brand {
    font-size: 20px;
    white-space: normal;
  }

  .logo,
  .portal-nav-logo,
  .nav-brand .logo,
  .admin-nav-brand .logo {
    width: 38px !important;
    height: 38px !important;
    border-radius: 11px !important;
    font-size: 18px !important;
  }

  .nav-links,
  .portal-nav-links {
    width: 100%;
    gap: 7px;
    justify-content: flex-start;
  }

  .nav-links a,
  .portal-nav-links a,
  .portal-nav-links span {
    min-width: 0;
    min-height: 32px;
    padding: 0 12px;
    font-size: 9px;
    letter-spacing: 1.4px;
  }

  .auth-story p,
  .portal-hero-copy p,
  .portal-card p,
  .portal-tool-desc {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .portal-layout {
    padding: 28px 0 52px;
  }

  .auth-card {
    margin: 26px auto;
    padding: 28px 22px;
    border-radius: 20px;
  }

  .auth-layout {
    width: 100%;
    max-width: 100%;
    margin: 18px 0 40px;
    gap: 14px;
  }

  .auth-story {
    width: 100%;
    padding: 28px 22px;
    border-radius: 20px;
  }

  .auth-story h1 {
    max-width: 100%;
    margin-top: 28px;
    font-size: 30px;
    overflow-wrap: break-word;
  }

  .auth-proof-grid {
    grid-template-columns: 1fr;
  }

  .auth-card h2 {
    font-size: 34px;
  }

  .auth-card .sub,
  .portal-tool-desc {
    font-size: 15.5px;
  }

  .portal-stat-grid {
    grid-template-columns: 1fr;
  }

  .portal-tools-grid {
    grid-template-columns: 1fr;
  }

  .card,
  .portal-card,
  .portal-stat-card,
  .portal-tool-card {
    padding: 22px;
    border-radius: 18px;
  }

  .portal-section-title {
    font-size: 28px;
  }

  .portal-hero-panel {
    padding: 24px 22px;
    border-radius: 20px;
  }

  .portal-hero-copy h1 {
    font-size: 28px;
  }

  .phq9-page-head,
  .phq9-section-head,
  .phq9-result-card {
    display: grid;
    grid-template-columns: 1fr;
  }

  .phq9-page-head {
    align-items: start;
  }

  .phq9-page-head h1 {
    font-size: 32px;
  }

  .phq9-form-card {
    padding: 22px;
  }

  .phq9-tabs,
  .phq9-flow-controls {
    width: 100%;
  }

  .phq9-tabs {
    display: grid;
    grid-template-columns: 1fr;
    border-radius: 18px;
  }

  .phq9-tabs a {
    width: 100%;
  }

  .phq9-step-card {
    padding: 22px;
    border-radius: 18px;
  }

  .phq9-flow-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .phq9-flow-controls .portal-btn {
    width: 100%;
  }

  .phq9-review-head {
    grid-template-columns: 1fr;
  }

  .phq9-meaning-grid,
  .phq9-answer-row {
    grid-template-columns: 1fr;
  }

  .phq9-answer-row em {
    text-align: left;
  }

  .phq9-score-strip {
    width: 100%;
    min-width: 0;
  }

  .phq9-client-mode {
    width: 100%;
  }

  .phq9-client-mode label,
  .phq9-client-mode span {
    flex: 1 1 0;
  }

  .phq9-new-client,
  .phq9-options {
    grid-template-columns: 1fr;
  }

  .phq9-question legend {
    font-size: 16px;
  }

  .phq9-field-error {
    margin-left: 0;
  }

  .phq9-wizard-controls,
  .phq9-wizard-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .phq9-wizard-actions {
    width: 100%;
  }

  .phq9-wizard-actions .portal-btn {
    width: 100%;
  }

  .phq9-form-actions {
    justify-content: stretch;
  }

  .phq9-form-actions .portal-btn {
    width: 100%;
  }

  .portal-stat-value,
  .stat-card .value {
    font-size: 32px;
  }
}

/* Compatibility classes used by checkout/success pages */
.nav-logo {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 13px;
  background: var(--accent);
  color: var(--ink);
  font: 900 22px/1 var(--sans);
}

.nav-name {
  font: italic 400 25px/1 var(--serif);
}

.btn,
.btn-fill {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 24px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font: 900 15px/1 var(--sans);
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:hover,
.btn-fill:hover {
  transform: translateY(-1px);
  color: var(--ink);
}

.site-footer {
  width: 100%;
  padding: 64px max(24px, calc((100vw - var(--site-width)) / 2)) 28px;
  border-top: 1px solid var(--line);
  background: var(--grid-light), var(--paper);
  background-size: var(--grid-size);
  color: var(--ink);
}

.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 40px;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 16px;
}

.footer-col h2 {
  margin: 0 0 14px;
  color: var(--muted);
  font: 900 10px/1 var(--mono);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.footer-col a {
  display: block;
  margin-top: 9px;
  color: var(--stage-3);
  font-weight: 700;
}

.footer-col a:hover {
  color: var(--accent);
}

.footer-bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 54px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .footer-links {
    width: 100%;
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
