/* ==========================================================================
   Playful Pilots — Design System v12 (Redesign)
   Warm, modern, elegant. Easy to read. Feels like home.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* Brand — warm sage + deep navy */
  --brand-sage:    #5C8A6A;
  --brand-sage-dk: #3E6B52;
  --brand-coral:   #E07B5D;
  --brand-navy:    #1E293B;
  --brand-gold:    #C9A227;

  /* Surfaces — warm cream */
  --bg:           #F7F5F1;
  --surface:      #FFFFFF;
  --surface-2:    #F2EFE9;
  --surface-3:    #EAE6DE;
  --surface-inv:  #1E293B;

  /* Text */
  --text:         #1E293B;
  --text-muted:   #64748B;
  --text-faint:   #94A3B8;
  --text-inv:     #F8F9FA;

  /* Borders — warm, soft */
  --border:       #E4DED4;
  --border-md:    #CFC8BC;
  --border-strong:#B8AFA0;

  /* Semantic — primary is sage green */
  --primary:      #5C8A6A;
  --primary-dk:   #3E6B52;
  --primary-lt:   rgba(92,138,106,.12);
  --primary-tint: #EEF4F0;

  --danger:       #C0392B;
  --danger-lt:    rgba(192,57,43,.09);
  --success:      #27AE60;
  --success-lt:   rgba(39,174,96,.10);
  --warning:      #D4860A;
  --warning-lt:   rgba(212,134,10,.10);
  --info:         #2471A3;
  --info-lt:      rgba(36,113,163,.09);

  /* Radius */
  --r-sm:  8px;
  --r:     14px;
  --r-lg:  20px;
  --r-xl:  28px;
  --r-pill:999px;

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

  /* Shadows — warmer, softer */
  --sh-xs: 0 1px 3px rgba(30,41,59,.05);
  --sh-sm: 0 2px 8px rgba(30,41,59,.06), 0 1px 2px rgba(30,41,59,.04);
  --sh-md: 0 4px 20px rgba(30,41,59,.10), 0 1px 4px rgba(30,41,59,.06);
  --sh-lg: 0 8px 40px rgba(30,41,59,.14), 0 2px 8px rgba(30,41,59,.08);

  /* Typography */
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "DM Serif Display", Georgia, serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Backward-compat aliases */
  --radius: var(--r);
  --radius-lg: var(--r-lg);
  --radius-pill: var(--r-pill);
  --space-1: var(--sp-1);
  --space-2: var(--sp-2);
  --space-3: var(--sp-3);
  --space-4: var(--sp-4);
  --space-5: var(--sp-5);
  --space-6: var(--sp-6);
  --space-7: var(--sp-7);

  /* Animation */
  --ease: cubic-bezier(.16,1,.3,1);
  --t-fast:140ms;
  --t-base:200ms;
  --t-slow:300ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #131A24;
    --surface:     #1A2332;
    --surface-2:   #1F2B3D;
    --surface-3:   #263548;
    --surface-inv: #F1F5F9;

    --text:        #EEF2F8;
    --text-muted:  #8A97AD;
    --text-faint:  #5C6A80;
    --text-inv:    #1E293B;

    --border:      #243047;
    --border-md:   #2D3D56;
    --border-strong:#3A4F6A;

    --primary:     #6FA87E;
    --primary-dk:  #5C8A6A;
    --primary-lt:  rgba(111,168,126,.16);
    --primary-tint:#152A1E;

    --danger:      #E57373;
    --danger-lt:   rgba(229,115,115,.13);
    --success:     #55CF7E;
    --success-lt:  rgba(85,207,126,.13);
    --warning:     #FFCA62;
    --warning-lt:  rgba(255,202,98,.13);

    --sh-xs: 0 1px 3px rgba(0,0,0,.35);
    --sh-sm: 0 2px 8px rgba(0,0,0,.40), 0 1px 2px rgba(0,0,0,.30);
    --sh-md: 0 4px 20px rgba(0,0,0,.45), 0 1px 4px rgba(0,0,0,.35);
    --sh-lg: 0 8px 40px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.40);
  }
}

/* --------------------------------------------------------------------------
   2. RESET + BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  font-feature-settings: "ss01","cv11","liga";
}

body {
  min-height: 100vh;
  margin: 0;
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,h2,h3,h4,h5,h6 {
  line-height: 1.25;
  letter-spacing: -.02em;
  font-weight: 700;
  margin: 0 0 var(--sp-3);
}
h1 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem,1.2rem + 1.8vw,2.4rem);
  font-weight: 400;
  letter-spacing: -.01em;
}
h2 { font-size: clamp(1.15rem,1rem + .5vw,1.4rem); font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
h4 { font-size: .95rem; font-weight: 600; }

p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dk); text-decoration: underline; }
a:focus-visible { outline: 3px solid var(--primary-lt); outline-offset: 2px; border-radius: 4px; }

button,input,select,textarea { font: inherit; font-size: 15.5px; }
textarea { resize: vertical; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   3. LAYOUT SHELL
   -------------------------------------------------------------------------- */
.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: var(--sp-4);
}
@media (min-width: 768px) { .app-shell { padding: var(--sp-5) var(--sp-6); } }

.site-main { padding: var(--sp-5) 0; }

/* Auth body */
.auth-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(55% 50% at 30% 0%, rgba(92,138,106,.13), transparent 65%),
    radial-gradient(40% 40% at 90% 90%, rgba(201,162,39,.08), transparent 60%),
    var(--bg);
}
.auth-main {
  min-height: 100vh;
  padding: var(--sp-4);
  padding-left: max(var(--sp-4), env(safe-area-inset-left));
  padding-right: max(var(--sp-4), env(safe-area-inset-right));
  padding-bottom: max(var(--sp-5), env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --------------------------------------------------------------------------
   4. TOPBAR / HEADER
   -------------------------------------------------------------------------- */
.site-header.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-5);
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(247,245,241,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

@media (prefers-color-scheme: dark) {
  .site-header.app-topbar { background: rgba(19,26,36,.92); }
}

.brand--with-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}
.brand--with-logo:hover { text-decoration: none; color: var(--text); }
.brand__logo { width: 38px; height: 38px; flex: 0 0 38px; object-fit: contain; border-radius: 10px; }
.brand__text { display: flex; flex-direction: column; gap: 1px; line-height: 1; }
.brand__name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -.01em;
}
.brand__tagline { font-size: .7rem; color: var(--text-muted); font-weight: 400; }
@media (max-width: 480px) { .brand__tagline { display: none; } }

.topbar-select {
  max-width: 13rem;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-md);
  background: var(--surface);
  color: var(--text);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--t-fast) ease;
}
.topbar-select:hover { border-color: var(--primary); }

.topbar-actions { display: flex; gap: var(--sp-4); align-items: center; }
.topbar-actions a, .topbar-actions button {
  color: var(--text-muted);
  font-size: .86rem;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color var(--t-fast) ease;
}
.topbar-actions a:hover, .topbar-actions button:hover { color: var(--text); text-decoration: none; }

.notification-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  font-size: 1.1rem;
  line-height: 1;
}
.notification-link .badge-count { margin-left: 2px; }

/* --------------------------------------------------------------------------
   5. BOTTOM NAV
   -------------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  right: var(--sp-3);
  bottom: var(--sp-3);
  left: var(--sp-3);
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
}
@media (min-width: 768px) {
  .bottom-nav {
    right: calc(50% - 480px + var(--sp-6));
    left: calc(50% - 480px + var(--sp-6));
  }
}
.bottom-nav__item, .bottom-nav > a {
  display: grid;
  place-items: center;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: var(--r-lg);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
  letter-spacing: .01em;
}
.bottom-nav__item:hover, .bottom-nav > a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.bottom-nav__item.is-active, .bottom-nav > a.is-active {
  background: var(--primary);
  color: #fff;
}
.bottom-nav__item.is-active:hover, .bottom-nav > a.is-active:hover {
  background: var(--primary-dk);
  color: #fff;
}
.with-bottom-nav { padding-bottom: 104px; }

/* --------------------------------------------------------------------------
   6. CARDS
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  padding: var(--sp-4);
}
@media (min-width: 768px) { .card { padding: var(--sp-5); } }
.card--soft { background: var(--surface-2); box-shadow: none; border-color: var(--border); }
.card--link {
  display: block;
  color: var(--text);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) ease, border-color var(--t-fast) ease;
  text-decoration: none;
}
.card--link:hover {
  color: var(--text);
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: var(--sh-md);
  border-color: var(--primary);
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-md);
  padding: var(--sp-5);
}
@media (min-width: 768px) { .hero-card { padding: var(--sp-7) 40px; } }

.details-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
  padding: var(--sp-4);
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  margin-bottom: var(--sp-4);
}
.settings-card__head {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.settings-card__head h2 { margin: 0; font-size: 1.02rem; font-weight: 600; }
.settings-card__head .eyebrow { margin: 0 0 4px; font-size: .7rem; }
.settings-card__head p.muted { margin: 4px 0 0; font-size: .88rem; }
.settings-card__body { padding: var(--sp-4); display: grid; gap: var(--sp-3); }
.settings-card--danger { border-color: rgba(192,57,43,.35); }
.settings-card--danger .settings-card__head { background: var(--danger-lt); border-bottom-color: rgba(192,57,43,.3); }
.settings-card--danger .settings-card__head h2 { color: var(--danger); }

.caseload-card { padding: var(--sp-4); }
.caseload-card h2 { font-size: 1.02rem; margin: 0; font-weight: 600; }

.collapse-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
  margin-bottom: var(--sp-3);
}
.collapse-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--text);
  border-radius: var(--r-lg);
  transition: background var(--t-fast) ease;
}
.collapse-card > summary::-webkit-details-marker { display: none; }
.collapse-card > summary::after { content: "▾"; color: var(--text-faint); font-size: .9rem; transition: transform var(--t-fast) ease; }
.collapse-card[open] > summary::after { transform: rotate(180deg); }
.collapse-card > summary:hover { background: var(--surface-2); }
.collapse-card__body { padding: 0 var(--sp-4) var(--sp-4); display: grid; gap: var(--sp-3); }
.collapse-card--danger { border-color: rgba(192,57,43,.3); }
.collapse-card--danger > summary { color: var(--danger); }

.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--sh-xs);
}
.note-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-2); flex-wrap: wrap; }
.note-card__type { display: inline-block; padding: 3px 10px; background: var(--primary-tint); color: var(--primary-dk); border-radius: var(--r-pill); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.note-card__type--clinical { background: var(--warning-lt); color: var(--warning); }
.note-card__locked { font-size: .74rem; color: var(--text-muted); font-weight: 500; }
.note-card__author { font-size: .85rem; color: var(--text-muted); margin-top: var(--sp-2); }
.note-card__content { white-space: pre-wrap; line-height: 1.65; }

/* --------------------------------------------------------------------------
   7. BUTTONS
   -------------------------------------------------------------------------- */
.btn, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: .92rem;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(92,138,106,.3);
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease, color var(--t-fast) ease, box-shadow var(--t-fast) ease, transform var(--t-fast) ease;
}
.btn:hover, .button:hover { background: var(--primary-dk); color: #fff; text-decoration: none; box-shadow: 0 4px 12px rgba(92,138,106,.35); }
.btn:active, .button:active { transform: translateY(1px); box-shadow: var(--sh-xs); }
.btn:focus-visible, .button:focus-visible { outline: 3px solid var(--primary-lt); outline-offset: 2px; }
.btn:disabled, button:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn-secondary, .button-secondary, .button--secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-md);
  box-shadow: var(--sh-xs);
}
.btn-secondary:hover, .button-secondary:hover, .button--secondary:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger, .button-danger { background: var(--danger); box-shadow: none; }
.btn-danger:hover, .button-danger:hover { background: #a93226; color: #fff; }

.btn-ghost, .button--ghost {
  background: transparent;
  color: var(--primary);
  border-color: transparent;
  box-shadow: none;
}
.btn-ghost:hover, .button--ghost:hover { background: var(--primary-lt); color: var(--primary-dk); box-shadow: none; }

.btn-sm { min-height: 34px; padding: 6px 14px; font-size: .82rem; border-radius: var(--r-sm); }
.btn-block { display: flex; width: 100%; }

.link-button { background: none; border: 0; color: var(--primary); font: inherit; padding: 0; cursor: pointer; font-weight: 600; }
.link-button:hover { color: var(--primary-dk); text-decoration: underline; }

/* --------------------------------------------------------------------------
   8. FORMS
   -------------------------------------------------------------------------- */
.form-stack { display: grid; gap: var(--sp-4); }

label { font-weight: 600; font-size: .92rem; color: var(--text); }
label small, .field-hint { font-weight: 400; color: var(--text-muted); font-size: .8rem; }

.field-stack { display: grid; gap: 6px; }
.field-label { font-weight: 600; font-size: .88rem; color: var(--text); }

.grid-2 { display: grid; gap: var(--sp-3); }
@media (min-width: 540px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

input, select, textarea {
  width: 100%;
  padding: 11px 15px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-size: .93rem;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--primary); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-lt);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=date], input[type=time] { font-variant-numeric: tabular-nums; }
textarea { min-height: 90px; }

fieldset { border: 1.5px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); margin: 0; }
fieldset legend { padding: 0 var(--sp-2); font-weight: 600; font-size: .92rem; }

.datetime-grid { display: grid; gap: var(--sp-3); }
@media (min-width: 540px) { .datetime-grid { grid-template-columns: 1fr 1fr; } }

.form-actions {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
  margin-top: var(--sp-2);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 15px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--r);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 500;
  font-size: .92rem;
  line-height: 1.4;
  transition: border-color var(--t-fast) ease, background var(--t-fast) ease;
}
.checkbox-row:hover { border-color: var(--primary); background: var(--primary-tint); }
.checkbox-row input[type=checkbox] { width: 19px; height: 19px; flex: 0 0 19px; margin: 1px 0 0; accent-color: var(--primary); cursor: pointer; }
.checkbox-row a { color: var(--primary); font-weight: 600; }

.choice-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  min-height: 36px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: .88rem;
  cursor: pointer;
  user-select: none;
  line-height: 1.1;
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease, color var(--t-fast) ease;
}
.chip--btn { font-family: inherit; border: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.is-selected, .chip:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; }

.inline-form { display: inline; margin: 0; }

/* --------------------------------------------------------------------------
   9. TYPOGRAPHY HELPERS
   -------------------------------------------------------------------------- */
.eyebrow {
  display: block;
  color: var(--primary);
  font-weight: 700;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  margin: 0 0 var(--sp-2);
}
.muted, .text-muted { color: var(--text-muted); }
.lead { font-size: 1.02rem; max-width: 62ch; color: var(--text-muted); }
.plain-link { color: inherit; text-decoration: none; }
.plain-link:hover { text-decoration: none; }

/* --------------------------------------------------------------------------
   10. PAGE HEADERS
   -------------------------------------------------------------------------- */
.page-header {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-5);
}
.page-header .eyebrow { margin: 0; font-size: .68rem; }
.page-header h1 { margin: 0; letter-spacing: -.02em; }
@media (min-width: 768px) {
  .page-header { flex-direction: row; align-items: flex-end; justify-content: space-between; }
}
.page-header__title { display: flex; align-items: center; gap: var(--sp-3); }

.section-heading {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-5) 0 var(--sp-3);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
}
.section-heading .muted { font-size: .88rem; font-weight: 400; }

/* --------------------------------------------------------------------------
   11. ALERTS
   -------------------------------------------------------------------------- */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  border: 1.5px solid;
  font-size: .92rem;
}
.alert p { margin: 0; }
.alert + .alert { margin-top: var(--sp-2); }
.alert-danger  { border-color: rgba(192,57,43,.4);  background: var(--danger-lt);  color: var(--danger); }
.alert-success { border-color: rgba(39,174,96,.4);  background: var(--success-lt); color: var(--success); }
.alert-info    { border-color: rgba(92,138,106,.4); background: var(--primary-lt); color: var(--primary-dk); }
.alert-warning { border-color: rgba(212,134,10,.4); background: var(--warning-lt); color: var(--warning); }

.flash-message {
  padding: var(--sp-3) var(--sp-4);
  background: var(--success-lt);
  color: var(--success);
  border-left: 4px solid var(--success);
  border-radius: var(--r);
  font-weight: 600;
  margin-bottom: var(--sp-4);
  animation: slideDown .28s var(--ease);
}
@keyframes slideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }

/* --------------------------------------------------------------------------
   12. BADGES & STATUS CHIPS
   -------------------------------------------------------------------------- */
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--r-pill);
  font-size: .68rem;
  font-weight: 800;
  line-height: 1;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
  border: 0;
  text-transform: capitalize;
  letter-spacing: .03em;
}
.status-badge--active   { background: #DCFCE7; color: #15803D; }
.status-badge--paused   { background: #FEF3C7; color: #D97706; }
.status-badge--achieved { background: #DBEAFE; color: #1D4ED8; }
.status-badge--archived { background: #F1F5F9; color: #64748B; }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: var(--r-pill);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .03em;
  border: 1px solid;
  white-space: nowrap;
}
.status-pill--scheduled   { background: var(--primary-tint); color: var(--primary-dk);  border-color: rgba(92,138,106,.25); }
.status-pill--completed   { background: #DCFCE7;             color: #15803D;            border-color: rgba(21,128,61,.2); }
.status-pill--cancelled   { background: var(--danger-lt);    color: var(--danger);      border-color: rgba(192,57,43,.2); }
.status-pill--rescheduled { background: var(--warning-lt);   color: var(--warning);     border-color: rgba(212,134,10,.2); }
.status-pill--noshow      { background: var(--surface-3);    color: var(--text-muted);  border-color: var(--border); }

.badge-today {
  display: inline-block;
  padding: 2px 9px;
  background: var(--success);
  color: #fff;
  border-radius: var(--r-pill);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.outcome-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.outcome-chip { padding: 4px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill); font-size: .78rem; font-weight: 600; }
.outcome-chip--success  { background: #DCFCE7; color: #15803D; border-color: rgba(21,128,61,.2); }
.outcome-chip--partial  { background: var(--warning-lt); color: var(--warning); border-color: rgba(212,134,10,.2); }
.outcome-chip--struggled{ background: var(--danger-lt);  color: var(--danger);  border-color: rgba(192,57,43,.2); }

.tag-chip { display: inline-flex; align-items: center; padding: 3px 11px; border-radius: var(--r-pill); background: var(--primary-lt); color: var(--primary-dk); font-size: .72rem; font-weight: 600; }

/* --------------------------------------------------------------------------
   13. AVATAR
   -------------------------------------------------------------------------- */
.avatar {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dk));
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
}
.avatar--xs  { width: 28px; height: 28px; flex: 0 0 28px; font-size: .78rem; }
.avatar--sm  { width: 40px; height: 40px; flex: 0 0 40px; font-size: .95rem; }
.avatar--org { background: linear-gradient(135deg, #7c3aed, #4f46e5); }

/* --------------------------------------------------------------------------
   14. DATA TABLE
   -------------------------------------------------------------------------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table thead th {
  text-align: left;
  padding: 12px 16px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td { padding: 15px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--t-fast) ease; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr.is-today { background: rgba(39,174,96,.05); }
.data-table tbody tr.row-status-cancelled .cell-strong { text-decoration: line-through; color: var(--text-muted); }

.cell-strong { font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.cell-sub { color: var(--text-muted); font-size: .8rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
.cell-child { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.th-actions, .td-actions { width: 1%; white-space: nowrap; text-align: right; }
.td-actions .btn { box-shadow: none; }

@media (max-width: 720px) {
  .table-wrap { background: transparent; border: 0; box-shadow: none; }
  .data-table thead { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
  .data-table tbody { display: grid; gap: var(--sp-3); }
  .data-table tbody tr { display: grid; gap: 6px; padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
  .data-table tbody tr.is-today { border-left: 4px solid var(--success); }
  .data-table tbody td { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); padding: 3px 0; border-bottom: 0; }
  .data-table tbody td::before { content: attr(data-label); color: var(--text-muted); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; flex-shrink: 0; }
  .data-table tbody td[data-label="Date & time"] { flex-direction: column; align-items: flex-start; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
  .data-table tbody td[data-label="Date & time"]::before { display: none; }
  .td-actions { justify-content: flex-end; padding-top: 6px; border-top: 1px solid var(--border); margin-top: 2px; }
  .td-actions::before { display: none; }
}

/* --------------------------------------------------------------------------
   15. CARD GRIDS & ROW LAYOUTS
   -------------------------------------------------------------------------- */
.card-grid { display: grid; gap: var(--sp-4); }
@media (min-width: 720px) { .card-grid { grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); } }

.card-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; justify-content: space-between; }
.actions-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

.list-stack { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.list-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.list-row > :first-child { flex: 1; min-width: 0; }

/* --------------------------------------------------------------------------
   16. STAT CARDS
   -------------------------------------------------------------------------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
  margin: var(--sp-3) 0;
}
@media (min-width: 720px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.stat-card__label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.stat-card__value { font-size: 1.7rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; color: var(--text); }
.stat-card--primary { border-top: 3px solid var(--primary); }
.stat-card--primary .stat-card__value { color: var(--primary); }
.stat-card--success { border-top: 3px solid var(--success); }
.stat-card--success .stat-card__value { color: var(--success); }
.stat-card--warning { border-top: 3px solid var(--warning); }
.stat-card--warning .stat-card__value { color: var(--warning); }
.stat-card--muted   { border-top: 3px solid var(--border-strong); }
.stat-card--muted .stat-card__value { color: var(--text-muted); }

.detail-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3); margin: var(--sp-3) 0;
}
@media (min-width: 720px) { .detail-tiles { grid-template-columns: repeat(4, 1fr); } }
.detail-tile { padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-xs); display: flex; flex-direction: column; gap: 4px; }
.detail-tile__label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.detail-tile__value { font-size: 1.08rem; font-weight: 700; color: var(--text); text-transform: capitalize; line-height: 1.2; }
.detail-tile--primary { border-top: 3px solid var(--primary); }
.detail-tile--primary .detail-tile__value { color: var(--primary); }
.detail-tile--success { border-top: 3px solid var(--success); }
.detail-tile--success .detail-tile__value { color: var(--success); }
.detail-tile--warning { border-top: 3px solid var(--warning); }
.detail-tile--danger  { border-top: 3px solid var(--danger); }
.detail-tile--danger .detail-tile__value { color: var(--danger); }

/* --------------------------------------------------------------------------
   17. CHILD HEADER
   -------------------------------------------------------------------------- */
.child-header {
  display: flex; gap: var(--sp-3); align-items: center;
  padding: var(--sp-4);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); margin-bottom: var(--sp-4);
  box-shadow: var(--sh-sm);
}
.child-header__avatar { width: 56px; height: 56px; flex: 0 0 56px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-dk)); color: #fff; font-weight: 700; font-size: 1.4rem; line-height: 1; }
.child-header__body { flex: 1; min-width: 0; }
.child-header__name { margin: 0 0 3px; font-size: 1.1rem; font-weight: 600; }
.child-header__meta { margin: 0; color: var(--text-muted); font-size: .88rem; display: flex; gap: 8px; flex-wrap: wrap; }
.child-header__tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--sp-2); }

.child-card {
  display: flex; gap: var(--sp-4); align-items: flex-start;
  padding: var(--sp-5);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-sm);
  transition: box-shadow var(--t-fast) ease, border-color var(--t-fast) ease, transform var(--t-fast) ease;
}
.child-card:hover { box-shadow: var(--sh-md); border-color: var(--primary); transform: translateY(-2px); }
.child-card h2 { margin: 0 0 4px; font-size: 1.08rem; font-weight: 600; }
.child-card p  { margin: 0 0 var(--sp-3); color: var(--text-muted); }

/* --------------------------------------------------------------------------
   18. DETAILS LIST
   -------------------------------------------------------------------------- */
.details-list { display: grid; gap: var(--sp-2); margin: var(--sp-3) 0 0; }
.details-list dt { color: var(--text-muted); font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; }
.details-list dd { margin: 0 0 var(--sp-2); font-size: .95rem; }
@media (min-width: 640px) {
  .details-list { grid-template-columns: 170px 1fr; }
  .details-list dd { margin: 0; }
  .details-list--block { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   19. TABS
   -------------------------------------------------------------------------- */
.tab-strip { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: var(--sp-2); scrollbar-width: none; }
.tab-strip::-webkit-scrollbar { display: none; }
.tab-strip__item {
  flex: 0 0 auto;
  padding: 8px 18px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 500; font-size: .88rem; white-space: nowrap;
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease, color var(--t-fast) ease;
}
.tab-strip__item:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.tab-strip__item.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab-strip__item.is-active:hover { color: #fff; }

/* --------------------------------------------------------------------------
   20. MESSAGES
   -------------------------------------------------------------------------- */
.message-list { display: flex; flex-direction: column; gap: var(--sp-2); }

.message-thread-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-decoration: none; color: var(--text);
  box-shadow: var(--sh-xs);
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease, transform var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.message-thread-link:hover { background: var(--surface-2); border-color: var(--primary); transform: translateY(-2px); text-decoration: none; color: var(--text); box-shadow: var(--sh-sm); }
.message-thread-link.is-unread { border-left: 3px solid var(--primary); background: var(--primary-tint); }
.message-thread-link__body { min-width: 0; }
.message-thread-link__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.message-thread-link__head strong { font-size: .96rem; font-weight: 600; }
.message-thread-link__time { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }
.message-thread-link__sub { font-size: .8rem; color: var(--text-muted); margin: 2px 0; }
.message-thread-link__preview { font-size: .86rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-thread-link.is-unread .message-thread-link__preview { font-weight: 600; color: var(--text); }
.message-thread-link__badge { align-self: center; min-width: 20px; height: 20px; padding: 0 6px; background: var(--primary); color: #fff; border-radius: var(--r-pill); font-size: .68rem; font-weight: 800; display: grid; place-items: center; }

.message-page .message-list { gap: var(--sp-2); display: flex; flex-direction: column; }
.message-bubble { max-width: 78%; padding: 12px 16px; border-radius: 20px; box-shadow: var(--sh-xs); }
.message-bubble p { margin: 0; white-space: pre-wrap; line-height: 1.6; }
.message-bubble small { display: block; margin-top: 5px; color: var(--text-muted); font-size: .7rem; }
.message-bubble--mine { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.message-bubble--mine small { color: rgba(255,255,255,.75); }
.message-bubble--theirs { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 5px; }
.message-compose { position: sticky; bottom: 80px; }

/* --------------------------------------------------------------------------
   21. AUTH SHELL
   -------------------------------------------------------------------------- */
.auth-shell { width: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4) 0 var(--sp-5); }
@media (min-width: 720px) { .auth-shell { padding: var(--sp-6) 0; } }

.auth-shell__back { align-self: flex-start; color: var(--text-muted); font-size: .86rem; font-weight: 500; text-decoration: none; padding: 5px 10px; margin-left: -10px; border-radius: var(--r); transition: color var(--t-fast) ease, background var(--t-fast) ease; }
.auth-shell__back:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.auth-shell__footer { text-align: center; margin-top: var(--sp-3); }
.auth-shell__footer p { margin: 0; font-size: .82rem; }
.auth-shell__footer a { color: var(--text-muted); }
.auth-shell__footer a:hover { color: var(--primary); }

.auth-card-pro {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: 0 2px 4px rgba(30,41,59,.04), 0 24px 60px rgba(30,41,59,.12);
  overflow: hidden;
}
.auth-card-pro__head {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(160deg, var(--primary-tint), var(--surface));
  text-align: center;
}
.auth-card-pro__brand { display: inline-flex; flex-direction: column; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.auth-card-pro__brand:hover { text-decoration: none; color: var(--text); }
.auth-card-pro__logo { width: 72px; height: 72px; object-fit: contain; border-radius: 18px; }
.auth-card-pro__brandtext { display: flex; flex-direction: column; gap: 2px; line-height: 1.1; }
.auth-card-pro__brandname { font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; letter-spacing: -.01em; }
.auth-card-pro__brandtag { font-size: .74rem; color: var(--text-muted); font-weight: 400; }
.auth-card-pro__body { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.auth-card-pro__title { margin: 0; font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; text-align: center; letter-spacing: -.01em; }
.auth-card-pro__subtitle { margin: 0; text-align: center; color: var(--text-muted); font-size: .93rem; }
.auth-card-pro__body .eyebrow { text-align: center; }
.auth-card-pro__divider { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-faint); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; margin: var(--sp-1) 0; }
.auth-card-pro__divider::before, .auth-card-pro__divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-card-pro__link, .auth-card-pro__signup { margin: 0; text-align: center; font-size: .91rem; }
.auth-card-pro__signup { color: var(--text-muted); }
.auth-card-pro__strong-link { font-weight: 700; color: var(--primary); }
.auth-card-pro__body .alert { margin: 0; font-size: .9rem; }

.otp-input { font-family: var(--font-mono); font-size: 1.4rem; letter-spacing: .4em; text-align: center; }

/* --------------------------------------------------------------------------
   22. LANDING PAGE
   -------------------------------------------------------------------------- */
.landing { max-width: 1040px; margin: 0 auto; padding: var(--sp-4) var(--sp-3); }
.landing__hero { text-align: center; padding: var(--sp-7) var(--sp-3) var(--sp-5); }
.landing__logo { width: 120px; height: 120px; object-fit: contain; display: block; margin: 0 auto var(--sp-4); border-radius: 24px; }
.landing__hero h1 { font-family: var(--font-display); font-size: clamp(2.2rem,1.4rem + 2.5vw,3.5rem); margin: 0; letter-spacing: -.02em; font-weight: 400; }
.landing__tagline { font-size: 1.1rem; color: var(--primary); font-weight: 600; margin: var(--sp-2) 0 var(--sp-3); }
.landing__hero .lead { margin: 0 auto; max-width: 52ch; font-size: 1.02rem; }
.landing__choose { text-align: center; margin: var(--sp-6) 0 var(--sp-3); font-size: 1rem; color: var(--text-muted); font-weight: 500; }
.landing__login { text-align: center; margin: var(--sp-5) 0 var(--sp-4); color: var(--text-muted); font-size: .92rem; }
.landing__login a { font-weight: 700; color: var(--primary); }

.landing__cards { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; margin: 0 auto; padding: 0 var(--sp-3); }
@media (min-width: 720px) { .landing__cards { grid-template-columns: repeat(3, 1fr); } }

.role-card {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-4);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-sm);
  color: var(--text); text-decoration: none;
  transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) ease, border-color var(--t-base) ease;
}
.role-card:hover { transform: translateY(-5px); box-shadow: var(--sh-lg); border-color: var(--primary); color: var(--text); text-decoration: none; }
.role-card__icon { font-size: 2.2rem; line-height: 1; }
.role-card h3 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.role-card p { color: var(--text-muted); margin: 0; flex: 1; font-size: .93rem; }
.role-card__cta { color: var(--primary); font-weight: 700; font-size: .9rem; margin-top: var(--sp-3); }
.role-card--accent { border-color: rgba(124,58,237,.2); }
.role-card--accent:hover { border-color: #7c3aed; }
.role-card--accent .role-card__cta { color: #7c3aed; }
.role-card--accent2 { border-color: rgba(39,174,96,.2); }
.role-card--accent2:hover { border-color: var(--success); }
.role-card--accent2 .role-card__cta { color: var(--success); }

/* --------------------------------------------------------------------------
   23. ORG CHOICE + JOIN
   -------------------------------------------------------------------------- */
.org-choice-grid { display: grid; gap: var(--sp-3); }
.org-choice-card { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-xs); color: var(--text); text-decoration: none; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) ease, border-color var(--t-fast) ease; }
.org-choice-card:hover { transform: translateY(-2px); box-shadow: var(--sh-sm); border-color: var(--primary); text-decoration: none; color: var(--text); }
.org-choice-card__icon { font-size: 1.8rem; line-height: 1; }
.org-choice-card h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.org-choice-card p { margin: 0; color: var(--text-muted); font-size: .9rem; }
.org-choice-card__cta { color: var(--primary); font-weight: 700; font-size: .9rem; margin-top: var(--sp-2); }

/* --------------------------------------------------------------------------
   24. REQUEST & INVITE PANELS
   -------------------------------------------------------------------------- */
.request-panel { display: grid; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid rgba(92,138,106,.25); border-radius: var(--r-lg); background: linear-gradient(135deg, rgba(92,138,106,.06), rgba(201,162,39,.04)); }
.invite-panel { border-color: rgba(92,138,106,.3); background: linear-gradient(135deg, rgba(92,138,106,.08), rgba(201,162,39,.05)); }
.request-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.request-panel__head h2 { margin: 0; }
.request-list { display: grid; gap: var(--sp-3); }

.request-card { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-xs); }
.request-card.invite-card { align-items: center; }
.request-card h3 { margin: 0 0 4px; font-weight: 600; }
.request-card p { margin-top: 5px; }
.request-card__head { display: flex; align-items: center; gap: var(--sp-3); }
.request-card__action button { width: 100%; }
.request-card__reject summary { cursor: pointer; list-style: none; text-align: center; }
.request-card__reject summary::-webkit-details-marker { display: none; }

.inline-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) {
  .request-card, .request-panel__head { display: grid; }
  .request-card .btn, .inline-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .inline-actions .btn { width: 100%; }
}

/* --------------------------------------------------------------------------
   25. SETTINGS — INVITE CODES
   -------------------------------------------------------------------------- */
.therapist-code-card--pro { display: grid; gap: var(--sp-3); padding: var(--sp-5); background: linear-gradient(135deg, var(--primary-tint), var(--surface)); border: 2px dashed var(--primary); border-radius: var(--r-lg); margin-bottom: var(--sp-4); }
.therapist-code-card--pro .therapist-code-card__head .eyebrow { margin: 0; }
.therapist-code-card--pro .therapist-code-card__head p.muted { margin: 4px 0 0; font-size: .9rem; }
.therapist-code-card--pro .therapist-code-card__body { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.therapist-code-card--pro code { flex: 1; min-width: 0; display: block; padding: 12px 18px; background: #fff; border: 1px solid var(--border); border-radius: var(--r); font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700; letter-spacing: .12em; color: var(--primary-dk); text-align: center; }
.code-row { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.code-row code { flex: 1; min-width: 0; }
.code-row .muted { min-width: 120px; font-size: .88rem; }
.js-tcode { word-break: break-all; }

/* --------------------------------------------------------------------------
   26. PERMISSION TABLE
   -------------------------------------------------------------------------- */
.permission-table { display: grid; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.permission-table__head { display: grid; grid-template-columns: 1fr 90px 90px; padding: 10px var(--sp-3); background: var(--surface-3); color: var(--text-muted); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.permission-table__head span:nth-child(n+2) { text-align: center; }
.permission-table__row { display: grid; grid-template-columns: 1fr 90px 90px; align-items: center; padding: 11px var(--sp-3); border-top: 1px solid var(--border); }
.permission-table__label { font-weight: 500; }
.permission-table__cell { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; padding: 6px; border-radius: var(--r); cursor: pointer; user-select: none; background: transparent; border: 1px solid transparent; transition: background var(--t-fast) ease; }
.permission-table__cell:hover { background: var(--surface-2); border-color: var(--border); }
.permission-table__cell input { margin: 0; width: 17px; height: 17px; accent-color: var(--primary); }
.permission-table__cell span { font-size: .84rem; color: var(--text-muted); }
.permission-table__cell:has(input:checked) span { color: var(--primary); font-weight: 700; }

/* --------------------------------------------------------------------------
   27. INVITE MODE CHOOSER
   -------------------------------------------------------------------------- */
.invite-mode-grid { display: grid; gap: var(--sp-3); margin-bottom: var(--sp-3); }
@media (min-width: 560px) { .invite-mode-grid { grid-template-columns: 1fr 1fr; } }
.invite-mode-option { display: grid; grid-template-rows: auto auto auto; gap: 6px; padding: var(--sp-4); border: 2px solid var(--border); border-radius: var(--r-lg); background: var(--surface); cursor: pointer; transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease, transform var(--t-fast) ease; position: relative; }
.invite-mode-option input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.invite-mode-option:hover { border-color: var(--primary); transform: translateY(-1px); }
.invite-mode-option.is-selected { border-color: var(--primary); background: var(--primary-tint); box-shadow: 0 0 0 3px var(--primary-lt); }
.invite-mode-option__icon { font-size: 1.7rem; line-height: 1; }
.invite-mode-option__title { font-weight: 700; font-size: 1rem; color: var(--text); }
.invite-mode-option__sub { font-size: .83rem; color: var(--text-muted); line-height: 1.4; }
.invite-mode-fields { display: grid; gap: var(--sp-3); }

/* --------------------------------------------------------------------------
   28. PERMISSION LIST
   -------------------------------------------------------------------------- */
.permission-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.permission-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); }
.permission-list__type { font-weight: 600; }
.permission-list__level { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--primary); }

.invite-summary { padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); }

/* --------------------------------------------------------------------------
   29. CONFIRMATION MODAL
   -------------------------------------------------------------------------- */
.confirm-modal-backdrop { position: fixed; inset: 0; background: rgba(30,41,59,.6); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); animation: fadeIn var(--t-fast) ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.confirm-modal { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-lg); max-width: 480px; width: 100%; overflow: hidden; animation: modalUp var(--t-slow) var(--ease); }
@keyframes modalUp { from { transform: translateY(14px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.confirm-modal__head { padding: var(--sp-4); background: var(--danger-lt); border-bottom: 1px solid rgba(192,57,43,.2); }
.confirm-modal__head h2 { margin: 0; color: var(--danger); font-size: 1.05rem; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.confirm-modal__body { padding: var(--sp-4); display: grid; gap: var(--sp-3); }
.confirm-modal__body p { margin: 0; line-height: 1.6; }
.confirm-modal__warning-list { margin: 0; padding: var(--sp-3); background: var(--warning-lt); border-left: 4px solid var(--warning); border-radius: var(--r); list-style: none; }
.confirm-modal__warning-list li { padding: 4px 0; font-size: .9rem; }
.confirm-modal__actions { display: flex; gap: var(--sp-3); padding: var(--sp-4); border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.confirm-modal__actions .btn { flex: 1; min-width: 0; }

/* --------------------------------------------------------------------------
   30. DAILY TASKS / KIDS COLUMNS
   -------------------------------------------------------------------------- */
.kids-columns { display: grid; gap: var(--sp-3); }
@media (min-width: 720px)  { .kids-columns { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .kids-columns { grid-template-columns: repeat(3, 1fr); } }

.kid-column { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-sm); overflow: hidden; display: flex; flex-direction: column; }
.kid-column__head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.kid-column__avatar { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; background: var(--kid-color, var(--primary)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; }
.kid-column__name { margin: 0; font-size: 1rem; font-weight: 600; }
.kid-column__list { flex: 1; padding: var(--sp-1) 0; }
.kid-task-row { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); transition: background var(--t-fast) ease; }
.kid-task-row:last-child { border-bottom: 0; }
.kid-task-row:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.kid-task-row__check { width: 20px; height: 20px; border: 2px solid var(--border-strong); border-radius: 50%; flex: 0 0 20px; margin-top: 2px; transition: border-color var(--t-fast) ease; }
.kid-task-row:hover .kid-task-row__check { border-color: var(--primary); }
.kid-task-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kid-task-row__title { font-size: .95rem; font-weight: 500; }
.kid-task-row__desc { color: var(--text-muted); font-size: .84rem; }
.kid-task-row__assigned { color: var(--text-faint); font-size: .76rem; margin-top: 3px; }
.kid-task-row__arrow { color: var(--text-faint); font-size: 1.3rem; line-height: 1; margin-top: 2px; }

.todo-overview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin-bottom: var(--sp-4); }
@media (max-width: 640px) { .todo-overview-grid { grid-template-columns: 1fr; } }
.todo-summary-card { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.todo-summary-card__icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--primary-lt); font-size: 1.15rem; }
.todo-summary-card strong { display: block; font-size: 1.4rem; line-height: 1.1; font-weight: 700; }
.todo-summary-card span:last-child { display: block; color: var(--text-muted); font-size: .86rem; }

/* --------------------------------------------------------------------------
   31. NUMBERED STEPS
   -------------------------------------------------------------------------- */
.numbered-steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-3); }
.numbered-steps li { counter-increment: step; position: relative; padding: var(--sp-4) var(--sp-4) var(--sp-4) 62px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-xs); }
.numbered-steps li::before { content: counter(step); position: absolute; left: var(--sp-4); top: var(--sp-4); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; font-size: .9rem; box-shadow: 0 0 0 4px var(--primary-lt); }

/* --------------------------------------------------------------------------
   32. INFO CALLOUT
   -------------------------------------------------------------------------- */
.info-callout { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-3) var(--sp-4); }
.info-callout > summary { cursor: pointer; font-weight: 600; color: var(--text); list-style: none; padding: 0; }
.info-callout > summary::-webkit-details-marker { display: none; }
.info-callout > summary::before { content: "▸ "; color: var(--text-muted); margin-right: 4px; }
.info-callout[open] > summary::before { content: "▾ "; }
.info-callout > p { margin: var(--sp-2) 0 0; font-size: .91rem; }

/* --------------------------------------------------------------------------
   33. QR / BACKUP CODES
   -------------------------------------------------------------------------- */
.qr-wrap { display: flex; justify-content: center; margin: var(--sp-3) 0; }
.qr-code { width: min(260px,100%); padding: 12px; background: #fff; border-radius: var(--r); border: 1px solid var(--border); aspect-ratio: 1; display: grid; place-items: center; }

.backup-code-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); margin: var(--sp-3) 0 0; }
@media (min-width: 480px) { .backup-code-grid { grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); } }
.backup-code-grid code { padding: 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); font-family: var(--font-mono); font-size: .96rem; letter-spacing: .06em; text-align: center; font-weight: 700; color: var(--text); display: block; }
.code-box { padding: var(--sp-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); font-family: var(--font-mono); }

/* --------------------------------------------------------------------------
   34. MISC COMPONENTS
   -------------------------------------------------------------------------- */
.empty-state { text-align: center; padding: var(--sp-7) var(--sp-4); }
.empty-state h2 { margin: 0 0 var(--sp-2); font-size: 1.1rem; font-weight: 600; }
.empty-state p { margin: 0 0 var(--sp-3); }

.danger-zone { border-color: rgba(192,57,43,.35); }
.pinned-section { border-color: var(--primary); }

.strategy-card { margin-top: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.permission-row { padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }

.summary-line { margin: var(--sp-3) 0 0; padding: 10px 14px; background: var(--primary-tint); border: 1px solid rgba(92,138,106,.25); border-radius: var(--r); color: var(--primary-dk); font-weight: 500; min-height: 22px; }
.summary-line:empty { display: none; }

.wizard-step:not(.is-active) { display: none; }
.progress { height: 4px; background: var(--border); border-radius: var(--r-pill); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--primary); width: 0; transition: width .35s var(--ease); }

.join-code-card { border: 2px dashed var(--primary); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); background: linear-gradient(135deg, var(--primary-tint), var(--surface)); }
.join-code-card__body { margin-top: var(--sp-3); display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.join-code-card__code { flex: 1; min-width: 0; padding: 12px 18px; background: #fff; border: 1px solid var(--border); border-radius: var(--r); font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700; letter-spacing: .12em; color: var(--primary-dk); text-align: center; }

.therapist-row-expand { display: block; margin-top: 6px; padding: var(--sp-3); background: var(--surface-2); border-radius: var(--r); border: 1px solid var(--border); }
.therapist-row-expand p { margin: 0 0 5px; font-size: .86rem; }
.therapist-row-expand p:last-child { margin: 0; }

/* --------------------------------------------------------------------------
   35. PRINT
   -------------------------------------------------------------------------- */
@media print {
  .bottom-nav, .topbar-actions, .topbar-select,
  .actions-row, .td-actions, .th-actions, .form-actions { display: none !important; }
  .data-table tbody tr:hover { background: transparent; }
  .app-shell { padding: 0; }
}

/* --------------------------------------------------------------------------
   36. DETAILS LIST & LABEL REFINEMENTS
   -------------------------------------------------------------------------- */
.details-list dt,
.form-label,
.profile-label,
.info-label {
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.details-list dd,
.profile-value,
.info-value {
  color: var(--text);
  font-size: .95rem;
  font-weight: 400;
  line-height: 1.65;
}

.details-list--block dt { margin-top: var(--sp-3); }
.details-list--block dt:first-child { margin-top: 0; }

/* --------------------------------------------------------------------------
   37. GOAL / STATUS ACTIONS
   -------------------------------------------------------------------------- */
.action-row--wrap,
.goal-status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}
.goal-status-actions form { margin: 0; }

/* --------------------------------------------------------------------------
   38. UNREAD BADGE / NAV
   -------------------------------------------------------------------------- */
.bottom-nav__item { position: relative; }
.bottom-nav__label { line-height: 1.1; }
.nav-unread-badge {
  position: absolute;
  top: 6px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: .65rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
}
.bottom-nav__item.is-active .nav-unread-badge { box-shadow: 0 0 0 2px var(--primary); }

/* --------------------------------------------------------------------------
   39. FILTER ROW
   -------------------------------------------------------------------------- */
.filter-row { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.filter-row label { font-size: .86rem; color: var(--text-muted); font-weight: 500; }
.filter-row select { width: auto; min-width: 140px; }

/* --------------------------------------------------------------------------
   40. PAGE LOAD ANIMATION
   -------------------------------------------------------------------------- */
.page-stack {
  animation: pageFadeIn .22s ease both;
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   41. DARK MODE ADJUSTMENTS
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  .details-list dt, .form-label, .profile-label, .info-label { color: var(--text-muted); }
  .status-badge--active   { background: rgba(39,174,96,.18);  color: #6EE7B7; }
  .status-badge--paused   { background: rgba(212,134,10,.18); color: #FCD34D; }
  .status-badge--achieved { background: rgba(59,130,246,.18); color: #93C5FD; }
  .status-badge--archived { background: rgba(148,163,184,.15); color: #94A3B8; }
  .therapist-code-card--pro code,
  .join-code-card__code { background: var(--surface-2); }
}

/* --------------------------------------------------------------------------
   42. RESPONSIVE TWEAKS
   -------------------------------------------------------------------------- */
@media (max-width: 639px) {
  .details-list { gap: 4px; }
  .details-list dd { margin-bottom: 14px; }
  .details-card { padding: var(--sp-4); }
}
