/**
 * DriveAI Component Library — components.css
 * ============================================
 * Depends on: design-system.css, layout.css
 *
 * Naming convention: BEM with da- prefix
 *   Block:    .da-[component]
 *   Element:  .da-[component]__[element]
 *   Modifier: .da-[component]--[variant]
 *
 * Why BEM over utility-first here:
 *   - Flask/Jinja2 templates already use Bootstrap class strings.
 *     Pure utility-first (Tailwind-style) would require a build step
 *     that doesn't exist in this stack.
 *   - BEM + design tokens gives semantic class names that Jinja2
 *     conditionals can target cleanly without long class lists.
 *   - Bootstrap utilities (mt-4, d-flex, etc.) remain usable for
 *     layout micro-adjustments inside BEM components.
 *
 * Contents:
 *   1.  Buttons
 *   2.  Cards
 *   3.  Theme Toggle
 *   4.  Badges & Status Chips
 *   5.  Alerts / Flash Messages
 *   6.  Forms
 *   7.  Navigation Pills (sub-nav)
 *   8.  Stat Cards (dashboard KPIs)
 *   9.  Feature Cards (marketing)
 *  10.  Pricing Cards
 *  11.  How-It-Works Steps
 *  12.  Stats Banner (social proof strip)
 *  13.  Diagnostic Cards
 *  14.  Vehicle Cards
 *  15.  CTA Banner
 *  16.  Loading States
 *  17.  Dividers
 *  18.  Chat Interface
 *  19.  Diagnostic Result Cards (chat inline)
 */


/* ============================================================
   1. BUTTONS
   ============================================================ */
.da-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2_5) var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  line-height: 1;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-all);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.da-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.da-btn:disabled,
.da-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.da-btn--primary {
  background: var(--gradient-brand);
  color: #ffffff;
  border-color: transparent;
}

.da-btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-brand);
  color: #ffffff;
}

.da-btn--primary:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Secondary / outlined */
.da-btn--secondary {
  background: transparent;
  color: var(--text-brand);
  border-color: var(--border-brand);
}

.da-btn--secondary:hover {
  background-color: var(--bg-brand-subtle);
  color: var(--text-brand);
  transform: translateY(-1px);
}

/* Ghost */
.da-btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.da-btn--ghost:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* Ghost buttons are borderless on a bare surface, so the ring is the ONLY
   focus signal — give them a visible border too (B2C-UI-2-FIX-1 M4:
   destructive icon-only ghosts like the delete control must not rely on a
   sub-threshold ring). --border-focus is 3.90:1+ light / 3.69:1+ dark. */
.da-btn--ghost:focus-visible {
  border-color: var(--border-focus);
}

/* Danger */
.da-btn--danger {
  background-color: var(--palette-danger-500);
  color: #ffffff;
  border-color: transparent;
}

.da-btn--danger:hover {
  background-color: var(--palette-danger-700);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Light — for use on dark/gradient backgrounds */
.da-btn--light {
  background-color: #ffffff;
  color: var(--palette-brand-700);
  border-color: transparent;
}

.da-btn--light:hover {
  background-color: var(--palette-brand-50);
  color: var(--palette-brand-800);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Outline-light — for use on dark/gradient backgrounds */
.da-btn--outline-light {
  background: transparent;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.55);
}

.da-btn--outline-light:hover {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: #ffffff;
  color: #ffffff;
}

/* Sizes */
.da-btn--sm {
  font-size: var(--text-xs);
  padding: var(--space-1_5) var(--space-3);
  border-radius: var(--radius-md);
}

.da-btn--lg {
  font-size: var(--text-base);
  padding: var(--space-3_5) var(--space-7);
  border-radius: var(--radius-xl);
}

.da-btn--xl {
  font-size: var(--text-lg);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-2xl);
}

/* Full-width */
.da-btn--block {
  width: 100%;
}

/* Loading state (JS adds this class) */
.da-btn--loading {
  pointer-events: none;
  opacity: 0.75;
}

.da-btn--loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: da-spin 0.7s linear infinite;
}

@keyframes da-spin {
  to { transform: rotate(360deg); }
}

/* Button group */
.da-btn-group {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.da-btn-group--center {
  justify-content: center;
}


/* ============================================================
   2. CARDS
   ============================================================ */
.da-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--duration-slow) var(--ease-default),
              transform var(--duration-slow) var(--ease-default),
              border-color var(--duration-normal) var(--ease-default);
}

.da-card--hoverable:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-brand);
}

.da-card--flat {
  box-shadow: none;
  border: 1px solid var(--border-subtle);
}

.da-card--elevated {
  box-shadow: var(--shadow-md);
  border: none;
}

.da-card--brand {
  background: var(--gradient-brand);
  color: #ffffff;
  border: none;
}

.da-card--diagnostic {
  background: var(--gradient-diagnostic);
  color: #ffffff;
  border: none;
}

/* Card sub-elements */
.da-card__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.da-card--brand .da-card__header,
.da-card--diagnostic .da-card__header {
  border-bottom-color: rgba(255, 255, 255, 0.15);
}

.da-card__title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.da-card--brand .da-card__title,
.da-card--diagnostic .da-card__title {
  color: #ffffff;
}

.da-card__body {
  padding: var(--space-6);
}

.da-card__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-secondary);
}


/* ============================================================
   2b. NOTICE / FINE-PRINT — legal & consent insets (FE-16)
   ============================================================ */

/* Reusable token-driven inset for fine-print legal/consent blocks
   (CCPA notice-at-collection, right-to-be-forgotten, do-not-sell).
   FE-16 root cause: .da-notice-collection had NO styling, so the
   notice rendered flush to its container edge. This gives every
   fine-print block consistent breathing room, a subtle surface, a
   gold accent rail, and relaxed leading for readability. Text uses
   --text-secondary on --bg-secondary (~7:1 contrast, exceeds WCAG AA). */
.da-notice-collection {
  padding: var(--space-4);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--border-gold);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.da-notice-collection > :first-child {
  margin-top: 0;
}

.da-notice-collection > :last-child {
  margin-bottom: 0;
}

.da-notice-collection p {
  margin: 0 0 var(--space-2);
  line-height: var(--leading-relaxed);
}

.da-notice-collection ul {
  margin: 0 0 var(--space-2);
  padding-left: var(--space-5);
  line-height: var(--leading-relaxed);
}

.da-notice-collection li {
  margin-bottom: var(--space-1);
}

/* Padded legal footer region inside an auth card. Hosts the full
   notice-at-collection inset once, with its own top divider and
   padding so the inset never sits flush to the card edges; the
   card's overflow:hidden + radius clips the bottom corners. */
.da-auth-legal {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-primary);
}

/* The notice is a closed <details> in the link row. Inline, so the closed
   row still reads as three links on one line; opened, the inset drops below
   the row, left-aligned instead of inheriting the row's centring. */
.da-auth-legal details,
.da-auth-legal summary {
  display: inline;
}

.da-auth-legal summary {
  cursor: pointer;
}

.da-auth-legal .da-notice-collection {
  margin-top: var(--space-3);
  text-align: start;
}

/* One-line consent shown in the Register state. The full notice lives
   once in the card's legal footer (.da-auth-legal), so the register
   form only needs a short pointer to it. */
.da-auth-consent {
  margin: 0 0 var(--space-4);
}


/* ============================================================
   3. THEME TOGGLE
   ============================================================ */
.da-theme-toggle {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: var(--space-1);
  gap: var(--space-px);
  flex-shrink: 0;
}

.da-theme-toggle__option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1_5) var(--space-3);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition-all);
  white-space: nowrap;
}

.da-theme-toggle__option:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.da-theme-toggle__option.active,
.da-theme-toggle__option[aria-checked="true"] {
  background-color: var(--bg-brand);
  color: #ffffff;
}

/* Icon-only compact version for tight navbars */
.da-theme-toggle--compact .da-theme-toggle__option {
  padding: var(--space-1_5);
  width: 32px;
  height: 32px;
}

.da-theme-toggle--compact .da-theme-toggle__label {
  display: none;
}


/* ============================================================
   4. BADGES & STATUS CHIPS
   ============================================================ */
.da-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-0_5) var(--space-2_5);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-full);
  line-height: 1.4;
  white-space: nowrap;
}

.da-badge--brand   { background-color: var(--bg-brand-subtle); color: var(--text-brand); }
.da-badge--success { background-color: var(--bg-success-subtle); color: var(--text-success); }
.da-badge--warning { background-color: var(--bg-warning-subtle); color: var(--text-warning); }
.da-badge--danger  { background-color: var(--bg-danger-subtle); color: var(--text-danger); }
.da-badge--muted   { background-color: var(--bg-tertiary); color: var(--text-muted); }

.da-badge--solid-brand   { background-color: var(--palette-brand-500); color: #ffffff; }
.da-badge--solid-success { background-color: var(--palette-success-500); color: #ffffff; }
.da-badge--solid-warning { background-color: var(--palette-warning-500); color: #ffffff; }
.da-badge--solid-danger  { background-color: var(--palette-danger-500); color: #ffffff; }

/* Status dot */
.da-badge::before {
  display: none;
}
.da-badge--dot::before {
  display: block;
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}


/* ============================================================
   5. ALERTS / FLASH MESSAGES
   ============================================================ */
.da-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-xl);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  position: relative;
}

.da-alert__icon {
  flex-shrink: 0;
  font-size: var(--text-lg);
  line-height: 1;
}

.da-alert__body {
  flex: 1;
}

.da-alert__title {
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-1);
}

.da-alert--success {
  background-color: var(--bg-success-subtle);
  border-color: var(--palette-success-300);
  color: var(--text-success);
}

.da-alert--warning {
  background-color: var(--bg-warning-subtle);
  border-color: var(--palette-warning-300);
  color: var(--text-warning);
}

.da-alert--danger {
  background-color: var(--bg-danger-subtle);
  border-color: var(--palette-danger-300);
  color: var(--text-danger);
}

.da-alert--info {
  background-color: var(--bg-accent-subtle);
  border-color: var(--palette-accent-300);
  color: var(--text-accent);
}

.da-alert .btn-close {
  flex-shrink: 0;
  margin-left: auto;
  align-self: center;
}


/* ============================================================
   6. FORMS
   ============================================================ */
.da-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1_5);
  margin-bottom: var(--space-5);
}

.da-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.da-label--required::after {
  content: ' *';
  color: var(--text-danger);
}

.da-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default),
              background-color var(--duration-normal) var(--ease-default);
  appearance: none;
  -webkit-appearance: none;
}

.da-input::placeholder {
  color: var(--text-muted);
}

.da-input:hover {
  border-color: var(--border-strong);
}

.da-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
}

.da-input--error {
  border-color: var(--palette-danger-500);
}

.da-input--error:focus {
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.25);
}

.da-input-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.da-input-error-msg {
  font-size: var(--text-xs);
  color: var(--text-danger);
  display: none;
}

.da-form-group--error .da-input-error-msg {
  display: block;
}

/* Input with icon */
.da-input-wrapper {
  position: relative;
}

.da-input-wrapper .da-input {
  padding-left: var(--space-10);
}

.da-input-wrapper .da-input-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: var(--text-base);
}

/* Password reveal toggle */
.da-input-wrapper--password .da-input {
  padding-right: var(--space-10);
}

.da-input-wrapper__action {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--text-base);
  display: flex;
  align-items: center;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}

.da-input-wrapper__action:hover {
  color: var(--text-secondary);
}

/* Select */
.da-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-lg);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-10);
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default);
}

.da-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
}

/* Auth divider (------ or ------) */
.da-auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-block: var(--space-5);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.da-auth-divider::before,
.da-auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--border-subtle);
}

/* OTP digit group — flex container for 6 digit inputs */
.da-otp-group {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  margin-block: var(--space-6);
}

/* OTP digit input — individual code character box */
.da-otp-input {
  width: 3rem;
  height: 3.5rem;
  text-align: center;
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default);
  appearance: none;
  -webkit-appearance: none;
}

.da-otp-input::placeholder {
  color: var(--text-muted);
}

.da-otp-input:hover {
  border-color: var(--border-strong);
}

.da-otp-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
}

.da-otp-input--filled {
  border-color: var(--border-brand);
}

/* Email display — inline row showing email address + change action */
.da-email-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.da-email-display__text {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.da-email-display__action {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-brand);
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--duration-normal) var(--ease-default);
}

.da-email-display__action:hover {
  color: var(--text-accent);
}

/* Auth state — multi-step form visibility toggling */
.da-auth-state {
  display: none;
}

.da-auth-state--active {
  display: block;
}

/* Resend link cooldown state */
.da-resend-link--disabled {
  pointer-events: none;
  opacity: 0.6;
}


/* ============================================================
   6b. ACCOUNT-TYPE TOGGLE + DATA/AI-LEARNING CONSENT
   Signup consent surface (W2B). The account-type toggle selects
   which document set + controls render (individual vs shop); the
   consent section gives the block real visual hierarchy — a titled
   region, REQUIRED vs OPTIONAL groups, and each control shown as a
   scannable short label with the full legal text tucked into an
   expandable detail (no more wall-of-text next to a checkbox).
   ============================================================ */

/* Segmented pill: "I'm signing up as [Individual] / [Auto shop]". */
.da-account-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  padding: var(--space-1);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.da-account-type-toggle__option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2_5) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
  transition: var(--transition-all);
}

.da-account-type-toggle__option:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

/* The radio itself is visually hidden; the label chrome shows state. */
.da-account-type-toggle__option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.da-account-type-toggle__option--active,
.da-account-type-toggle__option:has(input:checked) {
  background-color: var(--bg-brand);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.da-account-type-toggle__option:has(input:focus-visible) {
  box-shadow: var(--focus-ring);
}

/* Titled consent region. */
.da-consent-section {
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.da-consent-section__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.da-consent-section__icon {
  color: var(--text-secondary);
  font-size: var(--text-base);
}

.da-consent-section__title {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/* Draft/preview note (shop tier before LEGAL ratifies its copy). */
.da-consent-draft-note {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

/* REQUIRED vs OPTIONAL grouping. */
.da-consent-group + .da-consent-group {
  margin-top: var(--space-4);
}

.da-consent-group__label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/* One consent control row: checkbox + short label (+ expandable detail). */
.da-consent-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: var(--transition-all);
}

.da-consent-option + .da-consent-option {
  margin-top: var(--space-2);
}

.da-consent-option:hover {
  border-color: var(--border-strong);
}

.da-consent-option:has(input:checked) {
  border-color: var(--border-brand);
  background-color: var(--bg-brand-subtle);
}

.da-consent-option:has(input:focus-visible) {
  box-shadow: var(--focus-ring);
  border-color: var(--border-focus);
}

.da-consent-checkbox {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.1rem;
  accent-color: var(--bg-brand);
  cursor: pointer;
}

.da-consent-option__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.da-consent-option__label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  line-height: var(--leading-snug);
  cursor: pointer;
}

/* Info affordance on a consent label — the whole disclaimer, one tap away,
   with no prose in the row. `padding` (not a bare 16px glyph) is what gives it
   a 24x24 target: WCAG 2.5.8, and this control is reached from a phone. */
.da-consent-option__info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  margin-inline-start: var(--space-1);
  vertical-align: middle;
  color: var(--text-secondary);
  text-decoration: none;
  line-height: 1;
}

.da-consent-option__info:hover,
.da-consent-option__info:focus-visible {
  color: var(--text-primary);
}

.da-consent-option__links {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: var(--leading-snug);
}

/* Expandable full legal copy — collapsed by default so the row stays scannable;
   the verbatim text (hashed server-side) is one tap away. */
.da-consent-option__detail {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.da-consent-option__detail > summary {
  cursor: pointer;
  color: var(--text-brand);
  font-weight: var(--font-medium);
  list-style: none;
}

.da-consent-option__detail > summary::-webkit-details-marker {
  display: none;
}

.da-consent-option__detail > summary::before {
  content: '\203A';  /* › — rotates when open */
  display: inline-block;
  margin-right: var(--space-1);
  transition: var(--transition-transform);
}

.da-consent-option__detail[open] > summary::before {
  transform: rotate(90deg);
}

.da-consent-option__detail-text {
  display: block;
  margin-top: var(--space-1);
  line-height: var(--leading-relaxed);
}


/* ============================================================
   7. NAVIGATION PILLS (sub-nav / tab bar)
   ============================================================ */
.da-pills {
  display: flex;
  gap: var(--space-1);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-1);
  flex-wrap: wrap;
}

.da-pills__item {
  flex: 1;
}

.da-pills__link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: var(--transition-all);
  white-space: nowrap;
}

.da-pills__link:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.da-pills__link.active,
.da-pills__link[aria-current="page"] {
  background-color: var(--bg-primary);
  color: var(--text-brand);
  box-shadow: var(--shadow-xs);
  font-weight: var(--font-semibold);
}


/* ============================================================
   8. STAT CARDS (dashboard KPIs)
   ============================================================ */
.da-stat-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-slow) var(--ease-default),
              transform var(--duration-slow) var(--ease-default);
}

.da-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.da-stat-card__icon {
  font-size: 2rem;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl);
  background-color: var(--bg-brand-subtle);
  color: var(--text-brand);
  margin-bottom: var(--space-2);
}

.da-stat-card__value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: 1;
}

.da-stat-card__label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

/* Icon color variants */
.da-stat-card--brand  .da-stat-card__icon { background-color: var(--bg-brand-subtle);   color: var(--text-brand); }
.da-stat-card--accent .da-stat-card__icon { background-color: var(--bg-accent-subtle);  color: var(--text-accent); }
.da-stat-card--success .da-stat-card__icon { background-color: var(--bg-success-subtle); color: var(--text-success); }
.da-stat-card--warning .da-stat-card__icon{ background-color: var(--bg-warning-subtle); color: var(--text-warning); }
.da-stat-card--danger .da-stat-card__icon { background-color: var(--bg-danger-subtle);  color: var(--text-danger); }

/* The band must READ on the value itself, not only on the decorative icon
   chip (B2C-UI-2-FIX-1, a11y N4): the chip bg is 1.05–1.22:1 vs the card,
   near-invisible. Same semantic text ramps as the health scores (AA in
   both themes); brand/accent (unscored) stay primary ink — absence of data
   is not a status claim (CEO Guard 1). */
.da-stat-card--success .da-stat-card__value { color: var(--text-success); }
.da-stat-card--warning .da-stat-card__value { color: var(--text-warning); }
.da-stat-card--danger  .da-stat-card__value { color: var(--text-danger); }


/* ============================================================
   9. FEATURE CARDS (marketing page)
   ============================================================ */
.da-feature-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: box-shadow var(--duration-slow) var(--ease-default),
              transform var(--duration-slow) var(--ease-default),
              border-color var(--duration-normal) var(--ease-default);
}

.da-feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-brand);
}

.da-feature-card__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #ffffff;
  flex-shrink: 0;
}

.da-feature-card__title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.da-feature-card__body {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin: 0;
}

.da-feature-card__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.da-feature-card__list li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.da-feature-card__list li::before {
  content: '';
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%231e8449'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-size: contain;
  flex-shrink: 0;
}


/* ============================================================
   10. PRICING CARDS
   ============================================================ */
.da-pricing-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  position: relative;
  transition: box-shadow var(--duration-slow) var(--ease-default),
              transform var(--duration-slow) var(--ease-default);
}

.da-pricing-card--featured {
  border-color: var(--border-brand);
  border-width: 2px;
  box-shadow: var(--shadow-brand);
  transform: scale(1.02);
}

.da-pricing-card--featured:hover {
  transform: scale(1.02) translateY(-4px);
}

.da-pricing-card__badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
}

.da-pricing-card__tier {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-brand);
}

.da-pricing-card__price {
  display: flex;
  align-items: flex-end;
  gap: var(--space-1);
  line-height: 1;
}

.da-pricing-card__amount {
  font-size: var(--text-5xl);
  font-weight: var(--font-extrabold);
  color: var(--text-primary);
}

.da-pricing-card__period {
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding-bottom: var(--space-1_5);
}

.da-pricing-card__description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.da-pricing-card__divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
}

.da-pricing-card__features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
}

.da-pricing-card__feature {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.da-pricing-card__feature--included .da-pricing-card__feature-icon {
  color: var(--text-success);
}

.da-pricing-card__feature--excluded {
  color: var(--text-muted);
  text-decoration: line-through;
}


/* ============================================================
   10b. MARKETING LANE PRIMITIVES
   (dual-audience landing — feature list, inline price teaser,
    compact multi-tier plan row). Semantic-token driven so they
    flex across light / dark / B&W lock like every da- component.
   ============================================================ */

/* Checkmark feature list — the audience-lane value bullets. */
.da-feature-list {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.da-feature-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}

.da-feature-list li > i {
  flex-shrink: 0;
  margin-top: 0.15em;
}

/* Inline price teaser — a one-line "Free — $0 · Pro — $19/mo" strip. */
.da-pricing-inline {
  margin-top: var(--space-5);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.da-pricing-inline__free { color: var(--text-success); }
.da-pricing-inline__pro  { color: var(--text-primary); }
.da-pricing-inline__sep  { color: var(--text-muted); }

/* Compact multi-tier plan row — name + note on the left, price on the right. */
.da-plan-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) 0;
}

.da-plan-row__name {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.da-plan-row__note {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.da-plan-row__price {
  flex-shrink: 0;
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-brand);
  white-space: nowrap;
}

.da-plan-row__price small {
  font-size: var(--text-sm);
  font-weight: var(--font-normal);
  color: var(--text-muted);
}


/* ============================================================
   11. HOW-IT-WORKS STEPS
   ============================================================ */
.da-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
  position: relative;
}

/* Connector line between steps — desktop only */
@media (min-width: 768px) {
  .da-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 28px; /* center of the step number circle */
    right: calc(-50% + 28px);
    width: calc(100% - 56px);
    height: 2px;
    background: linear-gradient(90deg, var(--border-brand), var(--border-subtle));
  }
}

.da-step__number {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: #ffffff;
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
  z-index: 1;
}

.da-step__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  background-color: var(--bg-brand-subtle);
  color: var(--text-brand);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
}

.da-step__title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.da-step__body {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin: 0;
}


/* ============================================================
   12. STATS BANNER (social proof strip)
   ============================================================ */
.da-stats-banner {
  background: var(--gradient-diagnostic);
  border-radius: var(--radius-2xl);
  padding: var(--space-12) var(--space-8);
  color: #ffffff;
}

.da-stats-banner__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-8);
  text-align: center;
}

@media (min-width: 768px) {
  .da-stats-banner__grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.da-stats-banner__value {
  font-size: var(--text-4xl);
  font-weight: var(--font-extrabold);
  color: #ffffff;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.da-stats-banner__label {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.75);
}


/* ============================================================
   13. DIAGNOSTIC CARDS (app — diagnostic type selector)
   ============================================================ */
.da-diag-card {
  background: var(--gradient-diagnostic);
  color: #ffffff;
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  cursor: pointer;
  transition: transform var(--duration-slow) var(--ease-spring),
              box-shadow var(--duration-slow) var(--ease-default);
  text-decoration: none;
}

.da-diag-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(0, 96, 180, 0.35);
  color: #ffffff;
}

.da-diag-card__icon {
  font-size: 2.5rem;
  opacity: 0.9;
}

.da-diag-card__title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  margin: 0;
}

.da-diag-card__body {
  font-size: var(--text-sm);
  opacity: 0.8;
  line-height: var(--leading-relaxed);
  margin: 0;
}


/* ============================================================
   14. VEHICLE CARDS
   ============================================================ */
.da-vehicle-card {
  background: linear-gradient(135deg, var(--palette-accent-600) 0%, var(--palette-accent-300) 100%);
  color: #ffffff;
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: transform var(--duration-slow) var(--ease-spring),
              box-shadow var(--duration-slow) var(--ease-default);
}

.da-vehicle-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 150, 199, 0.35);
}

.da-vehicle-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}

.da-vehicle-card__name {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin: 0;
}

.da-vehicle-card__subtitle {
  font-size: var(--text-sm);
  opacity: 0.8;
}

.da-vehicle-card__meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.da-vehicle-card__meta-label {
  font-size: var(--text-xs);
  opacity: 0.7;
  margin-bottom: var(--space-0_5);
}

.da-vehicle-card__meta-value {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}


/* ============================================================
   15. CTA BANNER
   ============================================================ */
.da-cta-banner {
  background: var(--gradient-brand);
  border-radius: var(--radius-2xl);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  color: #ffffff;
}

.da-cta-banner__title {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-4);
}

.da-cta-banner__subtitle {
  font-size: var(--text-xl);
  opacity: 0.8;
  max-width: 560px;
  margin-inline: auto;
  margin-bottom: var(--space-8);
  line-height: var(--leading-relaxed);
}

@media (max-width: 639px) {
  .da-cta-banner__title { font-size: var(--text-3xl); }
  .da-cta-banner__subtitle { font-size: var(--text-base); }
}


/* ============================================================
   16. LOADING STATES
   ============================================================ */

/* Full-page overlay */
.da-loading-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--overlay-backdrop);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  z-index: var(--z-modal);
  color: #ffffff;
}

.da-loading-overlay.hidden {
  display: none;
}

.da-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: da-spin 0.75s linear infinite;
}

.da-spinner--brand {
  border-color: var(--bg-brand-subtle);
  border-top-color: var(--bg-brand);
}

/* Skeleton loader */
.da-skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--bg-tertiary) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  animation: da-shimmer 1.5s infinite;
}

@keyframes da-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ============================================================
   17. DIVIDERS
   ============================================================ */
.da-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin-block: var(--space-6);
}

.da-divider--strong {
  border-top-color: var(--border-default);
}

.da-divider--dashed {
  border-top-style: dashed;
}


/* ============================================================
   18. CHAT INTERFACE
   ============================================================ */

/* ── Shell ── */
.da-chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);   /* below navbar + footer */
  min-height: 400px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  overflow: hidden;
}

/* ── 3-column grid (desktop) ── */
.da-chat__columns {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;                 /* allow flex children to shrink */
}

/* ── Column 1: Sessions sidebar ── */
.da-chat__sidebar {
  width: 250px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
}

.da-chat__sidebar-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.da-chat__sidebar-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/* ── Session list (shared desktop + mobile) ── */
.da-chat__session-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
}

.da-chat__session-item {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition-colors);
}

.da-chat__session-item:hover {
  background-color: var(--bg-tertiary);
}

.da-chat__session-item--active {
  background-color: var(--bg-brand-subtle);
  border-left: 3px solid var(--border-brand);
}

.da-chat__session-vehicle-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.da-chat__session-timestamp {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-0_5);
}

/* ── Column 2: Main chat area ── */
.da-chat__main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* Load-bearing, same reason as `.da-chat__columns` above: a column flex item
     defaults to `min-height: auto`, i.e. it refuses to shrink below its
     content. Without this the island's own scroll containers cannot resolve a
     remaining height and push the column past the shell instead of scrolling
     inside it. */
  min-height: 0;
}

/* ── Full-bleed chat canvas under flag-ON (DTW-AUI W2-REALPAGE-FIX) ──
   The island owns everything below the header: full width, full height, no
   card border, no footer. The rolled-back build left it inside the 1280px
   content gutter as a rounded card with the marketing footer beneath it, which
   is the "floating in a void" half of the CEO's screenshot.

   NO MAGIC NUMBERS. The obvious spelling is `height: calc(100vh - 66px)`, and
   the 66 is a lie the moment the header wraps, the flash-message strip renders,
   or the type scale moves. `.da-page` is ALREADY `display:flex;
   flex-direction:column; min-height:100vh` and `.da-page__main` is ALREADY
   `flex: 1 1 auto` (layout.css), so the height that the header does not use is
   a quantity the layout can compute for itself. These rules only pass it down
   through the two wrappers that currently stop it — every one of them adds
   `min-block-size: 0`, without which a flex item refuses to shrink below its
   content and the shell grows the page a scrollbar instead of fitting it.

   SCOPED BY `:has()` TO PAGES THAT MOUNT AN ISLAND. The selector cannot match
   without `.da-chat--island` in the tree, and that class is emitted only
   inside chat.html's `should_render` branch — so flag-OFF, and every other
   page in the app, are untouched by construction rather than by care. */
/* THE SCROLLER NEEDS A BOUNDED CHAIN (island scroll-back fix).
   `.da-page` only sets `min-height: 100vh`, which is a floor and not a bound:
   with a flex column of content-sized children the page, the shell and the
   island all grow to the length of the transcript, the thread viewport never
   overflows, and the document scrolls instead of the thread (the viewport
   measured 7232px tall at 40 messages, scrollTop pinned at 0, composer 7000px
   down the page). Giving the page itself a definite block size lets the
   `min-block-size: 0` links below pass a REMAINDER down to the viewport, which
   is then the only box that scrolls. `dvh` follows the phone's collapsing
   toolbar; the `vh` line is the fallback; `min-block-size: 0` removes
   `.da-page`'s 100vh floor, which on a phone is taller than the visible area. */
body:has(.da-chat--island) {
  block-size: 100vh;
  block-size: 100dvh;
  min-block-size: 0;
}
body:has(.da-chat--island) .da-page__main {
  /* The gutter that would otherwise sit above and below the canvas. */
  padding-block: 0;
  display: flex;
  min-block-size: 0;
}

body:has(.da-chat--island) .da-page__main > .da-container {
  max-inline-size: none;
  padding-inline: 0;
  margin-inline: 0;
  display: flex;
  flex: 1 1 auto;
  min-block-size: 0;
}

/* base.html wraps `{% block content %}` in an unclassed div when the page is
   neither the shop nor the consumer shell, which /chat is not. It is a real
   link in the chain and has to carry the height like the rest. */
body:has(.da-chat--island) .da-page__main > .da-container > div {
  display: flex;
  flex: 1 1 auto;
  min-block-size: 0;
}

/* A marketing footer under a workspace is a different product. */
body:has(.da-chat--island) .da-footer {
  display: none;
}

.da-chat--island {
  /* Beats `.da-chat`'s `calc(100vh - 160px)`: the height now comes from the
     flex chain above, which knows what the header actually took. */
  block-size: auto;
  flex: 1 1 auto;
  min-block-size: 0;
  /* Edge-to-edge: a card border in the middle of a full-bleed workspace draws
     a box around nothing. The top border stays as the seam under the header. */
  border-radius: 0;
  border-inline: 0;
  border-block-end: 0;
}

/* ── The assistant-ui island's canvas (DTW-AUI W2-REALPAGE-FIX) ──
   THE RULE THAT DID NOT EXIST. `.da-chat__island` is written on the mount div
   in chat.html and matched NOTHING in any stylesheet, so the mount was a
   default flex item — `flex: 0 1 auto`, height auto — and sized to its
   content. On the real page that rendered the whole island as a ~300px strip
   at the top of a full-height shell, with the rest of the canvas dead white
   (docs/design/aui-overhaul/refs/ANTIPATTERN-real-page-collapse-2026-08-16.png).

   The island's own root is `aui:h-full` (`dt-island-layout` in App.tsx), and
   `height: 100%` against a parent whose height is `auto` computes to `auto` —
   so every height rule INSIDE the island was correct and inert. The chain was
   broken at exactly one link, and this is that link.

   It never surfaced in the component harness because the harness gives the
   mount a definite height of its own; the harness is an iteration tool, and
   acceptance is the assembled page. `tests/test_dtw_aui_island_height_chain.py`
   now derives this dependency from the stylesheets rather than asserting the
   symptom.

   Only ever present under flag-ON — the mount is inside
   `{% if aui_island.should_render %}` — so the legacy page is untouched. */
.da-chat__island {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.da-chat__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-6);
  scroll-behavior: smooth;
}

/* Placeholder */
.da-chat__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
}

.da-chat__placeholder-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
}

.da-chat__placeholder-text {
  font-size: var(--text-base);
  max-width: 300px;
}

/* B2C-UI-2 G5 — placeholder guidance (has-vehicles hint). The zero-vehicle
   branch carries no CTA of its own: the garage strip's first-run block owns
   the single primary action (B2C-UI-2-FIX-1 M3). */
.da-chat__placeholder-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 340px;
  margin-top: var(--space-2);
}

/* ── Message wrappers ── */
.da-chat__message {
  display: flex;
  margin-bottom: var(--space-4);
}

.da-chat__message--user {
  justify-content: flex-end;
}

.da-chat__message--assistant {
  justify-content: flex-start;
}

/* ── Bubbles ── */
.da-chat__bubble {
  max-width: 80%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.da-chat__bubble--user {
  background: var(--gradient-brand);
  color: var(--text-on-brand);
  border-bottom-right-radius: var(--radius-sm);
}

.da-chat__bubble--assistant {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: var(--radius-sm);
}

.da-chat__bubble-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-1);
  opacity: 0.8;
}

.da-chat__bubble--user .da-chat__bubble-label {
  color: rgba(255, 255, 255, 0.85);
}

.da-chat__bubble--assistant .da-chat__bubble-label {
  color: var(--text-secondary);
}

.da-chat__bubble-content {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

/* The sources line under an answer (chat-main.js renderAnswerSources):
   which DriveTrace source contributed, as the server set it. */
.da-chat__sources {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.da-chat__sources-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Markdown content inside assistant bubbles */
.da-chat__bubble-content p {
  margin: 0 0 var(--space-2) 0;
}

.da-chat__bubble-content p:last-child {
  margin-bottom: 0;
}

.da-chat__bubble-content ul,
.da-chat__bubble-content ol {
  margin: var(--space-2) 0;
  padding-left: var(--space-5);
}

.da-chat__bubble-content code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background-color: var(--bg-tertiary);
  padding: var(--space-0_5) var(--space-1);
  border-radius: var(--radius-sm);
}

.da-chat__bubble-content pre {
  background-color: var(--bg-tertiary);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: var(--space-2) 0;
}

.da-chat__bubble-content pre code {
  background: none;
  padding: 0;
}

/* ── Typing indicator ── */
.da-chat__typing {
  padding: 0 var(--space-6) var(--space-2);
}

.da-chat__typing-dots {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) 0;
}

.da-chat__typing-dots span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
  animation: da-chat-dot-bounce 1.4s ease-in-out infinite;
}

.da-chat__typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.da-chat__typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes da-chat-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Input bar (sticky bottom) ── */
.da-chat__input-bar {
  flex-shrink: 0;
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-secondary);
}

.da-chat__form {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.da-chat__input {
  flex: 1 1 auto;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: var(--space-2_5) var(--space-4);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition-all);
  outline: none;
}

.da-chat__input:focus {
  border-color: var(--border-brand);
  box-shadow: var(--focus-ring);
}

.da-chat__input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.da-chat__input::placeholder {
  color: var(--text-muted);
}

.da-chat__status {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
  min-height: 1em;
}

/* ── CHAT-COMPOSER: in-composer attach + voice affordances ── */
.da-chat__composer-btn {
  flex-shrink: 0;
  /* Mobile-web-first: >=44px touch target (WCAG 2.5.5 / iOS HIG). */
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  font-size: var(--text-lg);
  color: var(--text-secondary);
  border-radius: var(--radius-xl);
}

.da-chat__composer-btn:hover {
  color: var(--palette-brand-500);
}

.da-chat__composer-btn--recording {
  color: var(--palette-danger-500);
  animation: da-composer-rec-pulse 1.4s ease-in-out infinite;
}

@keyframes da-composer-rec-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  .da-chat__composer-btn--recording {
    animation: none;
  }
}

/* Send button: keeps the primary gradient (da-btn--primary) but is sized as a
   composer touch target so it matches the mic/attach buttons and meets the
   >=44px WCAG 2.5.5 / iOS-HIG minimum. Without this the icon-only submit
   button rendered ~34px tall (da-btn's text-sm + space-2_5 padding), shorter
   than its 44px siblings and hard to tap on a phone — the reported broken
   mobile send button. flex-shrink:0 keeps it from being squeezed on narrow
   viewports. Sizing only — color/background come from da-btn--primary. */
.da-chat__send-btn {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-2);
  font-size: var(--text-lg);
  border-radius: var(--radius-xl);
}

.da-chat__composer-status {
  font-size: var(--text-xs);
  color: var(--text-muted);
  min-height: 0;
}

.da-chat__composer-status:not(:empty) {
  margin-bottom: var(--space-2);
}

.da-chat__attach-strip {
  margin-bottom: var(--space-2);
  /* P0A: multiple chips (one per pending attachment) wrap in a row. */
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Explicit display forces override of the UA [hidden] rule — restore it. */
.da-chat__attach-strip[hidden] {
  display: none;
}

/* ── P0A "+" attach menu (one upload surface for the chat) ── */
.da-chat__attach-wrap {
  position: relative;
  flex-shrink: 0;
}

.da-chat__attach-menu {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 0;
  z-index: var(--z-dropdown);
  min-width: 240px;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.da-chat__attach-menu[hidden] {
  display: none;
}

.da-chat__attach-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  /* >=44px touch target (WCAG 2.5.5), matching the composer buttons. */
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}

.da-chat__attach-menu-item:hover,
.da-chat__attach-menu-item:focus-visible {
  background-color: var(--bg-secondary);
}

/* A greyed "coming soon" item (PR #627 round 8): still focusable in the
   roving menu so its line is read, but muted and inert. */
.da-chat__attach-menu-item[aria-disabled="true"] {
  align-items: flex-start;
  color: var(--text-muted);
  cursor: not-allowed;
}

.da-chat__attach-menu-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.da-chat__attach-menu-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: normal;
}

.da-chat__attach-menu-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.da-chat__attach-menu-panel[hidden] {
  display: none;
}

.da-chat__attach-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 100%;
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  background-color: var(--bg-primary);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.da-chat__attach-chip-icon {
  flex-shrink: 0;
}

.da-chat__attach-chip-name {
  font-weight: var(--font-semibold);
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.da-chat__attach-chip-state {
  overflow: hidden;
  text-overflow: ellipsis;
}

.da-chat__attach-chip--uploading .da-chat__attach-chip-icon {
  animation: da-composer-rec-pulse 1.4s ease-in-out infinite;
}

.da-chat__attach-chip--done {
  border-color: var(--palette-success-300);
  color: var(--palette-success-700);
}

.da-chat__attach-chip--error {
  border-color: var(--palette-danger-300);
  color: var(--palette-danger-700);
}

.da-chat__attach-chip-remove {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Comfortable touch target inside a compact chip. */
  min-width: 32px;
  min-height: 32px;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  border-radius: var(--radius-xl);
}

.da-chat__attach-chip-remove:hover {
  color: var(--palette-danger-500);
}

/* ── Column 3: Vehicle context ── */
.da-chat__context {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
}

.da-chat__context-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.da-chat__context-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.da-chat__context-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.da-chat__vehicle-select {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: var(--space-2_5) var(--space-3);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition-all);
  cursor: pointer;
}

.da-chat__vehicle-select:focus {
  border-color: var(--border-brand);
  box-shadow: var(--focus-ring);
  outline: none;
}

.da-chat__no-vehicles {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

.da-chat__no-vehicles a {
  color: var(--text-brand);
  text-decoration: underline;
}

/* ── Session info ── */
.da-chat__session-vehicle {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: var(--font-medium);
}

.da-chat__session-id {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: var(--space-1);
  word-break: break-all;
}

/* ── Mobile top bar ── */
.da-chat__mobile-bar {
  display: none;           /* hidden on desktop */
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-secondary);
  align-items: center;
  gap: var(--space-3);
}

.da-chat__mobile-vehicle {
  flex: 1 1 auto;
}

/* ── Off-canvas drawer (mobile) ── */
.da-chat__drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--overlay-backdrop);
  z-index: var(--z-overlay);
}

.da-chat__drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background-color: var(--bg-primary);
  border-right: 1px solid var(--border-subtle);
  z-index: var(--z-modal);
  transform: translateX(-100%);
  transition: transform var(--duration-slow) var(--ease-out);
  display: flex;
  flex-direction: column;
}

.da-chat__drawer--open {
  transform: translateX(0);
}

.da-chat__drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.da-chat__drawer-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

/* ── Session info on mobile ── */
.da-chat__session-info {
  border-top: 1px solid var(--border-subtle);
}


/* ── Responsive: tablet and below ── */
@media (max-width: 1023px) {
  .da-chat__sidebar {
    display: none;
  }

  .da-chat__context {
    display: none;
  }

  .da-chat__mobile-bar {
    display: flex;
  }

  .da-chat__bubble {
    max-width: 90%;
  }

  .da-chat__messages {
    padding: var(--space-4);
  }

  .da-chat__input-bar {
    padding: var(--space-3) var(--space-4);
  }
}

/* ── Responsive: small phones ── */
@media (max-width: 479px) {
  .da-chat__bubble {
    max-width: 95%;
  }

  .da-chat__form {
    gap: var(--space-2);
  }

  .da-chat__input {
    font-size: var(--text-base);  /* prevent iOS zoom */
  }

  .da-chat__messages {
    padding: var(--space-3);
  }
}


/* ============================================================
   18b. W1-IA CHAT RAIL — collapsible left rail, recents, KB
   (CEO chat-IA directive 2026-08-01: minimizable sessions rail
   with Knowledge Base + Garage integrated, chats as recents,
   no consumer top tab bar.)
   ============================================================ */

/* ── Rail top: New session + collapse toggle ── */
.da-chat__rail-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.da-chat__rail-new {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
}

.da-chat__rail-toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-colors);
}

.da-chat__rail-toggle:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.da-chat__rail-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ── Rail nav (Knowledge Base + retired tab destinations) ── */
.da-chat__rail-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.da-chat__rail-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-colors);
}

.da-chat__rail-item:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.da-chat__rail-item:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.da-chat__rail-item--active,
.da-chat__rail-item[aria-pressed="true"] {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

.da-chat__rail-icon {
  flex: 0 0 auto;
  font-size: var(--text-base);
}

/* Gold is the single-highlight accent (locked style guide): it marks the
   Knowledge Base — the vehicle's memory — and nothing else in the rail. */
.da-chat__rail-icon--kb {
  color: var(--palette-gold-500);
}

.da-chat__rail-section-title {
  padding: var(--space-4) var(--space-4) var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Recents (real session list — button rows) ── */
.da-chat__session-list .da-chat__session-item {
  padding: 0;
  border-bottom: none;
}

.da-chat__session-btn {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-4);
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: var(--transition-colors);
}

.da-chat__session-btn:hover {
  background-color: var(--bg-tertiary);
}

.da-chat__session-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.da-chat__session-btn--active {
  background-color: var(--bg-brand-subtle);
  border-left-color: var(--border-brand);
}

.da-chat__session-btn--loading {
  opacity: 0.6;
  cursor: progress;
}

.da-chat__session-btn .da-chat__session-vehicle-name,
.da-chat__session-btn .da-chat__session-timestamp {
  display: block;
}

.da-chat__session-empty {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Collapsed rail (desktop): icon column ── */
.da-chat__sidebar {
  transition: width var(--duration-normal) var(--ease-default);
}

.da-chat--rail-collapsed .da-chat__sidebar {
  width: 64px;
}

/* W1-IA-R1 N1 (WCAG 4.1.2): collapsed labels go VISUALLY hidden, not
   display:none — the accessible name must survive the collapse (icons are
   aria-hidden; the label IS the name). chat-rail.js additionally mirrors
   the label into title while collapsed so sighted users get a tooltip. */
.da-chat--rail-collapsed .da-chat__rail-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* The recents REGION (heading + list) is genuinely unavailable while
   collapsed — hidden for every user alike, so display:none is correct. */
.da-chat--rail-collapsed .da-chat__rail-section-title,
.da-chat--rail-collapsed .da-chat__session-list {
  display: none;
}

.da-chat--rail-collapsed .da-chat__rail-top {
  flex-direction: column;
  gap: var(--space-2);
}

.da-chat--rail-collapsed .da-chat__rail-new {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
}

.da-chat--rail-collapsed .da-chat__rail-item {
  justify-content: center;
  padding: var(--space-2);
}

@media (prefers-reduced-motion: reduce) {
  .da-chat__sidebar {
    transition: none;
  }
}

/* ── Knowledge Base view — replaces the chat pane when open ── */
.da-chat--kb-open .da-chat__messages,
.da-chat--kb-open .da-chat__typing,
.da-chat--kb-open .da-chat__input-bar {
  display: none;
}

.da-chat__kb {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-6);
}

.da-chat__kb:focus {
  outline: none;
}

.da-chat__kb-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: 720px;
  margin: 0 auto var(--space-5);
}

.da-chat__kb-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 var(--space-1);
}

.da-chat__kb-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0;
}

.da-chat__kb-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 720px;
  margin: 0 auto;
}

.da-chat__kb-section {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
}

.da-chat__kb-section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 var(--space-3);
}

.da-chat__kb-section-title .bi {
  color: var(--palette-gold-500);
}

.da-chat__kb-fact {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
}

.da-chat__kb-fact-label {
  color: var(--text-muted);
}

.da-chat__kb-fact-value {
  font-weight: var(--font-medium);
}

/* ── KB health dash (B2C-UI-2 G1) — the per-vehicle health front door.
   Token-only: score/status/trend/sparkline all read the semantic status
   ramps; no hex, no Bootstrap contextual classes. ── */
.da-chat__kb-health {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.da-chat__kb-health-headline {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.da-chat__kb-health-score {
  font-size: var(--text-4xl);
  font-weight: var(--font-extrabold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

.da-chat__kb-health-unit {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  margin-left: var(--space-0_5);
}

.da-chat__kb-health-score--good    { color: var(--text-success); }
.da-chat__kb-health-score--fair    { color: var(--text-warning); }
.da-chat__kb-health-score--poor    { color: var(--text-danger); }
.da-chat__kb-health-score--unknown { color: var(--text-muted); }

.da-chat__kb-health-tags {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1_5);
}

.da-chat__kb-health-status {
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
}

.da-chat__kb-health-status--good {
  background-color: var(--bg-success-subtle);
  color: var(--text-success);
}

.da-chat__kb-health-status--fair {
  background-color: var(--bg-warning-subtle);
  color: var(--text-warning);
}

.da-chat__kb-health-status--poor {
  background-color: var(--bg-danger-subtle);
  color: var(--text-danger);
}

/* Symmetry with __score--unknown (B2C-UI-2-FIX-1 code nit 1): the JS emits
   --unknown for a bandless status; muted-on-tertiary is AA in both themes. */
.da-chat__kb-health-status--unknown {
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
}

.da-chat__kb-health-trend {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.da-chat__kb-health-trend--up    { color: var(--text-success); }
.da-chat__kb-health-trend--down  { color: var(--text-danger); }
.da-chat__kb-health-trend--muted { color: var(--text-muted); }

.da-chat__kb-health-delta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.da-chat__kb-health-svg {
  display: block;
  width: 100%;
  max-width: 420px;
  height: 40px;
}

/* Band fills via the theme-flexed chart tokens (B2C-UI-2-FIX-1 M2):
   warning-500 was 2.38:1 on white — the tokens keep every bar >=3:1
   (WCAG 1.4.11) in both themes, incl. the bandless neutral fallback. */
.da-chat__kb-health-bar        { fill: var(--health-bar-neutral); }
.da-chat__kb-health-bar--good  { fill: var(--health-bar-good); }
.da-chat__kb-health-bar--fair  { fill: var(--health-bar-fair); }
.da-chat__kb-health-bar--poor  { fill: var(--health-bar-poor); }

.da-chat__kb-health-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: 0;
}

.da-chat__kb-entries,
.da-chat__kb-missions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.da-chat__kb-entry {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}

.da-chat__kb-entry:last-child {
  border-bottom: none;
}

.da-chat__kb-entry-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.da-chat__kb-badge {
  display: inline-block;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

.da-chat__kb-badge--note {
  background-color: var(--bg-gold-subtle);
  color: var(--text-gold);
}

.da-chat__kb-badge--torque {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.da-chat__kb-entry-date,
.da-chat__kb-entry-mileage {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.da-chat__kb-entry-torque {
  font-weight: var(--font-medium);
}

.da-chat__kb-entry-text {
  color: var(--text-secondary);
}

.da-chat__kb-mission {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
}

.da-chat__kb-mission .bi-check-circle-fill {
  color: var(--palette-success-500);
}

.da-chat__kb-mission-pending {
  color: var(--text-muted);
}

.da-chat__kb-muted {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

.da-chat__kb-link {
  display: inline-flex;
  align-items: center;
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.da-chat__kb-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.da-chat__kb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-4);
  color: var(--text-muted);
  text-align: center;
}

.da-chat__kb-empty .bi {
  font-size: 2rem;
}

@media (max-width: 1023px) {
  .da-chat__kb {
    padding: var(--space-4);
  }
}


/* ============================================================
   19. DIAGNOSTIC RESULT CARDS (chat inline)
   ============================================================ */
.da-chat-diag {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  margin-top: var(--space-3);
  box-shadow: var(--shadow-sm);
}

/* ── Header ── */
.da-chat-diag__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.da-chat-diag__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  background: var(--gradient-brand);
  color: #ffffff;
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.da-chat-diag__title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

/* ── Badges row ── */
.da-chat-diag__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

/* ── Confidence section ── */
.da-chat-diag__confidence {
  margin-bottom: var(--space-4);
}

.da-chat-diag__confidence-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-1_5);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.da-chat-diag__confidence-value {
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
}

.da-chat-diag__confidence-value--success { color: var(--text-success); }
.da-chat-diag__confidence-value--warning { color: var(--text-warning); }
.da-chat-diag__confidence-value--danger  { color: var(--text-danger); }

/* ── Progress bar ── */
.da-chat-diag__progress {
  width: 100%;
  height: 8px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.da-chat-diag__progress--sm {
  height: 6px;
}

.da-chat-diag__progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--duration-slower) var(--ease-out);
}

.da-chat-diag__progress-bar--success {
  background: var(--gradient-success);
}

.da-chat-diag__progress-bar--warning {
  background: var(--gradient-warning);
}

.da-chat-diag__progress-bar--danger {
  background-color: var(--palette-danger-500);
}

/* ── Metrics breakdown ── */
.da-chat-diag__metrics {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.da-chat-diag__metrics-heading {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-3);
}

.da-chat-diag__metric {
  margin-bottom: var(--space-2_5);
}

.da-chat-diag__metric:last-child {
  margin-bottom: 0;
}

.da-chat-diag__metric-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* ── Recommendations ── */
.da-chat-diag__recs {
  margin-bottom: var(--space-4);
}

.da-chat-diag__recs-heading {
  display: flex;
  align-items: center;
  gap: var(--space-1_5);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.da-chat-diag__recs-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.da-chat-diag__recs-list li {
  position: relative;
  padding-left: var(--space-5);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.da-chat-diag__recs-list li:last-child {
  margin-bottom: 0;
}

.da-chat-diag__recs-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--palette-brand-400);
}

/* ── Footer: model meta ── */
.da-chat-diag__footer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.da-chat-diag__meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ── Responsive adjustments for diag card ── */
@media (max-width: 479px) {
  .da-chat-diag {
    padding: var(--space-4);
  }

  .da-chat-diag__badges {
    flex-direction: column;
    gap: var(--space-1_5);
  }

  .da-chat-diag__footer {
    flex-wrap: wrap;
  }
}


/* ============================================================
   19. SSE STREAMING COMPONENTS
   ============================================================ */

/* Tool loading indicator — shown during tool_call / tool_executing */
.da-chat__tool-loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-3);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.da-chat__tool-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--bg-brand-subtle);
  border-top-color: var(--bg-brand);
  border-radius: 50%;
  animation: da-spin 0.75s linear infinite;
  flex-shrink: 0;
}

.da-chat__tool-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

/* Diagnostic card wrapper — wraps inline diagnostic result cards */
.da-chat__diag-card-wrapper {
  margin-top: var(--space-3);
}

/* Stream error message */
.da-chat__stream-error {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-3);
  background-color: var(--bg-danger-subtle);
  border: 1px solid var(--palette-danger-300);
  border-radius: var(--radius-lg);
  color: var(--text-danger);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.da-chat__stream-error::before {
  content: '\f33a';
  font-family: 'bootstrap-icons';
  font-size: var(--text-base);
  flex-shrink: 0;
}


/* ============================================================
   20. RAG-07 CITATIONS — inline markers, tooltips, detail panel,
       similar cases collapsible on diagnostic cards.
   ============================================================ */

/* Inline citation superscript — [N] link rendered in assistant prose. */
.da-chat__cite {
  display: inline-block;
  line-height: 1;
  margin: 0 1px;
  vertical-align: super;
  font-size: 0.72em;
}

.da-chat__cite-btn {
  background: var(--bg-brand-subtle);
  color: var(--text-brand);
  border: 1px solid var(--palette-brand-300, var(--border-subtle));
  border-radius: var(--radius-sm, 4px);
  padding: 0 4px;
  font-size: inherit;
  font-weight: var(--font-semibold);
  line-height: 1.4;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background-color 120ms ease, transform 120ms ease;
}

.da-chat__cite-btn:hover {
  background: var(--bg-brand, var(--bg-brand-subtle));
  color: var(--text-on-brand, var(--text-brand));
}

.da-chat__cite-btn:focus-visible {
  outline: 2px solid var(--palette-brand-500, var(--bg-brand));
  outline-offset: 2px;
}

/* Citation detail panel — fixed bottom-right on desktop, full-width
   bottom sheet at <=480px so it fits inside 375px viewports without
   horizontal scroll. */
.da-chat__cite-panel {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  width: min(420px, calc(100vw - 2 * var(--space-4)));
  max-height: min(70vh, 560px);
  overflow-y: auto;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl, 0 12px 32px rgba(0, 0, 0, 0.18));
  z-index: 1000;
  padding: var(--space-4);
  display: none;
}

.da-chat__cite-panel--open {
  display: block;
}

.da-chat__cite-panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.da-chat__cite-panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-brand-subtle);
  color: var(--text-brand);
  font-size: 16px;
  flex-shrink: 0;
}

.da-chat__cite-panel-title {
  margin: 0;
  flex: 1;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.da-chat__cite-panel-close {
  flex-shrink: 0;
}

.da-chat__cite-panel-body {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.da-chat__cite-panel-score,
.da-chat__cite-panel-id,
.da-chat__cite-panel-tier {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  gap: var(--space-2);
}

.da-chat__cite-panel-score-label,
.da-chat__cite-panel-id-label {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--font-medium);
}

.da-chat__cite-panel-score-value {
  font-weight: var(--font-semibold);
  color: var(--text-brand);
}

.da-chat__cite-panel-summary {
  margin: var(--space-3) 0;
  line-height: var(--leading-normal, 1.5);
  color: var(--text-primary);
}

.da-chat__cite-panel-id-value {
  font-family: var(--font-mono, monospace);
  font-size: var(--text-xs);
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm, 4px);
  word-break: break-all;
}

.da-chat__cite-panel-missing {
  color: var(--text-secondary);
  font-style: italic;
  margin: 0;
}

/* Similar Cases collapsible on diagnostic cards. */
.da-chat-diag__similar {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--border-subtle);
}

.da-chat-diag__similar-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  color: var(--text-primary);
  padding: var(--space-1) 0;
}

.da-chat-diag__similar-summary::-webkit-details-marker {
  display: none;
}

.da-chat-diag__similar-summary::before {
  content: '\f282';
  font-family: 'bootstrap-icons';
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: transform 180ms ease;
  display: inline-block;
}

.da-chat-diag__similar[open] .da-chat-diag__similar-summary::before {
  transform: rotate(90deg);
}

.da-chat-diag__similar-summary:focus-visible {
  outline: 2px solid var(--palette-brand-500, var(--bg-brand));
  outline-offset: 2px;
  border-radius: var(--radius-sm, 4px);
}

.da-chat-diag__similar-count {
  color: var(--text-secondary);
  font-weight: var(--font-normal);
}

.da-chat-diag__similar-list {
  list-style: none;
  padding: 0;
  margin: var(--space-2) 0 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.da-chat-diag__similar-item {
  margin: 0;
}

.da-chat-diag__similar-btn {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 8px);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--text-xs);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
  font-family: inherit;
}

.da-chat-diag__similar-btn:hover {
  background: var(--bg-brand-subtle);
  border-color: var(--palette-brand-300, var(--bg-brand));
}

.da-chat-diag__similar-btn:focus-visible {
  outline: 2px solid var(--palette-brand-500, var(--bg-brand));
  outline-offset: 2px;
}

.da-chat-diag__similar-id {
  font-family: var(--font-mono, monospace);
  font-weight: var(--font-semibold);
  color: var(--text-brand);
  white-space: nowrap;
}

.da-chat-diag__similar-score {
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.da-chat-diag__similar-text {
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-width: 0;
}

/* Mobile (<=480px): panel becomes a bottom sheet, similar-btn wraps
   onto two rows so the long summary doesn't force horizontal scroll
   inside a 375px viewport. */
@media (max-width: 480px) {
  .da-chat__cite-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 75vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .da-chat-diag__similar-btn {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }

  .da-chat-diag__similar-text {
    grid-column: 1 / -1;
    -webkit-line-clamp: 3;
  }
}


/* ============================================================
   21. DATA-ENTRY KIT (FE-06)
   ------------------------------------------------------------
   Gap-fill primitives that round out the existing form set
   (da-field / da-input / da-textarea / da-select / da-otp-group):

     da-switch       — on/off toggle (native checkbox + role="switch")
     da-checkbox     — checked / indeterminate (native checkbox)
     da-radio        — single-select (native radio)
     da-segmented    — LOGIC-FREE segmented control (ARIA radiogroup);
                       the segmented visual, behaviour-free (the old
                       Simple/Expert view-density toggle was removed in FE-07)
     da-input-group  — input with a __prefix / __suffix affix
     da-stepper      — numeric +/- stepper around a native input
     da-tabs         — tablist / tab / tabpanel (ARIA)

   Rules honoured:
     * 100% token-driven — no hardcoded hex; check/dash/dot marks are
       CSS-drawn (no SVG data-URI, no innerHTML).
     * Keyboard-operable: switch/checkbox/radio use a real, focusable
       native <input>; segmented/stepper/tabs use real <button>s.
     * Every applicable state: hover / focus-visible / error / success /
       disabled / checked / indeterminate.
     * Dark theme + B&W brand lock inherited via the semantic tokens.
   ============================================================ */

/* ── Shared: visually-hidden native control (still focusable) ─────────── */
.da-switch__input,
.da-checkbox__input,
.da-radio__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── 21.1  da-switch ─────────────────────────────────────────────────── */
.da-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2_5);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.da-switch__track {
  position: relative;
  flex-shrink: 0;
  width: var(--switch-w);
  height: var(--switch-h);
  background-color: var(--border-strong);
  border-radius: var(--radius-full);
  transition: background-color var(--duration-normal) var(--ease-default);
}

.da-switch__thumb {
  position: absolute;
  top: var(--switch-gap);
  left: var(--switch-gap);
  width: var(--switch-thumb);
  height: var(--switch-thumb);
  background-color: var(--bg-primary);
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration-normal) var(--ease-default);
}

.da-switch:hover .da-switch__track {
  background-color: var(--text-muted);
}

/* Checked — ink track, thumb slides the full travel. */
.da-switch__input:checked + .da-switch__track {
  background-color: var(--bg-brand);
}

.da-switch__input:checked + .da-switch__track .da-switch__thumb {
  transform: translateX(
    calc(var(--switch-w) - var(--switch-thumb) - (2 * var(--switch-gap)))
  );
}

.da-switch:hover .da-switch__input:checked + .da-switch__track {
  background-color: var(--text-primary);
}

.da-switch__input:focus-visible + .da-switch__track {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Error / success — colour the track edge via a ring. */
.da-switch--error .da-switch__track {
  box-shadow: 0 0 0 1.5px var(--palette-danger-500);
}

.da-switch--success .da-switch__track {
  box-shadow: 0 0 0 1.5px var(--palette-success-500);
}

/* Disabled. */
.da-switch--disabled,
.da-switch__input:disabled {
  cursor: not-allowed;
}

.da-switch__input:disabled + .da-switch__track {
  opacity: 0.45;
}

.da-switch--disabled,
.da-switch__input:disabled ~ .da-switch__label {
  color: var(--text-muted);
}

/* ── 21.2  da-checkbox / da-radio ────────────────────────────────────── */
.da-checkbox,
.da-radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2_5);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.da-checkbox__box,
.da-radio__circle {
  position: relative;
  flex-shrink: 0;
  width: var(--control-box-size);
  height: var(--control-box-size);
  background-color: var(--bg-primary);
  border: 1.5px solid var(--border-strong);
  transition: background-color var(--duration-fast) var(--ease-default),
              border-color var(--duration-fast) var(--ease-default);
}

.da-checkbox__box {
  border-radius: var(--radius-sm);
}

.da-radio__circle {
  border-radius: 50%;
}

/* Checkmark — CSS-drawn, hidden (scale 0) until checked. */
.da-checkbox__box::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: 0.3125rem;   /* 5px */
  height: 0.625rem;   /* 10px */
  border: solid var(--text-on-brand);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg) scale(0);
  transition: transform var(--duration-fast) var(--ease-default);
}

/* Radio dot — ink, hidden (scale 0) until checked. */
.da-radio__circle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: var(--bg-brand);
  transform: translate(-50%, -50%) scale(0);
  transition: transform var(--duration-fast) var(--ease-default);
}

.da-checkbox:hover .da-checkbox__box,
.da-radio:hover .da-radio__circle {
  border-color: var(--text-primary);
}

/* Checked. */
.da-checkbox__input:checked + .da-checkbox__box {
  background-color: var(--bg-brand);
  border-color: var(--bg-brand);
}

.da-checkbox__input:checked + .da-checkbox__box::after {
  transform: translate(-50%, -50%) rotate(45deg) scale(1);
}

.da-radio__input:checked + .da-radio__circle {
  border-color: var(--bg-brand);
}

.da-radio__input:checked + .da-radio__circle::after {
  transform: translate(-50%, -50%) scale(1);
}

/* Indeterminate (native :indeterminate, set via JS) plus a declarative
   [data-indeterminate] hook so the state can be shown without script. */
.da-checkbox__input:indeterminate + .da-checkbox__box,
.da-checkbox__input[data-indeterminate="true"] + .da-checkbox__box {
  background-color: var(--bg-brand);
  border-color: var(--bg-brand);
}

.da-checkbox__input:indeterminate + .da-checkbox__box::after,
.da-checkbox__input[data-indeterminate="true"] + .da-checkbox__box::after {
  width: 0.625rem;   /* 10px dash */
  height: 0;
  border-width: 0 0 2px 0;
  border-radius: var(--radius-full);
  transform: translate(-50%, -50%) rotate(0) scale(1);
}

/* Focus-visible. */
.da-checkbox__input:focus-visible + .da-checkbox__box,
.da-radio__input:focus-visible + .da-radio__circle {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
}

/* Error / success. */
.da-checkbox--error .da-checkbox__box,
.da-radio--error .da-radio__circle {
  border-color: var(--palette-danger-500);
}

.da-checkbox--success .da-checkbox__box,
.da-radio--success .da-radio__circle {
  border-color: var(--palette-success-500);
}

/* Disabled. */
.da-checkbox--disabled,
.da-radio--disabled {
  cursor: not-allowed;
  color: var(--text-muted);
}

.da-checkbox__input:disabled + .da-checkbox__box,
.da-radio__input:disabled + .da-radio__circle {
  opacity: 0.45;
}

.da-checkbox__input:disabled ~ .da-checkbox__label,
.da-radio__input:disabled ~ .da-radio__label {
  color: var(--text-muted);
}

/* ── 21.3  da-segmented (LOGIC-FREE — salvaged segmented-control look) ── */
.da-segmented {
  display: inline-flex;
  align-items: center;
  padding: var(--space-0_5);
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-full);
  gap: var(--space-0_5);
}

.da-segmented__option {
  position: relative;
  min-height: var(--control-h-md);
  padding: var(--space-1) var(--space-4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-colors);
}

.da-segmented__option:hover {
  color: var(--text-primary);
}

/* Selected — supports aria-checked (radiogroup) and aria-selected. */
.da-segmented__option[aria-checked="true"],
.da-segmented__option[aria-selected="true"] {
  color: var(--text-on-brand);
  background-color: var(--bg-brand);
  box-shadow: var(--shadow-xs);
}

.da-segmented__option:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.da-segmented__option:disabled,
.da-segmented__option[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── 21.4  da-input-group (prefix / suffix affixes) ──────────────────── */
.da-input-group {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.da-input-group__prefix,
.da-input-group__suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-muted);
  background-color: var(--bg-secondary);
  border: 1.5px solid var(--border-default);
  white-space: nowrap;
}

.da-input-group__prefix {
  border-right: none;
  border-radius: var(--control-radius) 0 0 var(--control-radius);
}

.da-input-group__suffix {
  border-left: none;
  border-radius: 0 var(--control-radius) var(--control-radius) 0;
}

/* The field inside a group is square; affixes supply the outer corners. */
.da-input-group .da-input {
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 0;
}

/* No prefix → field keeps its own left corner. */
.da-input-group > .da-input:first-child {
  border-radius: var(--control-radius) 0 0 var(--control-radius);
}

/* No suffix → field keeps its own right corner. */
.da-input-group > .da-input:last-child {
  border-radius: 0 var(--control-radius) var(--control-radius) 0;
}

/* Lift the focused field so its focus ring is not overlapped by affixes. */
.da-input-group .da-input:focus {
  position: relative;
  z-index: 1;
}

/* Error / success / disabled — colour every piece together. */
.da-input-group--error .da-input,
.da-input-group--error .da-input-group__prefix,
.da-input-group--error .da-input-group__suffix {
  border-color: var(--palette-danger-500);
}

.da-input-group--success .da-input,
.da-input-group--success .da-input-group__prefix,
.da-input-group--success .da-input-group__suffix {
  border-color: var(--palette-success-500);
}

.da-input-group--disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── 21.5  da-stepper (numeric +/-) ──────────────────────────────────── */
.da-stepper {
  display: inline-flex;
  align-items: stretch;
  height: var(--control-h-md);
  background-color: var(--bg-primary);
  border: 1.5px solid var(--border-default);
  border-radius: var(--control-radius);
  overflow: hidden;
}

.da-stepper__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--control-h-md);
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  line-height: 1;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  border: none;
  cursor: pointer;
  transition: var(--transition-colors);
}

.da-stepper__btn:hover {
  background-color: var(--bg-tertiary);
}

.da-stepper__btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  z-index: 1;
}

.da-stepper__btn:disabled,
.da-stepper__btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.da-stepper__input {
  width: 3.5rem;
  text-align: center;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: none;
  border-left: 1.5px solid var(--border-subtle);
  border-right: 1.5px solid var(--border-subtle);
  appearance: textfield;
  -moz-appearance: textfield;
}

.da-stepper__input:focus {
  outline: none;
}

/* Strip the native number spinners — the +/- buttons own increment. */
.da-stepper__input::-webkit-outer-spin-button,
.da-stepper__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.da-stepper:focus-within {
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
}

.da-stepper--error {
  border-color: var(--palette-danger-500);
}

.da-stepper--success {
  border-color: var(--palette-success-500);
}

.da-stepper--disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── 21.6  da-tabs (tablist / tab / tabpanel) ────────────────────────── */
.da-tabs {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.da-tabs__list {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.da-tabs__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-h-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: -1px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-colors);
}

.da-tabs__tab:hover {
  color: var(--text-primary);
}

.da-tabs__tab[aria-selected="true"] {
  color: var(--text-brand);
  border-bottom-color: var(--border-brand);
  font-weight: var(--font-semibold);
}

.da-tabs__tab:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.da-tabs__tab:disabled,
.da-tabs__tab[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.da-tabs__panel {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: var(--leading-relaxed);
}

.da-tabs__panel[hidden] {
  display: none;
}

.da-tabs__panel:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-md);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONSUMER SHELL RAIL (CONSUMER-P1, Asana 1217138613936846)
   The rail is the consumer SHELL: base.html renders #consumer-rail on every
   authenticated consumer page except the chat home (which keeps its own
   richer rail — Recents + Knowledge Base). Below 992px the rail stands down
   and the consumer IA rides the navbar hamburger collapse instead (the
   d-lg-none items in base.html) — no width is ever left without navigation,
   and no width ever shows a persistent top tab bar (CEO chat-IA directive
   2026-08-01). 992px (not the chat surface's internal 1024px) deliberately
   matches Bootstrap's lg navbar-expand breakpoint, so the hamburger and the
   rail hand over at the SAME width with no dead zone between them.
   Visual language mirrors .da-chat__rail-item so the two rails read as one
   system.
   ═══════════════════════════════════════════════════════════════════════ */

.da-consumer-rail {
  display: none;                 /* mobile: the hamburger collapse carries the IA */
}

@media (min-width: 992px) {
  .da-consumer-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: var(--space-6);
    align-items: start;
  }

  .da-consumer-rail {
    display: block;
    position: sticky;
    top: calc(var(--space-6) + 56px);   /* clear the sticky navbar */
    padding: var(--space-4) 0;
  }
}

.da-consumer-rail__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2);
  border-right: 1px solid var(--border-subtle);
}

.da-consumer-rail__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-decoration: none;
  transition: var(--transition-colors);
}

.da-consumer-rail__item:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.da-consumer-rail__item:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.da-consumer-rail__item--active {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

.da-consumer-rail__icon {
  flex: 0 0 auto;
  font-size: var(--text-base);
}

/* ───────────────────────────────────────────────────────────────────────────
   THE HEADER, EDGE TO EDGE (CEO round 3, item 2)

   The DriveTrace logo sat inset from the left and the profile menu inset from
   the right, because `base.html`'s navbar wraps its row in `.da-container`
   (max-width 1280px, auto side margins). On a 2560px display that parks both
   ends of the header hundreds of pixels inside the window while the island
   below runs full-bleed — the header reads as belonging to a different page
   than the workspace under it.

   ===========================================================================
   THIS IS CSS ONLY, AND IT IS SCOPED TO FLAG-ON. Both facts are deliberate.

   The navbar is SHARED LEGACY CHROME: `base.html` is the shell for every
   surface in the app, and the brief's instruction for that case is to scope
   under the flag rather than touch shared markup without VP signoff. So no
   markup changed — not one byte of `base.html` or `chat.html`.

   `body:has(.da-chat--island)` is the same hook the full-bleed canvas rules
   above already use. `.da-chat--island` is emitted ONLY inside chat.html's
   `should_render` branch, so:
     - flag-OFF /chat        -> class absent -> these rules never match
     - every other page      -> class absent -> untouched
   and the flag-OFF byte parity arm is unaffected by construction, since a
   stylesheet cannot change the rendered HTML at all.

   WHY NOT `padding-inline: 0`. Hard-left means flush to the page gutter, not
   flush to the glass. `--space-4` is the gutter the rest of the app already
   uses, and it is what keeps the wordmark off a 0px window edge on mobile.
   ─────────────────────────────────────────────────────────────────────────── */
body:has(.da-chat--island) .da-navbar--sticky > .da-container {
  max-inline-size: none;
  margin-inline: 0;
  padding-inline: var(--space-4);
}
