/* ==========================================================================
   PsychMedWA Design System
   Calm, trustworthy, professional medical aesthetic.
   Tokens first; components below. Used by every patient and admin page.
   ========================================================================== */

:root {
  /* Colour tokens */
  --c-primary: #33635c;        /* deep calm teal-green */
  --c-primary-dark: #264d47;
  --c-primary-soft: #e7f0ee;   /* washed teal for tints            */
  --c-primary-softer: #f2f7f6;
  --c-accent: #b5835a;         /* warm sand accent                 */
  --c-accent-soft: #f6efe7;
  --c-bg: #faf9f7;             /* warm off-white page background   */
  --c-surface: #ffffff;
  --c-ink: #23312f;            /* near-black green ink             */
  --c-ink-soft: #5b6b68;
  --c-ink-faint: #8a9996;
  --c-border: #e3e8e6;
  --c-danger: #b3261e;
  --c-danger-soft: #fceeed;
  --c-warn: #9a6b00;
  --c-warn-soft: #fdf3dd;
  --c-success: #2e7d5b;
  --c-success-soft: #e8f3ee;
  --c-info: #2b5f8a;
  --c-info-soft: #e9f1f7;

  /* Typography */
  --font-head: 'Lora', Georgia, serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --fs-xs: 0.78rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2.25rem;
  --fs-3xl: 2.9rem;

  /* Spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px; --sp-9: 96px;

  /* Shape + elevation */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(35, 49, 47, 0.08);
  --shadow: 0 4px 14px rgba(35, 49, 47, 0.08);
  --shadow-lg: 0 12px 32px rgba(35, 49, 47, 0.14);
  --focus-ring: 0 0 0 3px rgba(51, 99, 92, 0.35);
}

/* ------------------------------------------------------------------ reset */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--c-ink); line-height: 1.25; margin: 0 0 var(--sp-4); font-weight: 600; }
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); }
p  { margin: 0 0 var(--sp-4); }
a  { color: var(--c-primary); }
a:hover { color: var(--c-primary-dark); }

/* Accessible focus states everywhere */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 2000;
  background: var(--c-primary); color: #fff; padding: var(--sp-3) var(--sp-4);
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* -------------------------------------------------------------- layout */
.container { max-width: 1080px; margin: 0 auto; padding: 0 var(--sp-5); }
.container--narrow { max-width: 760px; }
.section { padding: var(--sp-8) 0; }
.section--tint { background: var(--c-primary-softer); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); }
@media (max-width: 840px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  h1 { font-size: var(--fs-2xl); }
  h2 { font-size: var(--fs-xl); }
}

/* ---------------------------------------------------------------- header */
.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 100;
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); min-height: 68px;
}
.brand { display: flex; align-items: center; gap: var(--sp-3); text-decoration: none; }
.brand__mark {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--c-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-size: 20px; font-weight: 700;
  flex-shrink: 0;
}

/* When /assets/img/logo.png exists, the letter mark is replaced by the logo's
   head-and-tree symbol. The supplied artwork is a square lockup (symbol above
   the wordmark), so it is scaled and offset to show just the symbol — the
   practice name stays as live text beside it, which keeps it crisp at any size
   and readable to screen readers and search engines.
   Tweak background-size / background-position if the crop needs nudging. */
.brand__mark--logo {
  background-color: transparent;
  background-repeat: no-repeat;
  background-size: 250% auto;   /* full square lockup: zoom in on the symbol */
  background-position: 50% 30%;
  color: transparent;
  width: 46px; height: 46px;
  border-radius: 0;
}
/* logo-mark.png is already just the symbol, so show it whole. */
.brand__mark--fit { background-size: contain; background-position: center; }

/* The symbol has a transparent background, so it sits happily on the dark
   sidebar without needing a white tile behind it. */
.admin-side .brand__mark--logo { background-color: transparent; }
.admin-side .brand__mark--logo:not(.brand__mark--fit) { background-color: #fff; border-radius: var(--radius-sm); }
.brand__name { font-family: var(--font-head); font-weight: 600; font-size: var(--fs-md); color: var(--c-ink); }
.brand__tag { display: block; font-family: var(--font-body); font-size: var(--fs-xs); color: var(--c-ink-soft); letter-spacing: 0.06em; text-transform: uppercase; }

.site-nav { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.site-nav a {
  text-decoration: none; color: var(--c-ink-soft); font-size: var(--fs-sm); font-weight: 500;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm);
}
.site-nav a:hover { color: var(--c-primary-dark); background: var(--c-primary-softer); }
.site-nav a[aria-current="page"] { color: var(--c-primary-dark); background: var(--c-primary-soft); }
/* Doctor's entry point. Deliberately understated so patients don't mistake
   it for something meant for them, but always visible in the header. */
.site-nav .nav-login {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: var(--sp-3); padding: 7px 14px;
  border: 1px solid var(--c-border); border-radius: var(--radius-pill);
  color: var(--c-ink-soft); font-size: var(--fs-xs); font-weight: 600;
  white-space: nowrap;
}
.site-nav .nav-login .material-icons { font-size: 15px; }
.site-nav .nav-login:hover {
  border-color: var(--c-primary); color: var(--c-primary-dark); background: var(--c-primary-softer);
}

.nav-toggle {
  display: none; background: none; border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  padding: var(--sp-2); cursor: pointer; color: var(--c-ink);
}
@media (max-width: 920px) {
  .nav-toggle { display: inline-flex; align-items: center; }
  .site-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--c-surface); border-bottom: 1px solid var(--c-border);
    flex-direction: column; align-items: stretch; padding: var(--sp-3) var(--sp-5) var(--sp-5);
    box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: flex; }
  .site-nav a { padding: var(--sp-3); }
  .site-nav .nav-login {
    margin: var(--sp-3) 0 0; justify-content: center;
    border-top: 1px solid var(--c-border); border-radius: var(--radius-pill);
    padding: var(--sp-3);
  }
}

/* ---------------------------------------------------------------- footer */
.site-footer {
  background: var(--c-primary-dark); color: #d9e5e2;
  padding: var(--sp-7) 0 var(--sp-5); margin-top: var(--sp-8);
  font-size: var(--fs-sm);
}
.site-footer a { color: #fff; }
.site-footer h3 { color: #fff; font-size: var(--fs-base); }
.site-footer__grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--sp-6); margin-bottom: var(--sp-6); }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: var(--sp-2); }
.site-footer__legal { border-top: 1px solid rgba(255,255,255,0.15); padding-top: var(--sp-4); color: #b8cbc7; font-size: var(--fs-xs); }
@media (max-width: 840px) { .site-footer__grid { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font-family: var(--font-body); font-weight: 600; font-size: var(--fs-sm);
  border: 1px solid transparent; border-radius: var(--radius-pill);
  padding: 12px 26px; cursor: pointer; text-decoration: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
  min-height: 44px; /* touch target */
}
.btn--primary { background: var(--c-primary); color: #fff; }
.btn--primary:hover { background: var(--c-primary-dark); color: #fff; box-shadow: var(--shadow); }
.btn--secondary { background: var(--c-surface); color: var(--c-primary-dark); border-color: var(--c-primary); }
.btn--secondary:hover { background: var(--c-primary-softer); }
.btn--ghost { background: transparent; color: var(--c-primary-dark); }
.btn--ghost:hover { background: var(--c-primary-softer); }
.btn--danger { background: var(--c-danger); color: #fff; }
.btn--danger:hover { background: #8f1d17; color: #fff; }
.btn--sm { padding: 7px 16px; min-height: 36px; font-size: var(--fs-xs); }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn .material-icons { font-size: 19px; }

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: var(--sp-6);
}
.card--flat { box-shadow: none; }
.card--feature { border-top: 4px solid var(--c-primary); }
.card h3 { display: flex; align-items: center; gap: var(--sp-2); }
.card h3 .material-icons { color: var(--c-primary); }

/* ----------------------------------------------------------------- forms */
.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-weight: 600; font-size: var(--fs-sm); margin-bottom: var(--sp-2); color: var(--c-ink); }
.field .hint { font-size: var(--fs-xs); color: var(--c-ink-soft); margin-top: var(--sp-1); }
.input, textarea.input, select.input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: var(--fs-base); color: var(--c-ink);
  background: var(--c-surface);
  transition: border-color 0.15s ease;
}
.input:focus { border-color: var(--c-primary); }
textarea.input { resize: vertical; min-height: 110px; }
.checkbox-row { display: flex; align-items: flex-start; gap: var(--sp-3); font-size: var(--fs-sm); }
.checkbox-row input[type="checkbox"], .checkbox-row input[type="radio"] { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--c-primary); flex-shrink: 0; }

/* ----------------------------------------------------------- alerts/badges */
.notice { border-radius: var(--radius-sm); padding: var(--sp-4); font-size: var(--fs-sm); border: 1px solid; margin-bottom: var(--sp-4); }
.notice--info    { background: var(--c-info-soft);    border-color: #c4d9e8; color: var(--c-info); }
.notice--warn    { background: var(--c-warn-soft);    border-color: #ecd9a8; color: var(--c-warn); }
.notice--danger  { background: var(--c-danger-soft);  border-color: #eac6c3; color: var(--c-danger); }
.notice--success { background: var(--c-success-soft); border-color: #bcdccd; color: var(--c-success); }

.badge {
  display: inline-block; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--c-primary-soft); color: var(--c-primary-dark);
}
.badge--accent { background: var(--c-accent-soft); color: #8a5f37; }
.badge--danger { background: var(--c-danger-soft); color: var(--c-danger); }
.badge--success { background: var(--c-success-soft); color: var(--c-success); }

/* ------------------------------------------------------------------ hero */
.hero { background: linear-gradient(160deg, var(--c-primary-softer) 0%, var(--c-bg) 60%); padding: var(--sp-8) 0; }
.hero__grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: var(--sp-8); align-items: center; }
.hero__eyebrow { color: var(--c-accent); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; font-size: var(--fs-xs); margin-bottom: var(--sp-3); }
.hero h1 { max-width: 17ch; }
.hero__lede { font-size: var(--fs-md); color: var(--c-ink-soft); max-width: 54ch; margin-bottom: var(--sp-6); }
.hero__actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.hero__trust { display: flex; gap: var(--sp-5); margin-top: var(--sp-6); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--c-ink-soft); }
.hero__trust div { display: flex; align-items: center; gap: var(--sp-2); }
.hero__trust .material-icons { color: var(--c-primary); font-size: 20px; }

/* Portrait frame — sits behind the image and shows through while it's a placeholder */
.portrait {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
  aspect-ratio: 4 / 5; background: var(--c-primary-soft); box-shadow: var(--shadow-lg);
}
.portrait::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 1px rgba(35, 49, 47, 0.08);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait--wide { aspect-ratio: 3 / 2; }
.portrait__caption {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  background: linear-gradient(to top, rgba(35,49,47,0.82), rgba(35,49,47,0));
  color: #fff; padding: var(--sp-6) var(--sp-4) var(--sp-4); font-size: var(--fs-sm);
}
.portrait__caption strong { display: block; font-family: var(--font-head); font-size: var(--fs-md); }

/* Placeholder shown until a real photo is dropped in */
.photo-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--sp-2); text-align: center;
  color: var(--c-primary-dark); padding: var(--sp-5);
  background: repeating-linear-gradient(45deg, var(--c-primary-soft), var(--c-primary-soft) 12px, var(--c-primary-softer) 12px, var(--c-primary-softer) 24px);
}
.photo-placeholder .material-icons { font-size: 40px; opacity: 0.65; }
.photo-placeholder span:not(.material-icons) { font-size: var(--fs-xs); max-width: 26ch; line-height: 1.5; opacity: 0.85; }

@media (max-width: 900px) {
  .hero__grid { grid-template-columns: 1fr; gap: var(--sp-6); }
  .hero__media { order: -1; max-width: 380px; }
  .portrait { aspect-ratio: 3 / 2; }
}

/* ----------------------------------------------------------- page header */
.page-head { background: var(--c-primary-softer); padding: var(--sp-7) 0 var(--sp-6); border-bottom: 1px solid var(--c-border); }
.page-head h1 { font-size: var(--fs-2xl); margin-bottom: var(--sp-2); }
.page-head p { color: var(--c-ink-soft); max-width: 62ch; margin: 0; }

/* ------------------------------------------------------------------- FAQ */
.faq-item { border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); margin-bottom: var(--sp-3); }
.faq-item summary {
  cursor: pointer; padding: var(--sp-4) var(--sp-5); font-weight: 600; font-family: var(--font-head);
  font-size: var(--fs-md); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-size: 22px; color: var(--c-primary); flex-shrink: 0; }
.faq-item[open] summary::after { content: '\2212'; }
.faq-item__body { padding: 0 var(--sp-5) var(--sp-5); color: var(--c-ink-soft); font-size: var(--fs-sm); }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); background: var(--c-surface); }
.table th { text-align: left; padding: var(--sp-3) var(--sp-4); background: var(--c-primary-softer); color: var(--c-ink); border-bottom: 2px solid var(--c-border); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; }
.table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); vertical-align: top; }
.table--lined th, .table--lined td { border: 1px solid var(--c-border); }
.table .col-center { text-align: center; vertical-align: middle; }
.table .total-row td { background: var(--c-primary-soft); font-weight: 700; color: var(--c-primary-dark); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--c-border); border-radius: var(--radius); }
.table-scroll .table { min-width: 620px; }

/* ================================================================ admin */
.admin-shell { display: flex; min-height: 100vh; }
.admin-side {
  width: 240px; flex-shrink: 0; background: var(--c-primary-dark); color: #d9e5e2;
  display: flex; flex-direction: column; padding: var(--sp-5) 0;
}
.admin-side .brand { padding: 0 var(--sp-5) var(--sp-5); }
.admin-side .brand__name, .admin-side .brand__tag { color: #fff; }
.admin-side nav { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--sp-3); }
.admin-side nav a, .admin-side nav button {
  display: flex; align-items: center; gap: var(--sp-3); text-decoration: none; text-align: left;
  color: #c3d4d0; font-size: var(--fs-sm); font-weight: 500; font-family: var(--font-body);
  padding: 10px var(--sp-3); border-radius: var(--radius-sm); background: none; border: none; cursor: pointer;
}
.admin-side nav a:hover, .admin-side nav button:hover { background: rgba(255,255,255,0.08); color: #fff; }
.admin-side nav a.is-active, .admin-side nav button.is-active { background: rgba(255,255,255,0.14); color: #fff; }
.admin-side nav .material-icons { font-size: 20px; }
.admin-side__foot { margin-top: auto; padding: var(--sp-4) var(--sp-5) 0; font-size: var(--fs-xs); color: #8fa8a3; }
.admin-main { flex-grow: 1; padding: var(--sp-6); min-width: 0; background: var(--c-bg); }
.admin-title { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.admin-title h1 { font-size: var(--fs-xl); margin: 0; }
@media (max-width: 920px) {
  .admin-shell { flex-direction: column; }
  .admin-side { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; padding: var(--sp-2) var(--sp-3); }
  .admin-side .brand { padding: 0 var(--sp-3); }
  .admin-side nav { flex-direction: row; }
  .admin-side nav a span:not(.material-icons), .admin-side nav button span:not(.material-icons) { display: none; }
  .admin-side__foot { display: none; }
  .admin-main { padding: var(--sp-4); }
}

/* Toggle switch (feature flags) */
.switch { position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute; cursor: pointer; inset: 0; background: #c9d4d1;
  border-radius: var(--radius-pill); transition: background 0.2s ease;
}
.switch__track::before {
  content: ""; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.2s ease; box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch__track { background: var(--c-primary); }
.switch input:checked + .switch__track::before { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus-ring); }
.switch input:disabled + .switch__track { opacity: 0.5; cursor: not-allowed; }

.flag-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-4) 0; border-bottom: 1px solid var(--c-border);
}
.flag-row:last-child { border-bottom: none; }
.flag-row__info h4 { margin: 0 0 2px; font-family: var(--font-body); font-size: var(--fs-base); }
.flag-row__info p { margin: 0; font-size: var(--fs-xs); color: var(--c-ink-soft); }

/* Login card */
.login-card { max-width: 420px; margin: 10vh auto; text-align: center; }
.login-card .material-icons--big { font-size: 44px; color: var(--c-primary); }

/* Patient submission cards (admin) */
.patient-card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-left: 5px solid var(--c-primary);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-3);
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
}
.patient-card h3 { margin: 0; font-size: var(--fs-md); }
.patient-card .meta { color: var(--c-ink-soft); font-size: var(--fs-sm); display: flex; align-items: center; gap: var(--sp-1); margin-top: var(--sp-1); }
.card-actions { display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-2); }
.confirm-group { display: none; align-items: center; gap: var(--sp-2); background: var(--c-danger-soft); padding: 4px 8px; border-radius: var(--radius-sm); border: 1px solid #eac6c3; }
.confirm-text { color: var(--c-danger); font-size: var(--fs-xs); font-weight: 600; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(35, 49, 47, 0.55);
  z-index: 1000; justify-content: center; align-items: center; backdrop-filter: blur(2px); padding: var(--sp-4);
}
.modal-content {
  background: var(--c-surface); width: 100%; max-width: 900px; max-height: 88vh;
  border-radius: var(--radius-lg); display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: modal-in 0.25s ease-out;
}
@keyframes modal-in { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  padding: var(--sp-4) var(--sp-5); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--c-primary); color: #fff;
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
}
.modal-header h2 { margin: 0; font-size: var(--fs-md); color: #fff; }
.modal-header p { margin: 2px 0 0; font-size: var(--fs-xs); opacity: 0.9; }
.modal-body { padding: var(--sp-5); overflow-y: auto; }
.icon-btn { background: transparent; border: none; color: inherit; cursor: pointer; padding: 6px; border-radius: 50%; display: inline-flex; }
.icon-btn:hover { background: rgba(255,255,255,0.2); }

/* Sections inside result modals — class names kept from legacy admin */
.section-title { font-size: var(--fs-base); font-weight: 700; color: var(--c-primary-dark); text-transform: uppercase; letter-spacing: 0.08em; margin: var(--sp-6) 0 var(--sp-4); border-bottom: 2px solid var(--c-border); padding-bottom: var(--sp-2); }
.section-title:first-child { margin-top: 0; }
.qa-item { padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-primary-softer); font-size: var(--fs-sm); display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); }
.qa-item:last-child { border-bottom: none; }
.snap-q { color: var(--c-ink); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-grow: 1; }
.snap-a { display: flex; align-items: center; font-size: var(--fs-sm); color: var(--c-ink-soft); white-space: nowrap; flex-shrink: 0; }
.score-pill { background: var(--c-primary-softer); color: var(--c-ink); font-weight: 700; padding: 2px 9px; border-radius: var(--radius-pill); margin-left: var(--sp-2); font-size: var(--fs-xs); }
.score-pill.active { background: var(--c-danger-soft); color: var(--c-danger); }
.subset-total { background: var(--c-primary-soft); padding: var(--sp-4); border-radius: var(--radius-sm); margin-top: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); color: var(--c-primary-dark); font-weight: 700; }

/* Questionnaire slide deck — class names kept from legacy questionnaire pages */
.q-appbar {
  background: var(--c-primary); color: #fff; padding: var(--sp-3) var(--sp-5);
  box-shadow: var(--shadow-sm); display: flex; justify-content: space-between; align-items: center;
  position: fixed; top: 0; width: 100%; z-index: 10;
}
.q-appbar h1 { margin: 0; font-size: var(--fs-md); color: #fff; font-family: var(--font-body); font-weight: 600; display: flex; align-items: center; }
.progress-text { font-size: var(--fs-sm); font-weight: 600; background: rgba(255,255,255,0.18); padding: 5px 12px; border-radius: var(--radius-pill); }
.viewport { height: 100vh; width: 100vw; overflow: hidden; position: relative; padding-top: 62px; }
.question-track { transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1); height: 100%; }
.question-slide { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: var(--sp-5); overflow-y: auto; }
.question-slide--top { justify-content: flex-start; padding-top: var(--sp-7); }
.q-card {
  background: var(--c-surface); padding: var(--sp-6); border: 1px solid var(--c-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  max-width: 640px; width: 100%; max-height: 100%; overflow-y: auto;
}
.q-card--wide { max-width: 940px; margin-bottom: var(--sp-6); }
.question-number { color: var(--c-accent); font-weight: 700; margin-bottom: var(--sp-2); text-transform: uppercase; letter-spacing: 0.1em; font-size: var(--fs-xs); }
.q-card h2 { font-size: var(--fs-lg); margin-bottom: var(--sp-5); font-weight: 500; }
.options { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.option-label {
  display: flex; align-items: center; padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--c-border); border-radius: var(--radius-sm); cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease; font-size: var(--fs-sm); line-height: 1.45;
}
.option-label:hover { background: var(--c-primary-softer); border-color: var(--c-primary); }
.option-label:has(input:checked) { background: var(--c-primary-soft); border-color: var(--c-primary); }
.option-label input[type="radio"], .option-label input[type="checkbox"] { margin-right: var(--sp-3); width: 19px; height: 19px; accent-color: var(--c-primary); flex-shrink: 0; }
.option-label--bare { border: none; padding: var(--sp-2); align-items: flex-start; }
.option-label--bare input { margin-top: 2px; }
.nav-buttons { display: flex; justify-content: space-between; gap: var(--sp-3); margin-top: auto; padding-top: var(--sp-4); }
.btn-prev { background: transparent; border: none; color: var(--c-primary-dark); font-weight: 600; font-size: var(--fs-sm); font-family: var(--font-body); text-transform: uppercase; letter-spacing: 0.04em; padding: 12px 20px; border-radius: var(--radius-pill); cursor: pointer; }
.btn-prev:hover { background: var(--c-primary-softer); }
.btn-next {
  background: var(--c-primary); color: #fff; border: none; flex-grow: 1;
  font-weight: 600; font-size: var(--fs-sm); font-family: var(--font-body); text-transform: uppercase; letter-spacing: 0.04em;
  padding: 12px 24px; border-radius: var(--radius-pill); cursor: pointer; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
}
.btn-next:hover { background: var(--c-primary-dark); box-shadow: var(--shadow); }
.timeline-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); margin-bottom: var(--sp-5); }
.timeline-section { background: var(--c-primary-softer); padding: var(--sp-4); border-radius: var(--radius-sm); border: 1px solid var(--c-border); }
.timeline-section--child { background: var(--c-accent-soft); }
.timeline-section h3, .timeline-section h4 { margin: 0 0 var(--sp-3); color: var(--c-primary-dark); font-size: var(--fs-base); display: flex; align-items: center; gap: var(--sp-2); border-bottom: 1px solid var(--c-border); padding-bottom: var(--sp-2); font-family: var(--font-body); font-weight: 700; }
.timeline-section--child h3, .timeline-section--child h4 { color: #8a5f37; }
.other-input { flex-grow: 1; width: 100%; padding: var(--sp-2); border: 1px solid var(--c-border); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: var(--fs-sm); resize: vertical; min-height: 44px; }
.other-input:focus { outline: none; border-color: var(--c-primary); }

/* Aliases for the questionnaire slide markup generated by the preserved
   legacy JS (class "card" inside ".question-slide") — do NOT rename the
   classes in the questionnaire scripts; restyle them here instead. */
.question-slide .card {
  background: var(--c-surface); padding: var(--sp-6); border: 1px solid var(--c-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  max-width: 640px; width: 100%; max-height: 100%; overflow-y: auto;
}
.question-slide .card h2 { font-size: var(--fs-lg); margin: 0 0 var(--sp-5); font-weight: 500; line-height: 1.4; }
.question-slide .card .nav-buttons { border-top: 1px solid var(--c-border); margin-top: var(--sp-5); }

@media (max-width: 768px) {
  .timeline-grid { grid-template-columns: 1fr; gap: var(--sp-4); }
  .q-card, .question-slide .card { padding: var(--sp-5); }
  .q-card h2, .question-slide .card h2 { font-size: var(--fs-md); }
  .q-appbar h1 { font-size: var(--fs-sm); }
  .progress-text { font-size: var(--fs-xs); }
  .options { gap: var(--sp-2); margin-bottom: var(--sp-4); }
  .option-label { padding: var(--sp-3); }
}

/* ---------------------------------------- questionnaire experience layer */

/* Thin progress bar pinned under the app bar */
.q-progress {
  position: fixed; top: 62px; left: 0; right: 0; height: 4px;
  background: var(--c-primary-softer); z-index: 20;
}
.q-progress__fill {
  height: 100%; width: 0; background: var(--c-accent);
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Inline validation message (replaces alert()) */
.q-error {
  background: var(--c-danger-soft); border: 1px solid #eac6c3; color: var(--c-danger);
  border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm); font-weight: 600; margin: 0 0 var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-2);
}
.q-error::before { content: "error_outline"; font-family: 'Material Icons'; font-size: 18px; font-weight: 400; }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.shake { animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@media (prefers-reduced-motion: reduce) {
  .shake { animation: none; }
  .question-track { transition: none; }
  .q-progress__fill { transition: none; }
}

/* Resume-draft dialog */
.q-resume {
  position: fixed; inset: 0; background: rgba(35, 49, 47, 0.55);
  backdrop-filter: blur(3px); z-index: 1200;
  display: flex; align-items: center; justify-content: center; padding: var(--sp-4);
}
.q-resume__card {
  background: var(--c-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: var(--sp-6); max-width: 460px; width: 100%; text-align: center;
}
.q-resume__icon { font-size: 42px; color: var(--c-accent); }
.q-resume__card h2 { font-size: var(--fs-lg); margin: var(--sp-3) 0 var(--sp-2); }
.q-resume__card p { color: var(--c-ink-soft); font-size: var(--fs-sm); }
.q-resume__actions { display: flex; flex-direction: column; gap: var(--sp-2); margin: var(--sp-5) 0 var(--sp-3); }
.q-resume__note { font-size: var(--fs-xs); color: var(--c-ink-faint); margin: 0; }

/* Completion screen */
.q-done { height: 100%; display: flex; align-items: center; justify-content: center; padding: var(--sp-5); }
.q-done__card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: var(--sp-7) var(--sp-6); max-width: 560px; text-align: center;
}
.q-done__tick { font-size: 56px; color: var(--c-success); }
.q-done__card h2 { font-size: var(--fs-lg); margin: var(--sp-4) 0 var(--sp-3); }
.q-done__card p { color: var(--c-ink-soft); font-size: var(--fs-sm); }
.q-done__note { font-size: var(--fs-xs); color: var(--c-ink-faint); margin-bottom: var(--sp-5); }
form.is-done { overflow: auto; }

/* Chat widget (AI assistant) */
.chat-toggle-btn {
  position: fixed; bottom: 24px; right: 24px; background: var(--c-primary); color: #fff;
  width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg); cursor: pointer; border: none; z-index: 1000; transition: transform 0.15s ease;
}
.chat-toggle-btn:hover { transform: scale(1.06); background: var(--c-primary-dark); }
.chat-widget {
  position: fixed; bottom: 96px; right: 24px; width: calc(100vw - 48px); max-width: 400px; height: 560px; max-height: 75vh;
  background: var(--c-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--c-border);
  display: flex; flex-direction: column; z-index: 1000;
  opacity: 0; pointer-events: none; transform: translateY(16px); transition: all 0.25s ease;
}
.chat-widget.active { opacity: 1; pointer-events: auto; transform: translateY(0); }
.chat-header { background: var(--c-primary); color: #fff; padding: var(--sp-4); border-radius: var(--radius-lg) var(--radius-lg) 0 0; display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.chat-body { flex-grow: 1; padding: var(--sp-4); overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-3); background: var(--c-bg); }
.chat-msg { max-width: 88%; padding: var(--sp-3) var(--sp-4); border-radius: 16px; font-size: var(--fs-sm); line-height: 1.5; word-wrap: break-word; }
.msg-ai { background: var(--c-surface); border: 1px solid var(--c-border); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-user { background: var(--c-primary-soft); color: var(--c-primary-dark); align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-footer { padding: var(--sp-3); border-top: 1px solid var(--c-border); display: flex; gap: var(--sp-2); background: var(--c-surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg); align-items: center; }
.chat-input { flex-grow: 1; padding: 10px 14px; border: 1px solid var(--c-border); border-radius: var(--radius-pill); font-size: var(--fs-sm); font-family: var(--font-body); outline: none; }
.chat-input:focus { border-color: var(--c-primary); }
.chat-send, .chat-mic { background: var(--c-primary); color: #fff; border: none; width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.chat-send:disabled { background: var(--c-border); cursor: not-allowed; }
.chat-mic { background: var(--c-accent); }
.chat-mic.is-listening { background: var(--c-danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(179,38,30,0.5); } 100% { box-shadow: 0 0 0 14px rgba(179,38,30,0); } }

/* Toasts — non-blocking feedback in place of alert() */
.toast-stack {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 2000; display: flex; flex-direction: column; gap: var(--sp-2);
  width: min(420px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  background: var(--c-ink); color: #fff; border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: var(--sp-3);
  animation: toast-in 0.25s ease-out; pointer-events: auto;
}
.toast--success { background: #24614a; }
.toast--error { background: var(--c-danger); }
.toast .material-icons { font-size: 20px; flex-shrink: 0; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Loading overlay + spinner */
.loading-overlay { display: none; position: fixed; inset: 0; background: rgba(250,249,247,0.85); z-index: 1500; justify-content: center; align-items: center; flex-direction: column; gap: var(--sp-4); }
.spinner { border: 4px solid var(--c-border); border-top-color: var(--c-primary); border-radius: 50%; width: 42px; height: 42px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ print */
@media print {
  body { background: #fff; }
  .site-header, .site-footer, .site-nav, .admin-side, .chat-toggle-btn, .chat-widget,
  .nav-toggle, .no-print { display: none !important; }
  .modal-overlay { display: block !important; position: static !important; background: transparent; padding: 0; }
  .modal-content { display: block !important; box-shadow: none !important; border: none !important; max-width: 100% !important; max-height: none !important; }
  .modal-body { overflow: visible !important; padding: 0; margin-top: 16px; }
  .modal-header { background: transparent !important; color: #000; padding: 0 0 12px; border-bottom: 2px solid #000; border-radius: 0; }
  .modal-header h2, .modal-header p { color: #000; }
  .header-actions { display: none !important; }
  .qa-item, .subset-total { page-break-inside: avoid; }
  .section-title { page-break-after: avoid; }
  .table tr { page-break-inside: avoid; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
