/* ============================================================
   Lysander Custom Design System
   Brand: liberation. Oat paper, aubergine ink, coral interaction,
   sage support. Fraunces (display) + Figtree (body) + Space Mono
   (small trust labels). A Haijahr product.
   ============================================================ */

/* ── Self-hosted fonts (OFL; no third-party calls) ──────── */
@font-face {
  font-family: 'Fraunces';
  font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/fonts/fraunces.woff2') format('woff2');
}
@font-face {
  font-family: 'Figtree';
  font-style: normal; font-weight: 300 900; font-display: swap;
  src: url('/fonts/figtree.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Mono';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/spacemono.woff2') format('woff2');
}

/* Variables */
:root {
  /* Brand palette: the Lysander identity (own, not Haijahr's).
     Coral drives actions, sage is the calm support, aubergine ink
     for headings, warm oat neutrals. Changing these recolours the
     whole app. (--teal* kept as token NAMES = the sage role.) */
  --primary:        #DC6A44;   /* coral: interaction, "Start free" and primary actions */
  --primary-dark:   #C4552F;
  --primary-light:  #FBECE4;   /* soft coral tint for active nav and highlights */
  --primary-ring:   rgba(220,106,68,0.28);

  --teal:           #5E8571;   /* sage: calm support, the between-sessions accent */
  --teal-dark:      #4C6E5C;
  --teal-light:     #E9F0EC;

  --gray-50:        #F5EFE4;   /* oat paper, app background */
  --gray-100:       #EFE7D8;   /* warm hover */
  --gray-200:       #E5DBC9;   /* hairline */
  --gray-300:       #D6CAB4;
  --gray-400:       #A99E8C;
  --gray-500:       #766B5F;   /* muted labels */
  --gray-600:       #4D4450;   /* body text (warm aubergine-grey) */
  --gray-700:       #3B3242;
  --gray-800:       #312839;
  --gray-900:       #2B2234;   /* aubergine ink, headings */

  --success-bg:     #ECF3ED;
  --success-border: #A8CBB0;
  --success-text:   #2F5D3E;
  --error-bg:       #FBEBE6;
  --error-border:   #E7A68F;
  --error-text:     #9A3B1F;
  --warning-bg:     #FBF1DD;
  --warning-border: #E3C070;
  --warning-text:   #7A5A1B;
  --info-bg:        #EAF0EC;
  --info-border:    #A8C3B4;
  --info-text:      #3C5A49;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  --shadow-sm:  0 1px 2px rgba(43,34,52,0.06);
  --shadow:     0 1px 3px rgba(43,34,52,0.09), 0 1px 2px rgba(43,34,52,0.05);
  --shadow-md:  0 4px 6px rgba(43,34,52,0.07), 0 2px 4px rgba(43,34,52,0.05);
  --shadow-lg:  0 10px 15px rgba(43,34,52,0.08), 0 4px 6px rgba(43,34,52,0.05);

  --nav-height: 60px;
  --font:         'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;   /* display headings */
  --font-mono:    'Space Mono', ui-monospace, 'SF Mono', Menlo, monospace;  /* small trust labels */
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Accessibility: visible keyboard focus everywhere ── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 3px;
}
.btn:focus-visible, .b:focus-visible {
  outline: 2px solid var(--gray-900);
  outline-offset: 2px;
}
/* Don't show focus rings for mouse users who haven't tabbed. */
:focus:not(:focus-visible) { outline: none; }

/* ── Skip to content (first focusable; visible only on focus) ── */
.skip-link {
  position: absolute; left: 8px; top: -56px; z-index: 1000;
  background: var(--gray-900); color: #fff;
  padding: 0.65rem 1.1rem; border-radius: 8px;
  font: 600 0.9rem/1 var(--font); text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 8px; outline: 2px solid #fff; outline-offset: 2px; }

/* Respect reduced-motion preferences globally. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1 { font-family: var(--font-display); font-size: 1.85rem; font-weight: 600; color: var(--gray-900); line-height: 1.2; letter-spacing: -0.012em; }
h2 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; color: var(--gray-900); line-height: 1.3; letter-spacing: -0.01em; }
h3 { font-size: 1.1rem;  font-weight: 600; color: var(--gray-900); }
h4 { font-size: 0.95rem; font-weight: 600; color: var(--gray-700); }

p { color: var(--gray-600); line-height: 1.7; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  word-break: break-all;
}

hr { border: none; border-top: 1px solid var(--gray-200); margin: 2rem 0; }

/* ── Layout ─────────────────────────────────────────── */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-main {
  flex: 1;
  padding: 2.5rem 0 4rem;
}

.site-footer {
  border-top: 1px solid var(--gray-200);
  padding: 1.25rem 0;
  font-size: 0.8rem;
  color: var(--gray-400);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.footer-links a { color: var(--gray-400); text-decoration: none; padding: 0.3rem 0; min-height: 24px; display: inline-flex; align-items: center; }
.footer-links a:hover { color: var(--gray-600); text-decoration: underline; }

.footer-cookie-btn {
  background: none;
  border: none;
  padding: 0.3rem 0;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  color: var(--gray-400);
  cursor: pointer;
  font-family: var(--font);
}
.footer-cookie-btn:hover { color: var(--gray-600); text-decoration: underline; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 { margin: 0; }

.page-header-meta {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.2rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  margin-top: 2.5rem;
}

.section-header h2 { margin: 0; }

.breadcrumb {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--primary); }

/* ── Impersonation banner (sits directly under the nav) ── */
.impersonation-bar {
  background: #fffbeb;
  border-bottom: 1px solid #fcd34d;
  color: #92400e;
  font-size: 0.85rem;
}
.impersonation-bar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  flex-wrap: wrap;
}
.impersonation-bar-text { display: inline-flex; align-items: center; gap: 0.4rem; }
.impersonation-bar-text strong { font-weight: 600; }
.impersonation-bar-btn {
  background: #92400e;
  color: #fff;
  border: none;
  font: 600 0.78rem/1 var(--font);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.impersonation-bar-btn:hover { background: #7c350c; }

/* ── Navigation ─────────────────────────────────────── */
.site-nav {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  height: var(--nav-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-inner {
  display: flex;
  align-items: center;
  height: var(--nav-height);
  gap: 2rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gray-900);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-brand:hover { text-decoration: none; color: var(--gray-900); }

.nav-brand { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
.nav-brand-icon {
  width: 34px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-brand-icon svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* ── "A Haijahr product" footer line ────────────────────── */
.footer-haijahr {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--gray-500);
}
.footer-haijahr img { height: 15px; width: auto; opacity: 0.85; }
.footer-haijahr .fh-dark { display: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.nav-links a:not(.btn) {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-600);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:not(.btn):hover { background: var(--gray-100); color: var(--gray-900); }
.nav-links a:not(.btn).active { background: var(--primary-light); color: var(--primary); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  margin-left: auto;
}

.nav-username {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
}

.avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
  line-height: 1.4;
  white-space: nowrap;
  font-family: var(--font);
}

.btn:hover { text-decoration: none; }

/* True brand coral with dark ink text: matches the logo/accent coral and still
   clears WCAG AA (~4.9:1), where coral + white would only reach ~3.4:1. */
.btn-primary {
  background: var(--primary);
  color: #241B2E;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary); border-color: var(--primary); color: #241B2E; box-shadow: var(--shadow-md); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border-color: var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); color: var(--gray-800); }

.btn-outline {
  background: transparent;
  color: var(--gray-600);
  border-color: var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-700); }

.btn-danger {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.btn-danger-outline {
  background: transparent;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-danger-outline:hover { background: var(--error-bg); border-color: #dc2626; }

.btn-teal {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.btn-teal:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ── Forms ─────────────────────────────────────────── */
.form-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 2rem;
  max-width: 560px;
}

.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.4rem;
}

.form-label .optional {
  font-weight: 400;
  color: var(--gray-400);
  font-size: 0.8rem;
  margin-left: 0.3rem;
}

.form-control,
.form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font);
  color: var(--gray-800);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.5;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

textarea.form-control { resize: vertical; min-height: 120px; }

.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2.25rem; }

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--gray-700);
  cursor: pointer;
}

.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.form-file { font-size: 0.875rem; color: var(--gray-600); }
.form-file input[type="file"] { margin-top: 0.3rem; font-size: 0.875rem; }

.form-hint { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.3rem; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-100);
}

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 1.5rem; }
.card-body p { margin: 0; }

.card-footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  display: flex;
  gap: 0.5rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }

/* ── Tables ─────────────────────────────────────────── */
.data-table {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead th {
  padding: 0.7rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.1s;
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); }

.data-table tbody td {
  padding: 0.8rem 1rem;
  color: var(--gray-700);
  vertical-align: middle;
}

.data-table tbody td a { color: var(--gray-800); font-weight: 500; }
.data-table tbody td a:hover { color: var(--primary); }

.table-actions { display: flex; gap: 0.75rem; }
.table-actions a { font-size: 0.8rem; color: var(--primary); font-weight: 500; }
.table-actions a:hover { text-decoration: underline; }
.table-actions a.danger { color: #dc2626; }

/* ── Stat Cards ─────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.stat-card.teal  { border-left-color: var(--teal); }
.stat-card.green { border-left-color: #16a34a; }
.stat-card.amber { border-left-color: #d97706; }
.stat-card.rose  { border-left-color: #e11d48; }

.stat-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.35rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Alerts ─────────────────────────────────────────── */
.alert {
  padding: 0.85rem 1rem 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  border-left: 4px solid transparent;
  line-height: 1.5;
}

.alert ul { margin: 0.25rem 0 0 1rem; padding: 0; }
.alert li { margin-bottom: 0.15rem; }

.alert-success { background: var(--success-bg); border-color: #16a34a; color: var(--success-text); }
.alert-error   { background: var(--error-bg);   border-color: #dc2626; color: var(--error-text); }
.alert-warning { background: var(--warning-bg); border-color: #d97706; color: var(--warning-text); }
.alert-info    { background: var(--info-bg);    border-color: #2563eb; color: var(--info-text); }

/* ── Badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.6em;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-success   { background: #dcfce7; color: #15803d; }
.badge-warning   { background: #fef9c3; color: #a16207; }
.badge-danger    { background: #fee2e2; color: #b91c1c; }
.badge-secondary { background: var(--gray-100); color: var(--gray-600); }
.badge-info      { background: #dbeafe; color: #1d4ed8; }
.badge-indigo    { background: var(--primary-light); color: var(--primary); }

/* ── Empty State ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.6; }
.empty-state h3 { font-size: 1.1rem; color: var(--gray-700); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9rem; color: var(--gray-500); margin-bottom: 1.5rem; }

/* ── Task Row Cards ──────────────────────────────────── */
.task-list { display: flex; flex-direction: column; gap: 0.75rem; }

.task-row {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.task-row:hover { box-shadow: var(--shadow-md); }
.task-row.completed { background: var(--success-bg); border-color: var(--success-border); }

.task-row-left { flex: 1; min-width: 0; }
.task-row-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.task-row-desc {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Case Thread (patient session timeline) ──────────── */
.case-thread { position: relative; padding-left: 1.75rem; }
.case-thread::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0.6rem;
  bottom: 0.6rem;
  width: 2px;
  background: linear-gradient(var(--teal), #bfe7e0);
}

.thread-node { position: relative; padding-bottom: 1.75rem; }
.thread-node:last-child { padding-bottom: 0; }
.thread-node::before {
  content: '';
  position: absolute;
  left: calc(-1.75rem + 1px);
  top: 0.3rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--teal);
  box-sizing: border-box;
}

/* Hollow dot = not yet done (e.g. a task awaiting the patient) */
.thread-node.pending::before { background: #fff; }

.thread-node-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.thread-title { font-size: 0.95rem; font-weight: 600; color: var(--gray-900); }
a.thread-title:hover { color: var(--primary); }

.thread-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gray-500);
}

.thread-open { font-size: 0.8rem; font-weight: 500; color: var(--primary); white-space: nowrap; }
.thread-open:hover { text-decoration: underline; }

.thread-note { font-size: 0.9rem; color: var(--gray-700); margin: 0.4rem 0 0; line-height: 1.6; }
.thread-note.muted { color: var(--gray-400); font-style: italic; }

.thread-tasks {
  list-style: none;
  padding: 0;
  margin: 0.85rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.thread-tasks li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.55rem 0.85rem;
  box-shadow: var(--shadow-sm);
}

.thread-tasks li a.thread-task-title { color: var(--gray-800); }
.thread-tasks li a.thread-task-title:hover { color: var(--primary); }

.thread-task-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-800);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2em 0.65em;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
}

.thread-chip.done    { color: var(--teal-dark);     background: var(--teal-light); border: 1px solid #c7ece5; }
.thread-chip.pending { color: var(--warning-text);  background: var(--warning-bg); border: 1px solid var(--warning-border); }

/* ── Support ticket thread ──────────────────────────── */
.ticket-thread { display: flex; flex-direction: column; gap: 0.85rem; }
.ticket-msg {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.35rem;
  box-shadow: var(--shadow-sm);
}
.ticket-msg.staff {
  background: var(--primary-light);
  border-color: #c7d2fe;
}
.ticket-msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.ticket-msg-author { font-size: 0.875rem; font-weight: 600; color: var(--gray-900); display: inline-flex; align-items: center; gap: 0.4rem; }
.ticket-msg-time { font-size: 0.75rem; color: var(--gray-400); white-space: nowrap; }
.ticket-msg-body { font-size: 0.9rem; color: var(--gray-700); line-height: 1.65; margin: 0; white-space: pre-wrap; }

/* ── CTA Promo Card ─────────────────────────────────── */
.promo-card {
  background: var(--primary-light);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2.5rem;
}

.promo-card p { color: var(--gray-700); margin: 0.25rem 0 0; font-size: 0.9rem; }
.promo-card h3 { color: var(--gray-900); margin-bottom: 0; }

/* ── Danger Zone Card ───────────────────────────────── */
.danger-card {
  background: #fff;
  border: 1px solid var(--error-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 480px;
  margin: 3rem auto;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.danger-card .danger-icon { font-size: 3rem; margin-bottom: 1rem; }
.danger-card h2 { color: var(--error-text); margin-bottom: 0.75rem; }
.danger-card p { margin-bottom: 2rem; }
.danger-card .btn-actions { justify-content: center; }

/* ── Pending / Info Card ─────────────────────────────── */
.info-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  max-width: 480px;
  margin: 3rem auto;
  text-align: center;
  box-shadow: var(--shadow);
}

.info-card .info-icon { font-size: 3rem; margin-bottom: 1.25rem; }
.info-card h2 { margin-bottom: 0.75rem; }
.info-card p  { margin-bottom: 1.5rem; }

/* ── Auth Pages ─────────────────────────────────────── */
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height));
  padding: 2rem 1rem;
}

.auth-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-logo-mark {
  width: 62px;
  height: 42px;
  color: var(--gray-900);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}
.auth-logo-mark svg { width: 100%; height: 100%; display: block; overflow: visible; }

.auth-card h1 {
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.auth-card .auth-subtitle {
  text-align: center;
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-bottom: 1.75rem;
}

.auth-footer {
  text-align: center;
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 1.25rem;
}

/* ── Landing Page (legacy hero class; brand-recoloured) ── */
.landing-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--teal) 100%);
  color: #fff;
  padding: 6rem 0 5rem;
  text-align: center;
}

.landing-hero h1 {
  font-size: 3rem;
  color: #fff;
  margin-bottom: 1.25rem;
  line-height: 1.15;
  font-weight: 800;
}

.landing-hero p {
  font-size: 1.2rem;
  color: rgba(255,255,255,0.82);
  max-width: 560px;
  margin: 0 auto 2.5rem;
}

.hero-cta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.btn-white {
  background: #fff;
  color: var(--primary);
  border-color: #fff;
  font-weight: 600;
}
.btn-white:hover { background: var(--gray-100); color: var(--primary-dark); }

.btn-ghost {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.35);
}
.btn-ghost:hover { background: rgba(255,255,255,0.2); color: #fff; }

.landing-section { padding: 5rem 0; }
.landing-section + .landing-section { border-top: 1px solid var(--gray-200); }
.landing-section-header { text-align: center; margin-bottom: 3rem; }
.landing-section-header h2 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.landing-section-header p { font-size: 1rem; max-width: 480px; margin: 0 auto; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.feature-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}

.feature-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.feature-icon { font-size: 2rem; margin-bottom: 1rem; }
.feature-card h3 { font-size: 1rem; margin-bottom: 0.5rem; color: var(--gray-900); }
.feature-card p  { font-size: 0.875rem; color: var(--gray-500); margin: 0; }

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.pricing-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.pricing-card.featured {
  border-color: var(--primary);
  border-width: 2px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.pricing-card.featured::before {
  content: 'Popular';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2em 0.9em;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pricing-name { font-size: 1.1rem; font-weight: 700; color: var(--gray-900); margin-bottom: 1.25rem; }

.pricing-limit {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-bottom: 2rem;
  line-height: 1.9;
}

.pricing-limit li { list-style: none; }
.pricing-limit li::before { content: '✓ '; color: var(--teal); font-weight: 700; }

/* ── Patient Portal ─────────────────────────────────────
   Shares the app's chrome (site-nav, container, cards, case-thread)
   so the patient side reads as the same product. Teal stays the accent. */
.portal-tag {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--teal-dark);
  background: var(--teal-light);
  border: 1px solid #c7ece5;
  padding: 0.18em 0.6em;
  border-radius: 100px;
}

.portal-tasks { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.85rem; }

.portal-task {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.35rem;
  box-shadow: var(--shadow-sm);
}

.portal-task.completed { background: var(--success-bg); border-color: var(--success-border); }

.portal-task-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.portal-task-title { font-size: 1rem; font-weight: 600; color: var(--gray-900); margin: 0; line-height: 1.4; }
.portal-task-desc { font-size: 0.9rem; color: var(--gray-600); line-height: 1.65; margin: 0.5rem 0 0; white-space: pre-wrap; }

.portal-task-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.portal-download { font-size: 0.85rem; color: #0b6157; font-weight: 600; display: inline-flex; align-items: center; gap: 0.35rem; }
.portal-download:hover { color: #0b6157; text-decoration: underline; }

/* Submit-work slide-in drawer (right) */
.portal-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21,35,59,0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 9000;
}
.portal-drawer-overlay.open { opacity: 1; visibility: visible; }

.portal-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(440px, 100%);
  background: #fff;
  box-shadow: -12px 0 40px rgba(21,35,59,0.18);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(.2,.7,.2,1);
  z-index: 9001;
  display: flex;
  flex-direction: column;
}
.portal-drawer.open { transform: none; }

.portal-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
}
.portal-drawer-head h2 { margin: 0; font-size: 1.2rem; }
.portal-drawer-eyebrow {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--teal-dark); margin-bottom: 0.35rem;
}
.portal-drawer-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.6rem; line-height: 1; color: var(--gray-400);
  padding: 0.1rem 0.4rem; border-radius: var(--radius-sm); flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.portal-drawer-close:hover { color: var(--gray-700); background: var(--gray-100); }

.portal-drawer-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.portal-drawer-desc { font-size: 0.9rem; color: var(--gray-600); line-height: 1.65; white-space: pre-wrap; margin: 0 0 1.25rem; }

@media (max-width: 480px) { .portal-drawer { width: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .portal-drawer, .portal-drawer-overlay { transition: none; }
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  h1 { font-size: 1.4rem; }
  .landing-hero h1 { font-size: 2rem; }
  .nav-links { display: none; }
  .nav-username { display: none; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .auth-card { padding: 1.75rem; }
  .form-card { padding: 1.5rem; }
  .stats-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ── Legal Pages ─────────────────────────────────────── */
.legal-page {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 3rem;
  align-items: start;
  max-width: 960px;
  margin: 0 auto;
}

.legal-toc {
  position: sticky;
  top: calc(var(--nav-height) + 2rem);
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  font-size: 0.875rem;
}

.legal-toc-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  margin-bottom: 0.75rem;
}

.legal-toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc;
}

.legal-toc li {
  counter-increment: toc;
  margin-bottom: 0.2rem;
}

.legal-toc a {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}

.legal-toc a:hover { background: var(--gray-100); color: var(--primary); }

.legal-content { min-width: 0; }

.legal-header { margin-bottom: 2rem; }
.legal-header h1 { margin-bottom: 0.25rem; }
.legal-meta { font-size: 0.85rem; color: var(--gray-400); margin: 0; }

.legal-content section {
  margin-top: 2.5rem;
  scroll-margin-top: calc(var(--nav-height) + 1.5rem);
}

.legal-content h2 {
  font-size: 1.15rem;
  color: var(--gray-900);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.legal-content h3 {
  font-size: 0.95rem;
  color: var(--gray-800);
  margin: 1.25rem 0 0.5rem;
}

.legal-content p { margin-bottom: 0.75rem; }

.legal-content ul, .legal-content ol {
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.legal-content li { margin-bottom: 0.35rem; color: var(--gray-600); line-height: 1.6; }

.legal-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  line-height: 1.75;
  color: var(--gray-700);
  margin: 1rem 0;
}

.legal-table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.legal-table th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  padding: 0.6rem 1rem;
  text-align: left;
  border: 1px solid var(--gray-200);
}

.legal-table td {
  padding: 0.6rem 1rem;
  border: 1px solid var(--gray-200);
  vertical-align: top;
  color: var(--gray-700);
  line-height: 1.55;
}

.legal-footer-links {
  display: flex;
  gap: 1.5rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-200);
  font-size: 0.875rem;
}

@media (max-width: 768px) {
  .legal-page { grid-template-columns: 1fr; }
  .legal-toc { position: static; }
}

/* ── Cookie Consent Banner ───────────────────────────── */
#cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: #fff;
  border-top: 1px solid var(--gray-200);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
  padding: 1.25rem 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#cookie-banner.hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.cookie-banner-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.cookie-banner-text { flex: 1; min-width: 260px; }

.cookie-banner-text h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cookie-banner-text p {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin: 0;
  line-height: 1.5;
}

.cookie-banner-text a { color: var(--primary); font-size: 0.8rem; }
/* AA on the always-white banner (both themes) + underline so links are
   distinguishable without relying on colour. */
#cookie-banner .cookie-banner-text a { color: #B14A28; text-decoration: underline; }

.cookie-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Cookie preferences modal */
#cookie-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9100;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#cookie-modal.open { display: flex; }

.cookie-modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
}

.cookie-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.cookie-modal-header h3 { font-size: 1rem; margin: 0; }

.cookie-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--gray-400);
  line-height: 1;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.cookie-modal-close:hover { color: var(--gray-700); background: var(--gray-100); }

.cookie-modal-body { padding: 1.5rem; }

.cookie-category {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--gray-100);
}

.cookie-category:last-child { border-bottom: none; }

.cookie-category-info { flex: 1; }

.cookie-category-info h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cookie-always-on {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--success-text);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  padding: 0.1em 0.5em;
  border-radius: 100px;
}

.cookie-category-info p {
  font-size: 0.78rem;
  color: var(--gray-500);
  margin: 0;
  line-height: 1.5;
}

/* Toggle switch */
.toggle-switch { position: relative; flex-shrink: 0; width: 40px; height: 22px; }

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-track { background: var(--primary); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle-switch input:disabled + .toggle-track { background: var(--success-text); opacity: 0.6; cursor: not-allowed; }

.cookie-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

@media (max-width: 600px) {
  .cookie-banner-inner { flex-direction: column; align-items: flex-start; }
  .cookie-banner-actions { width: 100%; justify-content: flex-end; }
}
