/* ============================================================================
   ScopeTrail client dashboard — layout + components
   Depends on ../assets/base.css for tokens, reset and primitives.
   ----------------------------------------------------------------------------
   Dashboard-only visual tokens are re-pointed on `body.dash` below: a cleaner,
   near-neutral off-white in place of the warm beige, crisper borders, tighter
   radii and near-invisible shadows. Dark mode (handled in base.css at a higher
   specificity) is intentionally left untouched.
   ============================================================================ */

body.dash{
  /* Surfaces — near-neutral, a trace of warmth, no wash */
  --bg:#f6f6f4;
  --surface:#ffffff;
  --surface-2:#f1f1ee;

  /* Ink — stronger near-black, plain neutral grey for support text */
  --ink:#151513;
  --ink-soft:#565651;
  --ink-faint:#7c7c76;

  /* Borders — light but genuinely visible */
  --border:rgba(21,21,19,0.10);
  --border-strong:rgba(21,21,19,0.17);
  --line-soft:rgba(21,21,19,0.06);

  /* Orange — reserved for outcomes, active states, small highlights */
  --accent:#d9542f;
  --accent-strong:#bf4522;
  --accent-tint:#fbeadf;
  --accent-ink:#a53c1c;

  /* Attention — amber, used sparingly */
  --warn:#c07c12;
  --warn-ink:#7c5205;
  --warn-tint:#fbf1dd;

  /* Radii — 14–16px cards, not pill-like */
  --radius-md:15px;
  --radius-sm:11px;

  /* Shadows — extremely subtle */
  --shadow-sm:0 1px 2px rgba(21,21,19,.05);
  --shadow-md:0 16px 40px -24px rgba(21,21,19,.30);
}

/* The landing-page grain overlay reads as haze on a data screen. */
body.dash::before{display:none;}

/* ---------------------------------------------------------------------------
   Shell width
   --------------------------------------------------------------------------- */
.dash-shell{
  max-width:1280px;
  margin:0 auto;
  padding:0 clamp(16px,4vw,32px);
}

/* ---------------------------------------------------------------------------
   Top navigation — compact, sticky, quiet
   --------------------------------------------------------------------------- */
.dash-topbar{
  position:sticky;
  top:0;
  z-index:20;
  background:var(--surface);
  border-bottom:1px solid var(--border-strong);
}
.dash-topbar__inner{
  max-width:1280px;
  margin:0 auto;
  padding:9px clamp(16px,4vw,32px);
  display:flex;
  align-items:center;
  gap:16px;
  flex-wrap:wrap;
}
.dash-topbar__identity{
  display:flex;
  align-items:center;
  gap:11px;
  min-width:0;
  flex:1 1 auto;
}
.dash-topbar__divider{
  width:1px;
  height:20px;
  background:var(--border-strong);
  flex:0 0 auto;
}
.dash-topbar__practice{
  font-weight:600;
  font-size:.9rem;
  color:var(--ink);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.dash-topbar__tools{
  display:flex;
  align-items:center;
  gap:10px;
  flex:0 0 auto;
}
.dash-topbar__toggle{
  display:none;
  align-items:center;
  gap:8px;
  min-height:40px;
  padding:8px 14px;
  border-radius:999px;
  font:inherit;
  font-weight:600;
  font-size:.9rem;
  cursor:pointer;
  background:transparent;
  color:var(--ink);
  border:1px solid var(--border-strong);
}
.dash-topbar__toggle-bars,
.dash-topbar__toggle-bars::before,
.dash-topbar__toggle-bars::after{
  content:"";
  display:block;
  width:16px;
  height:2px;
  background:currentColor;
  border-radius:2px;
}
.dash-topbar__toggle-bars{position:relative;}
.dash-topbar__toggle-bars::before{position:absolute;top:-5px;}
.dash-topbar__toggle-bars::after{position:absolute;top:5px;}

/* Form field (date range) — label inline, no shouty caps */
.field{display:flex;align-items:center;gap:8px;}
.field__label{
  font-size:.8rem;
  font-weight:500;
  letter-spacing:0;
  text-transform:none;
  color:var(--ink-faint);
  white-space:nowrap;
}
.field__control{
  font:inherit;
  font-size:.875rem;
  font-weight:500;
  color:var(--ink);
  background:var(--surface);
  border:1px solid var(--border-strong);
  border-radius:var(--radius-sm);
  padding:8px 32px 8px 12px;
  min-height:38px;
  cursor:pointer;
  appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%237c7c76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 8px center;
}
.field__control:hover{border-color:var(--ink);}
.field__control:focus-visible{outline:2px solid var(--accent-strong);outline-offset:2px;}

/* User menu */
.usermenu{position:relative;}
.usermenu__button{
  display:flex;
  align-items:center;
  gap:8px;
  font:inherit;
  font-weight:600;
  font-size:.875rem;
  color:var(--ink);
  background:var(--surface);
  border:1px solid var(--border-strong);
  border-radius:999px;
  padding:5px 12px 5px 5px;
  min-height:38px;
  cursor:pointer;
}
.usermenu__button:hover{border-color:var(--ink);}
.usermenu__avatar{
  display:grid;
  place-items:center;
  width:26px;
  height:26px;
  border-radius:50%;
  background:var(--surface-2);
  color:var(--ink-soft);
  font-size:.7rem;
  font-weight:600;
  letter-spacing:.02em;
}
.usermenu__chevron{width:15px;height:15px;color:var(--ink-faint);}
.usermenu__panel{
  position:absolute;
  right:0;
  top:calc(100% + 8px);
  min-width:236px;
  background:var(--surface);
  border:1px solid var(--border-strong);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-md);
  padding:8px;
  z-index:30;
}
.usermenu__meta{
  margin:0;
  padding:8px 10px 10px;
  font-size:.82rem;
  color:var(--ink-soft);
  border-bottom:1px solid var(--border);
}
.usermenu__muted{color:var(--ink-faint);}
.usermenu__item{
  display:block;
  width:100%;
  text-align:left;
  font:inherit;
  font-size:.875rem;
  color:var(--ink);
  background:transparent;
  border:0;
  border-radius:var(--radius-sm);
  padding:10px;
  min-height:44px;
  cursor:pointer;
}
.usermenu__item:hover:not(:disabled){background:var(--surface-2);}
.usermenu__item:disabled{color:var(--ink-faint);cursor:not-allowed;}
a.usermenu__item{text-decoration:none;}
a.usermenu__item:hover{background:var(--surface-2);}

/* ---------------------------------------------------------------------------
   Page structure
   --------------------------------------------------------------------------- */
.dash-main{padding:clamp(20px,3.5vw,32px) 0 56px;}

.dash-footer{
  border-top:1px solid var(--border);
  padding:22px 0 44px;
}
.dash-footer p{
  margin:0;
  font-size:.8rem;
  color:var(--ink-faint);
  line-height:1.5;
}

/* Page introduction — one compact row on desktop */
.page-intro{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:20px;
  flex-wrap:wrap;
  margin-bottom:clamp(16px,3vw,24px);
}
.page-intro__text{max-width:56ch;}
.page-intro__heading{
  margin:0;
  font-family:var(--font-display);
  font-weight:500;
  font-optical-sizing:auto;
  font-size:clamp(1.5rem,2.6vw,1.9rem);
  line-height:1.12;
  letter-spacing:-.015em;
  color:var(--ink);
}
.page-intro__lead{
  margin:5px 0 0;
  font-size:.95rem;
  color:var(--ink-soft);
}
.page-intro__aside{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:8px;
  padding-top:3px;
}

/* Status chip — only ever states a fact we hold (mode / selected range) */
.status-chip{
  display:inline-flex;
  align-items:center;
  gap:7px;
  padding:5px 11px;
  border-radius:999px;
  border:1px solid var(--border-strong);
  background:var(--surface);
  font-size:.78rem;
  font-weight:600;
  color:var(--ink-soft);
  white-space:nowrap;
}
.status-chip__dot{
  width:7px;height:7px;border-radius:50%;
  background:var(--ink-faint);
  flex:0 0 auto;
}
.status-chip--demo{
  color:var(--accent-ink);
  border-color:var(--accent-tint);
  background:var(--accent-tint);
}
.status-chip--demo .status-chip__dot{background:var(--accent);}

/* Notices — compact, one line of guidance */
.page-notices:has(.info-banner:not([hidden])){margin:0 0 16px;}
.info-banner{
  display:flex;
  align-items:flex-start;
  gap:10px;
  margin:14px 0 0;
  padding:11px 14px;
  background:var(--surface);
  border:1px solid var(--border-strong);
  border-left:3px solid var(--accent);
  border-radius:var(--radius-sm);
  font-size:.86rem;
  color:var(--ink-soft);
  line-height:1.5;
}
.info-banner--demo{
  background:var(--accent-tint);
  border-color:var(--accent-tint);
  border-left-color:var(--accent);
  color:var(--accent-ink);
}
.info-banner__icon{
  flex:0 0 auto;
  display:grid;
  place-items:center;
  width:17px;
  height:17px;
  margin-top:1px;
  border-radius:50%;
  background:currentColor;
  color:var(--surface);
  font-size:.68rem;
  font-weight:700;
  font-style:normal;
}
.info-banner__link{
  color:inherit;
  font-weight:600;
  text-decoration:underline;
  text-underline-offset:2px;
  white-space:nowrap;
}

/* Cards / sections */
.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  padding:clamp(15px,2vw,19px);
  box-shadow:var(--shadow-sm);
  margin-bottom:16px;
}
.card:last-child{margin-bottom:0;}
.section-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:14px;
}
.section-heading{
  margin:0;
  font-family:var(--font-body);
  font-weight:600;
  font-size:1.02rem;
  letter-spacing:-.005em;
  color:var(--ink);
}
.metrics .section-heading{margin-bottom:14px;}
.section-sub{margin:0;font-size:.83rem;color:var(--ink-faint);}

/* ---------------------------------------------------------------------------
   Primary metrics — even 5-up grid, sans-serif figures
   --------------------------------------------------------------------------- */
.metric-grid{
  list-style:none;
  margin:0;
  padding:0;
  display:grid;
  grid-template-columns:repeat(5,1fr);
  gap:10px;
}
.metric-card{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-height:104px;
  padding:13px 14px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
}
.metric-card--headline{
  border-color:var(--accent-tint);
  box-shadow:inset 3px 0 0 var(--accent);
}
.metric-card__label{
  font-size:.8rem;
  font-weight:500;
  letter-spacing:0;
  text-transform:none;
  color:var(--ink-soft);
  line-height:1.3;
}
.metric-card__value{
  font-family:var(--font-body);
  font-weight:600;
  font-size:1.7rem;
  line-height:1.05;
  letter-spacing:-.02em;
  color:var(--ink);
  font-variant-numeric:tabular-nums;
}
.metric-card--headline .metric-card__value{color:var(--accent-strong);}
.metric-card__note{font-size:.76rem;color:var(--ink-faint);line-height:1.4;margin-top:auto;padding-top:2px;}

/* ---------------------------------------------------------------------------
   Recovery funnel — compact left-to-right conversion journey
   Colour is never the only signal: name + value + % text carry the meaning.
   --------------------------------------------------------------------------- */
.funnel{
  list-style:none;
  margin:0;
  padding:0;
  display:grid;
  grid-template-columns:repeat(5,1fr);
  gap:8px;
}
.funnel__stage{
  position:relative;
  display:flex;
  flex-direction:column;
  gap:7px;
  padding:12px 13px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
}
.funnel__stage:not(:last-child)::after{
  content:"";
  position:absolute;
  right:-6px;
  top:50%;
  width:9px;
  height:9px;
  border-top:1.5px solid var(--ink-faint);
  border-right:1.5px solid var(--ink-faint);
  transform:translateY(-50%) rotate(45deg);
  z-index:1;
}
.funnel__name{
  margin:0;
  font-size:.8rem;
  font-weight:600;
  color:var(--ink-soft);
}
.funnel__value{
  margin:0;
  font-family:var(--font-body);
  font-weight:600;
  font-size:1.4rem;
  line-height:1;
  letter-spacing:-.02em;
  color:var(--ink);
  font-variant-numeric:tabular-nums;
}
.funnel__stage:last-child .funnel__value{color:var(--accent-strong);}
.funnel__track{
  height:6px;
  background:var(--surface-2);
  border-radius:999px;
  overflow:hidden;
}
.funnel__fill{
  display:block;
  height:100%;
  width:var(--pct,0%);
  background:var(--accent);
  border-radius:999px;
  min-width:2px;
}
.funnel__stage:last-child .funnel__fill{background:var(--accent-strong);}
.funnel__rate{
  margin:0;
  font-size:.74rem;
  color:var(--ink-faint);
  line-height:1.35;
}
.funnel__rate b{color:var(--ink-soft);font-weight:600;}
.funnel__rate--muted{color:var(--ink-faint);}
.funnel__empty{
  margin:12px 0 0;
  font-size:.83rem;
  color:var(--ink-faint);
}

/* ---------------------------------------------------------------------------
   Two-column section — recent recoveries (wide) + attention (narrow)
   --------------------------------------------------------------------------- */
.dash-columns{
  display:grid;
  grid-template-columns:minmax(0,2fr) minmax(0,1fr);
  gap:16px;
  align-items:start;
  margin-bottom:16px;
}
.dash-columns .card{margin-bottom:0;}

/* ---------------------------------------------------------------------------
   Recent recoveries table -> responsive cards
   --------------------------------------------------------------------------- */
.table-scroll{overflow-x:auto;}
.recoveries__table{
  width:100%;
  border-collapse:collapse;
  font-size:.84rem;
  min-width:600px;
}
.recoveries__table th,
.recoveries__table td{
  text-align:left;
  padding:10px 10px;
  border-bottom:1px solid var(--line-soft);
  vertical-align:top;
}
.recoveries__table th:first-child,
.recoveries__table td:first-child{padding-left:2px;}
.recoveries__table td.num,
.recoveries__table td[data-label="Appointment"],
.recoveries__table td[data-label="Last activity"]{white-space:nowrap;}
.recoveries__table th{
  font-size:.72rem;
  font-weight:600;
  letter-spacing:.02em;
  text-transform:none;
  color:var(--ink-faint);
  border-bottom-color:var(--border);
}
.recoveries__table tbody tr:hover{background:var(--surface-2);}
.recoveries__table tr:last-child td{border-bottom:0;}
.recoveries__table td.num{font-variant-numeric:tabular-nums;white-space:nowrap;}
.recoveries__caller{
  font:inherit;
  font-weight:600;
  font-size:.86rem;
  color:var(--ink);
  background:transparent;
  border:0;
  padding:0;
  cursor:pointer;
  text-align:left;
  display:inline-flex;
  align-items:center;
  gap:6px;
  white-space:nowrap;
}
.recoveries__caller:hover{color:var(--accent-strong);}
.recoveries__caller::after{
  content:"";
  width:6px;height:6px;
  border-right:1.5px solid currentColor;
  border-top:1.5px solid currentColor;
  transform:rotate(45deg);
  opacity:.55;
}
.recoveries__phone{display:block;font-weight:400;font-size:.76rem;color:var(--ink-faint);margin-top:2px;white-space:nowrap;}
.recoveries__muted{color:var(--ink-faint);}

/* Status badge — glyph + label, tone as a secondary cue only */
.status-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:3px 9px;
  border-radius:999px;
  font-size:.76rem;
  font-weight:600;
  line-height:1.3;
  border:1px solid var(--border-strong);
  background:var(--surface);
  color:var(--ink-soft);
  white-space:nowrap;
}
.status-badge__glyph{font-size:.72rem;line-height:1;}
.status-badge[data-tone="positive"]{background:var(--accent-tint);border-color:var(--accent-tint);color:var(--accent-ink);}
.status-badge[data-tone="active"]{background:var(--surface-2);border-color:var(--border-strong);color:var(--ink-soft);}
.status-badge[data-tone="attention"]{background:var(--warn-tint);border-color:rgba(192,124,18,.32);color:var(--warn-ink);}
.status-badge[data-tone="neutral"]{background:var(--surface-2);color:var(--ink-soft);}
.status-badge[data-tone="muted"]{background:transparent;color:var(--ink-faint);}

/* Card layout on narrow screens */
@media (max-width:820px){
  .recoveries__table{min-width:0;}
  .recoveries__table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);}
  .recoveries__table tr{
    display:block;
    border:1px solid var(--border);
    border-radius:var(--radius-sm);
    padding:6px 4px;
    margin-bottom:10px;
  }
  .recoveries__table tr:last-child{margin-bottom:0;}
  .recoveries__table tbody tr:hover{background:none;}
  .recoveries__table td{
    display:flex;
    flex-direction:column;
    align-items:flex-start;
    gap:3px;
    border-bottom:1px solid var(--line-soft);
    padding:9px 14px;
    white-space:normal;
  }
  .recoveries__table td:last-child{border-bottom:0;}
  .recoveries__table td::before{
    content:attr(data-label);
    font-size:.68rem;
    font-weight:600;
    letter-spacing:.02em;
    text-transform:none;
    color:var(--ink-faint);
  }
  .recoveries__table td.num{white-space:normal;}
  .recoveries__table td.cell-caller{
    background:var(--surface-2);
    border-radius:var(--radius-sm) var(--radius-sm) 0 0;
    padding:12px 14px;
  }
}

/* ---------------------------------------------------------------------------
   Attention required
   --------------------------------------------------------------------------- */
.attention-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:10px;}
.attention-item{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:13px 14px;
  background:var(--surface);
  border:1px solid var(--border);
  border-left:3px solid var(--warn);
  border-radius:var(--radius-sm);
}
.attention-item__text{min-width:0;}
.attention-item__title{margin:0;font-weight:600;font-size:.9rem;color:var(--ink);}
.attention-item__meta{margin:3px 0 0;font-size:.8rem;color:var(--ink-soft);}
.attention-item__note{margin:4px 0 0;font-size:.8rem;color:var(--ink-faint);line-height:1.45;}
.attention-item__actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center;}
.attention-item.is-resolved{border-left-color:var(--accent);opacity:.72;}
.attention-item__done{
  font-size:.8rem;
  font-weight:600;
  color:var(--accent-ink);
  display:inline-flex;
  align-items:center;
  gap:6px;
}

/* ---------------------------------------------------------------------------
   Empty / loading / error states — compact, no big blank areas
   --------------------------------------------------------------------------- */
.state{
  padding:22px 18px;
  color:var(--ink-soft);
}
.state--compact{
  min-height:168px;
  display:flex;
  flex-direction:column;
  justify-content:center;
}
.state__title{
  margin:0 0 5px;
  font-family:var(--font-body);
  font-weight:600;
  font-size:.95rem;
  color:var(--ink);
}
.state__body{margin:0;max-width:46ch;font-size:.86rem;line-height:1.5;}
.state__actions{margin-top:14px;}

/* Error / no-access states stay centred and a little more generous */
.card > .state:not(.state--compact){text-align:center;padding:clamp(22px,4vw,36px) 20px;}
.card > .state:not(.state--compact) .state__body{margin-inline:auto;}

.skeleton{
  background:var(--surface-2);
  border-radius:var(--radius-sm);
  position:relative;
  overflow:hidden;
}
.skeleton--line{height:12px;margin:8px 0;}
.skeleton--metric{height:112px;}
.skeleton--funnel{height:96px;}
.skeleton--row{height:40px;margin:8px 0;}
@media (prefers-reduced-motion:no-preference){
  .skeleton::after{
    content:"";
    position:absolute;
    inset:0;
    transform:translateX(-100%);
    background:linear-gradient(90deg,transparent,rgba(255,255,255,.55),transparent);
    animation:skeleton-sweep 1.4s ease-in-out infinite;
  }
  @media (prefers-color-scheme:dark){
    :root:not([data-theme="light"]) .skeleton::after{background:linear-gradient(90deg,transparent,rgba(255,255,255,.06),transparent);}
  }
  @keyframes skeleton-sweep{100%{transform:translateX(100%);}}
}

/* ---------------------------------------------------------------------------
   Activity panel (drawer)
   --------------------------------------------------------------------------- */
.drawer-overlay{
  position:fixed;
  inset:0;
  background:rgba(21,21,19,.42);
  z-index:40;
}
.drawer{
  position:fixed;
  top:0;
  right:0;
  height:100%;
  width:min(440px,100%);
  background:var(--surface);
  border-left:1px solid var(--border-strong);
  box-shadow:var(--shadow-md);
  z-index:50;
  display:flex;
  flex-direction:column;
  outline:none;
}
@media (prefers-reduced-motion:no-preference){
  .drawer{animation:drawer-in .28s var(--ease);}
  @keyframes drawer-in{from{transform:translateX(24px);opacity:0;}to{transform:none;opacity:1;}}
}
.drawer__head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  padding:18px 20px 14px;
  border-bottom:1px solid var(--border);
}
.drawer__eyebrow{
  margin:0 0 4px;
  font-size:.7rem;
  font-weight:600;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--ink-faint);
}
.drawer__title{
  margin:0;
  font-family:var(--font-body);
  font-weight:600;
  font-size:1.1rem;
  letter-spacing:-.01em;
  color:var(--ink);
}
.drawer__subtitle{margin:4px 0 0;font-size:.82rem;color:var(--ink-soft);font-variant-numeric:tabular-nums;}
.drawer__close{
  flex:0 0 auto;
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  border-radius:50%;
  border:1px solid var(--border-strong);
  background:transparent;
  color:var(--ink);
  cursor:pointer;
}
.drawer__close:hover{background:var(--surface-2);}
.drawer__close svg{width:18px;height:18px;}
.drawer__body{flex:1 1 auto;overflow-y:auto;padding:18px 20px;}
.drawer__foot{
  margin:0;
  padding:12px 20px 16px;
  border-top:1px solid var(--border);
  font-size:.75rem;
  color:var(--ink-faint);
}

/* Timeline */
.timeline{list-style:none;margin:0;padding:0;}
.timeline__item{
  position:relative;
  padding:0 0 18px 24px;
  border-left:2px solid var(--border);
}
.timeline__item:last-child{border-left-color:transparent;padding-bottom:0;}
.timeline__item::before{
  content:"";
  position:absolute;
  left:-7px;
  top:2px;
  width:12px;
  height:12px;
  border-radius:50%;
  background:var(--surface);
  border:2px solid var(--border-strong);
}
.timeline__item.is-key::before{background:var(--accent);border-color:var(--accent);}
.timeline__time{
  font-size:.76rem;
  color:var(--ink-faint);
  font-variant-numeric:tabular-nums;
}
.timeline__label{margin:2px 0 0;font-weight:600;font-size:.88rem;color:var(--ink);}
.timeline__status{margin:2px 0 0;font-size:.8rem;color:var(--ink-soft);}

/* Secure SMS conversation — message bodies are visible only through the
   authenticated, practice-scoped dashboard. */
.conversation{
  margin-top:22px;
  padding-top:18px;
  border-top:1px solid var(--border);
}
.conversation__heading{
  margin:0 0 12px;
  font:600 .95rem/1.3 var(--font-body);
  color:var(--ink);
}
.conversation__list{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  flex-direction:column;
  gap:9px;
}
.message-bubble{
  width:fit-content;
  max-width:88%;
  padding:9px 11px 7px;
  border:1px solid var(--border);
  border-radius:12px;
}
.message-bubble--in{align-self:flex-start;background:var(--surface-2);}
.message-bubble--out{align-self:flex-end;background:var(--accent-tint);border-color:var(--accent-tint);}
.message-bubble__body{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;font-size:.86rem;line-height:1.45;color:var(--ink);}
.message-bubble__meta{margin:5px 0 0;font-size:.68rem;color:var(--ink-faint);text-transform:capitalize;}
.conversation__empty,
.conversation__notice{margin:0;font-size:.82rem;line-height:1.5;color:var(--ink-faint);}
.conversation__notice{padding:10px 12px;background:var(--surface-2);border-radius:var(--radius-sm);}
.conversation__form{margin-top:14px;display:flex;flex-direction:column;gap:8px;}
.conversation__label{font-size:.78rem;font-weight:600;color:var(--ink-soft);}
.conversation__input{
  width:100%;
  resize:vertical;
  min-height:82px;
  padding:10px 11px;
  font:inherit;
  font-size:.86rem;
  line-height:1.45;
  color:var(--ink);
  background:var(--surface);
  border:1px solid var(--border-strong);
  border-radius:var(--radius-sm);
}
.conversation__input:focus-visible{outline:2px solid var(--accent-strong);outline-offset:2px;}
.conversation__form-row{display:flex;justify-content:space-between;align-items:center;gap:12px;}
.conversation__count{font-size:.7rem;color:var(--ink-faint);font-variant-numeric:tabular-nums;}
.conversation__feedback{min-height:1.2em;margin:0;font-size:.78rem;color:var(--accent-ink);}
.conversation__safety{margin:0;font-size:.7rem;line-height:1.45;color:var(--ink-faint);}

/* ---------------------------------------------------------------------------
   Responsive: funnel + columns collapse, then topbar
   --------------------------------------------------------------------------- */
@media (max-width:1024px){
  .dash-columns{grid-template-columns:1fr;}
  .metric-grid{grid-template-columns:repeat(2,1fr);}
}

@media (max-width:900px){
  .funnel{grid-template-columns:1fr;gap:8px;}
  .funnel__stage{
    flex-direction:row;
    align-items:center;
    flex-wrap:wrap;
    gap:4px 12px;
  }
  .funnel__stage:not(:last-child)::after{
    right:auto;
    left:19px;
    top:auto;
    bottom:-6px;
    transform:rotate(135deg);
  }
  .funnel__name{flex:0 0 96px;}
  .funnel__value{flex:0 0 auto;order:-1;min-width:44px;text-align:right;}
  .funnel__track{flex:1 1 100%;order:3;}
  .funnel__rate{flex:1 1 100%;order:4;}
}

@media (max-width:820px){
  .dash-topbar__toggle{display:inline-flex;}
  .dash-topbar__tools{
    flex-basis:100%;
    order:3;
    flex-direction:column;
    align-items:stretch;
    gap:12px;
    padding-top:4px;
  }
  .dash-topbar__tools[hidden]{display:none!important;}
  .field{flex-direction:column;align-items:stretch;gap:5px;}
  .field__control,
  .usermenu__button{width:100%;}
  .usermenu__button{justify-content:flex-start;}
  .usermenu__panel{position:static;width:100%;min-width:0;box-shadow:none;margin-top:8px;}
}

@media (max-width:560px){
  .metric-grid{grid-template-columns:1fr;}
  .metric-card{min-height:0;}
}

@media (max-width:420px){
  .dash-topbar__divider,
  .dash-topbar__practice{display:none;}
  .page-intro__aside{padding-top:0;}
}
