/* ══════════════════════════════════════════════════════════════════
   AskIQ UI — app.css  v3 (Sapience brand-compliant)
   Enterprise-grade design system for IQ-AI-UI-Integration.

   Brand source of truth:
     - Font headings: Poppins
     - Font body:     Calibri (system) → Segoe UI fallback
     - Font mono:     JetBrains Mono
     - Primary:       #2563EB  (Sapience blue)
     - Secondary:     #EC4E20  (Sapience orange)
   ══════════════════════════════════════════════════════════════════ */

/* ── Design tokens ──────────────────────────────────────────────── */
:root {
  /* Typography (Sapience brand) */
  --font-heading: "Poppins", "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  --font-primary: Calibri, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:    "JetBrains Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;

  /* Brand */
  --color-brand:          #0f2d52;
  --color-accent:         #2563eb;  /* Sapience primary */
  --color-accent-hover:   #1d4ed8;
  --color-accent-light:   #3b82f6;
  --color-accent-bg:      #eff6ff;
  --color-accent-border:  #bfdbfe;

  /* Sapience secondary (orange) — for emphasis, call-to-action accents */
  --color-secondary:        #ec4e20;
  --color-secondary-hover:  #d4421a;
  --color-secondary-bg:     #fef3ef;
  --color-secondary-border: #fbcab4;

  /* Semantic */
  --color-success:        #059669;
  --color-success-bg:     #ecfdf5;
  --color-success-light:  #d1fae5;
  --color-warning:        #d97706;
  --color-warning-bg:     #fffbeb;
  --color-warning-light:  #fef3c7;
  --color-error:          #dc2626;
  --color-error-bg:       #fef2f2;
  --color-error-light:    #fee2e2;

  /* Neutrals */
  --color-bg:             #f1f5f9;
  --color-surface:        #ffffff;
  --color-surface-alt:    #f8fafc;
  --color-border:         #e2e8f0;
  --color-border-strong:  #cbd5e1;
  --color-text:           #0f172a;
  --color-text-2:         #1e293b;
  --color-text-muted:     #64748b;
  --color-text-subtle:    #94a3b8;

  /* Sidebar */
  --color-sidebar:        #0f172a;
  --color-sidebar-hover:  rgba(255,255,255,.055);
  --color-sidebar-active: rgba(37,99,235,.18);
  --color-sidebar-text:   #94a3b8;

  /* Layout */
  --sidebar-width:        256px;
  --header-height:        64px;
  --footer-height:        36px;

  /* Border radius */
  --radius-xs:  3px;
  --radius-sm:  6px;
  --radius:     8px;
  --radius-md:  10px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 10px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 25px rgba(0,0,0,.08), 0 4px 8px rgba(0,0,0,.04);
  --shadow-xl:  0 20px 40px rgba(0,0,0,.12);
  --shadow-focus: 0 0 0 3px rgba(37,99,235,.20);

  --transition:      150ms ease;
  --transition-slow: 250ms ease;
}

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

html, body {
  height: 100%;
  font-family: var(--font-primary);
  font-size: clamp(14px, 1.1vw, 18px);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings use Poppins per Sapience brand. */
h1, h2, h3, h4, h5, h6,
.page-title, .hero-title, .section-card-title,
.manifest-title, .manifest-section-title,
.feature-title, .qp-panel-title, .qp-card-title,
.kpi-value, .welcome-title, .standalone-section-title,
.report-card-title, .auth-title, .auth-logo-text,
.history-stat-value {
  font-family: var(--font-heading);
}

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

/* ── App Layout ─────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ══════════════════════════════════════════════════════════════════
   TOP-NAV LAYOUT (Phase 5 D1)
   Replaces the legacy sidebar layout. The .app-layout-topnav stacks
   the topbar + main content vertically; sidebar styles are no longer
   loaded by base.html.
   ══════════════════════════════════════════════════════════════════ */
.app-body-topnav { padding-top: 56px; }   /* room for fixed topbar */
.app-layout-topnav { display: flex; flex-direction: column; min-height: 100vh; }

.app-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: stretch;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
  box-shadow: 0 1px 0 rgba(15,23,42,.02);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0 1.25rem;
  text-decoration: none;
  border-right: 1px solid var(--color-border);
  flex-shrink: 0;
}
.topbar-brand:hover { text-decoration: none; }

/* SapienceIQ logo mark — white background, orange border + text (matches brand image) */
.topbar-brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #fff;
  color: var(--color-secondary, #ec4e20);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9375rem;
  border-radius: 10px;
  border: 1.5px solid #f1d8ce;
  letter-spacing: -0.04em;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(236,78,32,.1);
}

.topbar-brand-name {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.topbar-brand-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--color-brand);
  letter-spacing: -0.02em;
}
.topbar-brand-sub {
  font-size: 0.625rem;
  font-weight: 400;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* Tab bar container */
.topbar-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  border-bottom: none;
  padding: 0 0.5rem;
  background: transparent;
  box-shadow: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar-tabs::-webkit-scrollbar { display: none; }

/* Individual tabs */
.iqai-tab {
  display: inline-flex;
  align-items: center;
  padding: 0 1rem;
  height: 100%;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.iqai-tab:hover { color: var(--color-text-2); text-decoration: none; }
.iqai-tab.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.75rem;
  border-left: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* Chart theme selector */
.topbar-theme-select {
  display: inline-flex;
  align-items: center;
}
.topbar-select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--color-border, #e2e5ea);
  border-radius: var(--radius, 6px);
  background: var(--color-surface, #fff);
  color: var(--color-text-muted, #6b7280);
  font-size: 0.78rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}
.topbar-select:hover,
.topbar-select:focus { border-color: var(--color-accent, #2563eb); color: var(--color-text, #111); }

/* Icon buttons (settings, help) */
.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border: none;
  background: none;
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.topbar-icon-btn:hover { background: var(--color-surface-alt); color: var(--color-text); }

/* User avatar dropdown (D2) */
.topbar-user { position: relative; }
.topbar-user > summary { list-style: none; cursor: pointer; }
.topbar-user > summary::-webkit-details-marker { display: none; }

.topbar-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--color-text-2);
  transition: background var(--transition);
}
.topbar-user-trigger:hover { background: var(--color-surface-alt); }

.topbar-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--color-accent);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.75rem;
  border-radius: 50%;
  letter-spacing: 0;
}

.topbar-user-name { display: none; }  /* show name only on wide viewports */
@media (min-width: 1200px) {
  .topbar-user-name {
    display: block;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    font-size: 0.8125rem;
  }
}

.topbar-user-caret {
  font-size: 0.625rem;
  color: var(--color-text-muted);
  transition: transform var(--transition);
}
.topbar-user[open] .topbar-user-caret { transform: rotate(180deg); }

.topbar-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 260px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 0.875rem;
  z-index: 200;
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8125rem;
}
.topbar-user-info-name { font-family: var(--font-heading); font-weight: 600; color: var(--color-text); }
.topbar-user-info-role { display: flex; gap: 0.35rem; }
.topbar-user-info-tenant { color: var(--color-text-muted); font-size: 0.75rem; }
.topbar-user-info-session {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text-subtle);
}

.topbar-user-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0.625rem 0;
}

.topbar-user-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  margin-bottom: 0.35rem;
}

.topbar-user-services .sidebar-health-item {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  padding: 0.125rem 0;
}

.topbar-user-action {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.25rem;
  font-size: 0.8125rem;
  color: var(--color-text-2);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.topbar-user-action--admin {
  color: var(--color-accent);
}
.topbar-user-action--admin:hover {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  text-decoration: none;
}
.topbar-user-action:hover {
  background: var(--color-error-bg);
  color: var(--color-error);
  text-decoration: none;
}

.main-content-topnav {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.75rem) clamp(1rem, 3vw, 1.75rem) 5rem;
}

.app-footer-topnav {
  left: 0;
  right: 0;
}

/* Hide legacy sidebar elements when they exist on a top-nav page */
.app-layout-topnav .sidebar,
.app-layout-topnav .sidebar-overlay,
.app-layout-topnav .sidebar-toggle { display: none !important; }


/* ══════════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #1e293b transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.375rem 1.25rem 1rem;
  font-size: 1.0625rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.sidebar-brand-icon { font-size: 1.5rem; color: var(--color-accent); line-height: 1; }
.sidebar-brand-text { letter-spacing: -0.02em; }

.sidebar-badges {
  padding: 0 1.25rem 0.875rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.sidebar-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,.06);
  margin: 0 1.25rem 0.75rem;
}

.sidebar-nav {
  padding: 0 0.625rem;
  flex: 1;
}

.sidebar-nav-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #3d5a80;
  padding: 0.3rem 0.625rem 0.375rem;
  margin-top: 0.125rem;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--color-sidebar-text);
  font-size: 0.875rem;
  font-weight: 450;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  position: relative;
}

.sidebar-nav-link:hover { background: var(--color-sidebar-hover); color: #e2e8f0; text-decoration: none; }

.sidebar-nav-link.active {
  background: var(--color-sidebar-active);
  color: #bfdbfe;
  font-weight: 500;
  box-shadow: inset 3px 0 0 var(--color-accent);
}

.nav-icon { font-size: 1rem; flex-shrink: 0; width: 1.125rem; text-align: center; }

.sidebar-section { padding: 0 1.25rem; }

.sidebar-session-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #475569;
  padding: 0.2rem 0;
  margin-bottom: 0.1rem;
  line-height: 1.4;
}

.sidebar-session-mono {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #3d5a80;
}

.sidebar-health-item {
  font-size: 0.8rem;
  color: #475569;
  padding: 0.15rem 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.health-dot { font-size: 0.5rem; }
.health-loading { color: #3d5a80; }

.sidebar-logout-link { color: #475569 !important; }
.sidebar-logout-link:hover { background: rgba(239,68,68,.10) !important; color: #fca5a5 !important; }

/* ══════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: clamp(0.875rem, 5vw, 2.5rem) clamp(0.875rem, 5vw, 2.5rem) 5rem;
  min-height: 100vh;
  width: 100%;
}

/* ── Footer ─────────────────────────────────────────────────────── */
.app-footer {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--footer-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.6875rem;
  color: var(--color-text-subtle);
  z-index: 50;
  letter-spacing: 0.01em;
}

.footer-env {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0.1rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-subtle);
}

.footer-sep { color: var(--color-border-strong); }

/* ══════════════════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════════════════ */
.env-badge, .mock-badge, .role-badge, .badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.env-badge { background: rgba(255,255,255,.08); color: #64748b; }
.env-badge.env-local,
.env-badge.env-local_direct_development { background: rgba(5,150,105,.18); color: #6ee7b7; }
.env-badge.env-staging { background: rgba(245,158,11,.18); color: #fcd34d; }
.env-badge.env-production { background: rgba(220,38,38,.18); color: #fca5a5; }
.mock-badge { background: rgba(245,158,11,.22); color: #fcd34d; }
.role-badge { background: rgba(37,99,235,.18); color: #93c5fd; margin-left: 0.25rem; }

.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-error   { background: var(--color-error-bg);   color: var(--color-error); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-info    { background: var(--color-accent-bg);  color: var(--color-accent); }

/* ══════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5625rem 1.125rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition),
              border-color var(--transition), color var(--transition), transform 80ms ease;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
  line-height: 1;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; border-radius: var(--radius-md); }

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover  { background: var(--color-accent-hover); border-color: var(--color-accent-hover); box-shadow: var(--shadow-sm); }

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

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--color-surface-alt); color: var(--color-text); }

.btn-danger {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: var(--color-error-light);
}
.btn-danger:hover { background: var(--color-error-light); }

/* Sapience secondary (orange) — for high-emphasis CTAs only. Use sparingly;
   primary brand #2563EB remains the default for everyday actions. */
.btn-secondary-cta {
  background: var(--color-secondary);
  color: #fff;
  border-color: var(--color-secondary);
  box-shadow: var(--shadow-xs);
}
.btn-secondary-cta:hover {
  background: var(--color-secondary-hover);
  border-color: var(--color-secondary-hover);
  box-shadow: var(--shadow-sm);
}

/* ══════════════════════════════════════════════════════════════════
   PAGE HEADER
   ══════════════════════════════════════════════════════════════════ */
.page-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.page-header-actions { flex-shrink: 0; display: flex; gap: 0.5rem; align-items: flex-start; }

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.25rem;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  max-width: 640px;
  line-height: 1.55;
}

/* ══════════════════════════════════════════════════════════════════
   HERO (Home page)
   ══════════════════════════════════════════════════════════════════ */
.page-hero { margin-bottom: 2.5rem; }

.hero-section {
  text-align: center;
  padding: 3rem 1rem 2.5rem;
}

.hero-logo {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.875rem;
  line-height: 1;
}

.hero-title {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--color-brand);
  margin-bottom: 0.875rem;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--color-text-muted);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.65;
}

/* ── Status cards ───────────────────────────────────────────────── */
.stat-row {
  display: flex;
  gap: 0.875rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1.875rem 0 1.25rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.875rem 1.5rem;
  text-align: center;
  min-width: 130px;
  box-shadow: var(--shadow-sm);
}

.stat-card.stat-mock { border-color: #fcd34d; background: #fefce8; }
.stat-card.stat-live { border-color: #6ee7b7; background: #f0fdf4; }

.stat-value {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-text-subtle);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* Coloured stat values for history page */
.stat-value-accent  { color: var(--color-accent); }
.stat-value-success { color: var(--color-success); }
.stat-value-error   { color: var(--color-error); }

/* ── Feature grid ───────────────────────────────────────────────── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.feature-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition-slow);
}

.feature-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
  transform: translateY(-1px);
}

.feature-icon { font-size: 1.875rem; margin-bottom: 0.75rem; display: block; line-height: 1; }

.feature-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

.feature-desc { font-size: 0.8125rem; color: var(--color-text-muted); line-height: 1.55; }

/* ── Nav buttons ────────────────────────────────────────────────── */
.nav-button-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════════════════
   SECTION CARD
   ══════════════════════════════════════════════════════════════════ */
.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.section-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1.125rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}

/* ══════════════════════════════════════════════════════════════════
   BANNERS
   ══════════════════════════════════════════════════════════════════ */
.info-banner {
  background: var(--color-accent-bg);
  border: 1px solid var(--color-accent-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: #1e40af;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  line-height: 1.55;
}

.warning-info-banner, .warning-banner {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-light);
  border-left: 3px solid var(--color-warning);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: #92400e;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  line-height: 1.55;
}

.warnings-banner {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 3px solid #f97316;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: #c2410c;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.error-banner {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-light);
  border-left: 3px solid var(--color-error);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: #991b1b;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  line-height: 1.55;
}

.controlled-response-panel {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.controlled-response-title { font-size: 0.9375rem; font-weight: 600; color: var(--color-error); margin-bottom: 0.5rem; }
.controlled-response-message { font-size: 0.875rem; color: var(--color-text); margin-bottom: 0.75rem; line-height: 1.55; }
.controlled-response-action { font-size: 0.875rem; color: #b45309; margin-bottom: 0.5rem; }
.controlled-response-ref { font-size: 0.75rem; color: var(--color-text-muted); }

/* ══════════════════════════════════════════════════════════════════
   QUICK PROMPTS
   ══════════════════════════════════════════════════════════════════ */
.qp-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.qp-panel-header { display: flex; flex-direction: column; gap: 0.175rem; margin-bottom: 1rem; }
.qp-panel-title { font-size: 0.9375rem; font-weight: 600; color: var(--color-text); letter-spacing: -0.01em; }
.qp-panel-sub { font-size: 0.8rem; color: var(--color-text-muted); }

.qp-controls { display: flex; gap: 0.625rem; margin-bottom: 1rem; }

.qp-search, .qp-category {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface-alt);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.qp-search { flex: 1; }
.qp-category { min-width: 160px; }

.qp-search:focus, .qp-category:focus {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
  background: var(--color-surface);
}

.qp-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  margin-bottom: 0.5rem;
}

.qp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.qp-card {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.qp-card:hover { box-shadow: var(--shadow-sm); border-color: var(--color-border-strong); }

.qp-card-head { display: flex; align-items: flex-start; gap: 0.5rem; }
.qp-card-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.075rem; }
.qp-card-title { font-size: 0.875rem; font-weight: 600; color: var(--color-text); line-height: 1.35; }
.qp-card-body { font-size: 0.8rem; color: var(--color-text-muted); line-height: 1.5; }

.qp-card-actions { display: flex; gap: 0.35rem; margin-top: 0.25rem; }

.qp-ask-btn {
  flex: 1;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  font-family: inherit;
  font-weight: 500;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.qp-ask-btn:hover { background: var(--color-accent-hover); }

.qp-fav-btn {
  padding: 0.4rem 0.5rem;
  background: transparent;
  color: var(--color-text-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  transition: color var(--transition), border-color var(--transition);
}
.qp-fav-btn:hover { color: var(--color-warning); border-color: #fde68a; }
.qp-fav-btn.is-fav { color: var(--color-warning); }

.qp-empty { text-align: center; padding: 1.25rem; color: var(--color-text-muted); font-size: 0.875rem; }

/* ══════════════════════════════════════════════════════════════════
   CHAT
   ══════════════════════════════════════════════════════════════════ */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
}

.chat-msg { display: flex; flex-direction: column; max-width: 84%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; align-items: flex-start; max-width: 94%; }

.chat-bubble {
  padding: 0.75rem 1.125rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  line-height: 1.65;
  word-break: break-word;
}

.chat-msg.user .chat-bubble {
  background: var(--color-accent);
  color: #fff;
  border-bottom-right-radius: var(--radius-xs);
  box-shadow: var(--shadow-sm);
}

.chat-msg.assistant .chat-bubble {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-bottom-left-radius: var(--radius-xs);
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.chat-restored-badge {
  font-size: 0.6875rem;
  color: var(--color-text-subtle);
  padding: 0.2rem 0.5rem 0 0.25rem;
  font-style: italic;
  opacity: 0.7;
}

.chat-meta {
  font-size: 0.6875rem;
  color: var(--color-text-subtle);
  padding: 0.3rem 0.25rem;
  letter-spacing: 0.01em;
}

.chat-input-area {
  position: sticky;
  bottom: var(--footer-height);
  background: var(--color-bg);
  padding: 0.875rem 0;
  border-top: 1px solid var(--color-border);
}

.chat-form { display: flex; gap: 0.625rem; align-items: flex-end; }

.chat-textarea {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  resize: none;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  max-height: 130px;
  overflow-y: auto;
  box-shadow: var(--shadow-xs);
  line-height: 1.55;
}

.chat-textarea:focus { border-color: var(--color-accent); box-shadow: var(--shadow-focus); }
.chat-textarea::placeholder { color: var(--color-text-subtle); }

.chat-send-btn {
  padding: 0.75rem 1.125rem;
  flex-shrink: 0;
  align-self: flex-end;
  border-radius: var(--radius-lg);
}

.send-icon { font-size: 1rem; }
.chat-loading { padding: 0.875rem 0; }

/* Pipeline progress */
.pipeline-progress {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.pipeline-header { display: flex; align-items: center; gap: 0.625rem; margin-bottom: 0.875rem; }
.pipeline-title { font-size: 0.875rem; color: var(--color-text-muted); font-weight: 500; }

.pipeline-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--color-text-subtle);
  padding: 0.3rem 0;
  transition: color 0.2s ease;
}

.pipeline-step .step-icon { width: 1.25rem; text-align: center; flex-shrink: 0; font-size: 0.875rem; }
.pipeline-step.step-active { color: var(--color-accent); font-weight: 500; }
.pipeline-step.step-done { color: var(--color-text-2); }

/* ── Spinner ─────────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════
   MANIFEST / PRESENTATION
   ══════════════════════════════════════════════════════════════════ */
.manifest-title {
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 700;
  margin-bottom: clamp(0.2rem, 1vw, 0.5rem);
  letter-spacing: -0.015em;
}
.manifest-subtitle {
  font-size: clamp(0.75rem, 2vw, 1rem);
  color: var(--color-text-muted);
  margin-bottom: clamp(0.75rem, 2vw, 1.25rem);
}
.manifest-section {
  margin-bottom: clamp(1rem, 3vw, 2rem);
}

/* Phase 5D — Prompt 0 v3 signal chips row at the top of the manifest. */
.manifest-v3-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 clamp(0.75rem, 2vw, 1.25rem);
}
.manifest-section-title {
  font-size: clamp(0.875rem, 2vw, 1rem);
  font-weight: 600;
  margin-bottom: clamp(0.5rem, 2vw, 1rem);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(100px, 18vw, 200px), 1fr));
  gap: clamp(0.5rem, 2vw, 1rem);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: clamp(0.75rem, 3vw, 1.25rem);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-label {
  font-size: clamp(0.6rem, 1.5vw, 0.8rem);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: clamp(0.2rem, 1vw, 0.5rem);
}

.kpi-value {
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin-bottom: clamp(0.1rem, 1vw, 0.3rem);
}

.kpi-trend {
  font-size: clamp(0.7rem, 1.5vw, 0.9rem);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 500;
}
.kpi-trend.trend-up { color: var(--color-success); }
.kpi-trend.trend-down { color: var(--color-error); }
.kpi-trend.trend-neutral { color: var(--color-text-muted); }

.direct-answer {
  background: var(--color-surface-alt);
  border-left: 3px solid var(--color-accent);
  padding: 1rem 1.125rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--color-text);
}

.chart-placeholder {
  background: var(--color-surface-alt);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.chart-container {
  width: 100%;
  min-height: clamp(200px, 50vh, 500px);
}

.evidence-list { list-style: none; padding: 0; }

.evidence-item {
  padding: 0.5625rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.evidence-item:last-child { border-bottom: none; }

.warning-item {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.35rem 0;
  font-size: 0.8125rem;
  color: #92400e;
  line-height: 1.5;
}

.follow-up-section { margin-top: 1.125rem; }

.follow-up-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--color-accent);
  cursor: pointer;
  margin: 0.2rem 0.25rem 0 0;
  transition: background var(--transition), border-color var(--transition);
}

.follow-up-btn:hover { background: var(--color-accent-bg); border-color: var(--color-accent-border); }

/* ══════════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════════ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.75rem, 2vw, 0.95rem);
}

.data-table th {
  background: var(--color-surface-alt);
  border-bottom: 2px solid var(--color-border);
  padding: clamp(0.4rem, 1vw, 0.75rem) clamp(0.5rem, 1.5vw, 1rem);
  text-align: left;
  font-size: clamp(0.6rem, 1.5vw, 0.75rem);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.data-table td {
  padding: clamp(0.4rem, 1vw, 0.75rem) clamp(0.5rem, 1.5vw, 1rem);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
  line-height: 1.45;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--color-accent-bg); }

/* ══════════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════════ */
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex: 1;
  min-width: 160px;
}

.form-label { font-size: 0.8125rem; font-weight: 500; color: var(--color-text-2); }

.form-input {
  padding: 0.5625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.4;
}

.form-input:focus { border-color: var(--color-accent); box-shadow: var(--shadow-focus); }
.form-input::placeholder { color: var(--color-text-subtle); }
select.form-input { cursor: pointer; }
.form-actions { margin-top: 0.875rem; }

/* ══════════════════════════════════════════════════════════════════
   REPORT CARDS
   ══════════════════════════════════════════════════════════════════ */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(250px, 25vw, 320px), 1fr));
  gap: clamp(0.75rem, 2vw, 1.5rem);
}

.report-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition-slow);
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.report-card:hover { border-color: var(--color-accent-border); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.report-card.selected { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

.report-card-header { display: flex; align-items: center; gap: 0.875rem; }

.report-card-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent-bg);
  border-radius: var(--radius);
  border: 1px solid var(--color-accent-border);
}

.report-card-title { font-size: 0.9375rem; font-weight: 600; color: var(--color-text); letter-spacing: -0.01em; line-height: 1.3; }

.report-card-alias {
  font-size: 0.6875rem;
  color: var(--color-text-subtle);
  font-family: var(--font-mono);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  padding: 0.05rem 0.35rem;
  display: inline-block;
  margin-top: 0.2rem;
}

.report-card-desc { font-size: 0.8125rem; color: var(--color-text-muted); line-height: 1.55; flex: 1; }
.report-pipeline-note { display: none; } /* internal pipeline text — hidden from users */
.report-select-btn { margin-top: 0.25rem; font-size: 0.8125rem; padding: 0.4375rem 0.875rem; width: 100%; justify-content: center; }

.filter-form-container { margin-top: 0; }
.filter-form { display: flex; flex-direction: column; }

.report-result { padding: 0.5rem 0; }
.response-meta { font-size: 0.75rem; color: var(--color-text-subtle); padding: 0.4rem 0; margin-bottom: 0.5rem; letter-spacing: 0.01em; }

/* ══════════════════════════════════════════════════════════════════
   HISTORY
   ══════════════════════════════════════════════════════════════════ */
.history-stats-row { display: flex; gap: 0.875rem; flex-wrap: wrap; margin-bottom: 1.5rem; }

.history-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  min-width: 110px;
  box-shadow: var(--shadow-sm);
}

.history-stat-value { font-size: 1.625rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; }
.history-stat-label { font-size: 0.65rem; font-weight: 600; color: var(--color-text-subtle); margin-top: 0.25rem; text-transform: uppercase; letter-spacing: 0.07em; }
.history-question { max-width: 360px; word-break: break-word; }
.history-actions { padding: 1rem 0; display: flex; justify-content: flex-end; }

/* Thread list — server-backed grouped history */
.history-thread-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.history-thread-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--color-border);
  transition: background var(--transition);
}

.history-thread-row:first-child { border-top: none; }
.history-thread-row:hover { background: var(--color-surface-alt); }

.history-thread-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.history-thread-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-thread-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Star / favourite toggle button — matches .qp-fav-btn pattern */
.history-star-btn {
  flex-shrink: 0;
  padding: 0.3rem 0.4rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-text-subtle);
  line-height: 1;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.history-star-btn:hover {
  color: var(--color-warning);
  background: var(--color-warning-bg);
  border-color: var(--color-warning-light);
}

.history-star-btn.history-star-active { color: var(--color-warning); }

/* ── History — search bar ───────────────────────────────────────────────── */
.history-search-wrap {
  position: relative;
  margin-bottom: 1rem;
}
.history-search-input {
  width: 100%;
  padding: 0.55rem 0.9rem 0.55rem 2.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-primary);
  font-size: clamp(0.8rem, 0.75rem + 0.15vw, 0.875rem);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.history-search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.history-search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  pointer-events: none;
}

/* ── History — date group sections ─────────────────────────────────────── */
.history-group-section { margin-bottom: 1.25rem; }
.history-group-label {
  font-family: var(--font-heading);
  font-size: clamp(0.68rem, 0.65rem + 0.1vw, 0.75rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  padding-bottom: 0.4rem;
  margin-bottom: 0.2rem;
  border-bottom: 1px solid var(--color-border);
}

/* ── History — thread body (clickable area) ─────────────────────────────── */
.history-thread-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  cursor: pointer;
  padding: 0.1rem 0;
}
.history-thread-body:hover .history-thread-title { color: var(--color-accent); }
.history-feedback-chip {
  display: inline-flex;
  gap: 0.4rem;
  margin-left: 0.4rem;
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

/* "Open →" and "Ask again" action buttons in history rows */
.history-thread-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.history-open-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  opacity: 0;
  transition: opacity var(--transition);
}
.history-thread-row:hover .history-open-btn { opacity: 1; }

.history-reask-btn {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-accent);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
  vertical-align: middle;
}
tr:hover .history-reask-btn { opacity: 1; }
.history-reask-btn:hover { background: var(--color-accent); color: #fff; }

.history-question { cursor: pointer; }
tr:hover .history-question { color: var(--color-accent); }

/* Section card header row — flex layout for title + right-aligned meta */
.section-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

.section-card-header .section-card-title {
  margin-bottom: 0;
}

/* Usage/storage footer strip */
.history-usage-strip {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* ══════════════════════════════════════════════════════════════════
   DEBUG
   ══════════════════════════════════════════════════════════════════ */
.json-block {
  background: #0f172a;
  color: #94a3b8;
  padding: 1rem 1.125rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.65;
  box-shadow: var(--shadow-sm);
}

.flags-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 0; }
.flag-item { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8125rem; padding: 0.25rem 0; }
.session-ctx { padding: 0.5rem 0; }
.info-text { font-size: 0.875rem; color: var(--color-text-muted); padding: 0.5rem 0; line-height: 1.55; }
.error-text { color: var(--color-error); font-size: 0.875rem; }

/* ══════════════════════════════════════════════════════════════════
   FEEDBACK
   ══════════════════════════════════════════════════════════════════ */
.feedback-panel {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-top: 0.875rem;
  font-size: 0.875rem;
}

.feedback-title { font-size: 0.8rem; font-weight: 600; color: var(--color-text-muted); margin-bottom: 0.5rem; }
.feedback-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.feedback-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.775rem;
  font-family: var(--font-heading, inherit);
  font-weight: 500;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
.feedback-btn svg { flex-shrink: 0; }
.feedback-btn:hover {
  background: var(--color-accent-bg);
  border-color: var(--color-accent-border);
  color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,.08);
}
.feedback-btn.submitted { opacity: 0.45; cursor: default; }

.feedback-issue-form { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }

/* ── Response footer ─────────────────────────────────────────────── */
.response-scope-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 0.25rem 0.65rem;
  background: var(--color-surface-2, #f1f5f9);
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  font-size: 0.75rem;
  color: var(--color-text-2, #475569);
  width: fit-content;
}
.response-scope-icon { font-size: 0.8rem; flex-shrink: 0; }
.response-scope-text { font-weight: 500; }
.response-scope-inherited {
  font-size: 0.65rem;
  font-style: italic;
  color: var(--color-text-muted, #94a3b8);
  padding-left: 0.3rem;
}

.response-footer {
  border-top: 1px solid var(--color-border);
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.response-footer-row {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.45;
}
.response-footer-icon { font-size: 0.8125rem; flex-shrink: 0; }
.response-footer-disclaimer em { font-style: italic; }
.response-footer-feedback {
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
}
.response-footer-feedback-label { font-weight: 500; color: var(--color-text-2); }
.response-footer-feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.response-footer-feedback-btn:hover { background: var(--color-surface-alt); border-color: var(--color-border-strong); }
.response-footer-feedback-btn.submitted { opacity: 0.45; cursor: default; }

/* ── Evidence details ────────────────────────────────────────────── */
details.evidence-details {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 0.875rem;
}

details.evidence-details > summary {
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: background var(--transition);
}

details.evidence-details > summary:hover { background: var(--color-bg); }
details.evidence-details > summary::-webkit-details-marker { display: none; }
details.evidence-details[open] > summary { border-bottom: 1px solid var(--color-border); }
details.evidence-details .evidence-body { padding: 0.75rem 0.875rem; }

/* ── Export ──────────────────────────────────────────────────────── */
.export-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--color-border);
  align-items: center;
}

/* ══════════════════════════════════════════════════════════════════
   WELCOME CARD
   ══════════════════════════════════════════════════════════════════ */
.welcome-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 2.25rem 1.75rem;
  text-align: center;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.welcome-icon { font-size: 2.5rem; margin-bottom: 0.625rem; display: block; line-height: 1; }

/* SapienceIQ IQ logo in welcome card (matches brand image) */
.welcome-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  background: #fff;
  color: var(--color-secondary, #ec4e20);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.375rem;
  letter-spacing: -0.04em;
  border-radius: 16px;
  border: 2px solid #f1d8ce;
  box-shadow: 0 2px 8px rgba(236,78,32,.12);
  margin: 0 auto 1rem;
}

.welcome-title {
  font-family: var(--font-heading);
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.375rem);
  font-weight: 700;
  margin-bottom: 0.35rem;
  letter-spacing: -0.025em;
}
.welcome-desc {
  font-size: clamp(0.8rem, 0.75rem + 0.15vw, 0.875rem);
  color: var(--color-text-muted);
  max-width: 500px;
  margin: 0 auto 1.25rem;
  line-height: 1.65;
}

/* 2×2 suggestion cards grid */
.welcome-cards-grid {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem;
  max-width: 560px;
  margin: 0 auto;
  text-align: left;
}
.welcome-card-suggestion {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.875rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.welcome-card-suggestion:hover {
  border-color: var(--color-accent-border);
  background: var(--color-accent-bg);
  box-shadow: 0 2px 8px rgba(37,99,235,.1);
}
.welcome-card-icon { font-size: 1.125rem; line-height: 1; }
.welcome-card-q {
  font-family: var(--font-heading);
  font-size: clamp(0.78rem, 0.74rem + 0.12vw, 0.875rem);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.35;
}
.welcome-card-cat {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

/* ── Input bar left-action icons (D8) ──────────────────────────────── */
.chat-input-action-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.chat-input-action-btn:hover {
  background: var(--color-accent-bg);
  border-color: var(--color-accent-border);
  color: var(--color-accent);
}

/* Stop button red state */
.chat-send-btn.is-stop {
  background: #dc2626;
  border-color: #dc2626;
}
.chat-send-btn.is-stop:hover { background: #b91c1c; }

/* ── Sidebar collapse handle (D14) ─────────────────────────────────── */
.askiq-nav-collapse-handle {
  position: absolute;
  top: 50%;
  right: -12px;
  transform: translateY(-50%);
  z-index: 10;
  width: 24px; height: 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-muted);
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}
.askiq-nav-collapse-handle:hover {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  box-shadow: var(--shadow-md);
}

/* Collapsed sidebar state */
.askiq-nav.nav-collapsed {
  width: 0;
  overflow: hidden;
  min-width: 0;
  padding: 0;
}
.askiq-shell.nav-collapsed .askiq-chat-pane {
  margin-left: 0;
}

/* ── Header dropdown — full name + email (D2) ──────────────────────── */
.topbar-user-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.1rem 0 0.75rem;
}
.topbar-user-avatar-lg {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar-user-details { flex: 1; min-width: 0; }
.topbar-user-fullname {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-user-email {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-user-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
}
.topbar-user-tenant {
  font-size: 0.7rem;
  color: var(--color-text-subtle);
}
.topbar-user-session {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
  font-size: 0.72rem;
  color: var(--color-text-muted);
}
.topbar-session-label { font-weight: 500; }
.topbar-session-id { font-family: var(--font-mono); color: var(--color-text-subtle); }

/* ══════════════════════════════════════════════════════════════════
   AUTH PAGES
   ══════════════════════════════════════════════════════════════════ */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(145deg, #0f2d52 0%, #0f172a 55%, #1e1b4b 100%);
}

/* ══════════════════════════════════════════════════════════════════
   CANONICAL THREE-PANEL RESPONSE  (AskIqResponseV1)
   ══════════════════════════════════════════════════════════════════ */

/* ── Outer card ─────────────────────────────────────────────────── */
.canonical-response-card {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

/* ── Processing view (collapsible) ─────────────────────────────── */
.proc-panel {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.proc-panel > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  transition: background var(--transition);
}
.proc-panel > summary::-webkit-details-marker { display: none; }
.proc-panel > summary::before {
  content: "▸";
  font-size: 0.625rem;
  transition: transform var(--transition);
  flex-shrink: 0;
}
.proc-panel[open] > summary::before { transform: rotate(90deg); }
.proc-panel > summary:hover { background: var(--color-border); }

.proc-panel-title { font-weight: 500; color: var(--color-text-2); }

.proc-badge {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--color-accent-bg);
  color: var(--color-accent);
  border: 1px solid var(--color-accent-border);
  border-radius: var(--radius-full);
  padding: 0.1rem 0.5rem;
}

.proc-panel-body {
  padding: 0.5rem 0.875rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

/* Progress steps */
.proc-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.proc-step {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  padding: 0.2rem 0;
  color: var(--color-text-muted);
}
.proc-step--SUCCESS { color: var(--color-success); }
.proc-step--ERROR   { color: var(--color-error); }

.proc-step-icon { flex-shrink: 0; font-size: 0.75rem; margin-top: 0.15rem; }
.proc-step-msg  { color: inherit; }

/* Understanding chips */
.proc-understanding {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.proc-chip {
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.15rem 0.525rem;
  border-radius: var(--radius-full);
  text-transform: capitalize;
  letter-spacing: 0.01em;
  border: 1px solid;
}
.proc-chip--intent { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.proc-chip--route  { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.proc-chip--domain { background: var(--color-warning-bg); color: var(--color-warning); border-color: var(--color-warning-light); }

/* ── Multi-part question breakdown (detected_requests) ──────────── */
.proc-detected-requests {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-accent-bg);
  border: 1px solid var(--color-accent-border);
  border-radius: var(--radius-sm);
}

.proc-detected-requests-heading {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.proc-detected-requests-list {
  margin: 0;
  padding-left: 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.proc-detected-requests-list li {
  font-size: 0.8125rem;
  color: var(--color-text-2);
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════════
   LIVE PROGRESS PANEL (SSE real-time updates before response arrives)
   ══════════════════════════════════════════════════════════════════ */
.live-progress-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-accent-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.live-progress-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Method Summary ("How this answer was prepared") ──────────────────── */
.method-summary-block {
  margin-top: 14px;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 8px;
  background: var(--color-surface-2, #f8fafc);
  font-size: 0.8125rem;
  color: var(--color-text-2, #64748b);
}
.method-summary-toggle {
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.method-summary-toggle::-webkit-details-marker { display: none; }
.method-summary-toggle::before {
  content: "ℹ";
  color: var(--color-accent, #2563eb);
  font-style: normal;
}
.method-summary-list {
  margin: 0;
  padding: 2px 14px 10px 30px;
  list-style: disc;
  line-height: 1.6;
}
.method-summary-item { margin: 2px 0; }

.live-progress-question {
  font-size: 0.8125rem;
  color: var(--color-text-1);
  font-style: italic;
  margin: 0.25rem 0 0.5rem 0;
  padding: 0.25rem 0.5rem;
  border-left: 3px solid var(--color-accent);
  background: var(--color-surface-2, #f8fafc);
  border-radius: 0 4px 4px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-progress-spinner {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  animation: spin 1.4s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Stop spinning once replaced by ✅ */
.live-progress-panel[data-done] .live-progress-spinner { animation: none; }

.live-progress-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-2);
  flex: 1;
}

.live-progress-percent {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
  min-width: 2.75rem;
  text-align: right;
}

.live-progress-bar {
  height: 5px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.live-progress-bar-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width 400ms ease;
  min-width: 4px;
}

.live-progress-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  /* No max-height — let all steps show without a scrollbar */
}

.live-progress-step {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  padding: 0.1rem 0;
  transition: color var(--transition);
}

.live-progress-step--done      { color: var(--color-success); }
.live-progress-step--completed { color: var(--color-success); }
.live-progress-step--loading   { color: var(--color-accent);  }
.live-progress-step--info      { color: var(--color-accent);  }
.live-progress-step--in_progress { color: var(--color-accent); }
.live-progress-step--error     { color: var(--color-error);   }
.live-progress-step--failed    { color: var(--color-error);   }

.live-progress-step-icon {
  flex-shrink: 0;
  font-size: 0.75rem;
  margin-top: 0.175rem;
}

@keyframes pulse-icon {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.live-progress-step-icon--pulse {
  animation: pulse-icon 1s ease-in-out infinite;
}

.live-progress-step-msg { color: inherit; }

/* ── Live insight cards (understanding + plan, shown during live progress) ── */
/* Wrapper list item keeps the card inside the ordered step flow so it renders
   in arrival sequence rather than pinned to the bottom of the list. */
.live-insight-card-li {
  list-style: none;
  margin: 0;
  padding: 0;
}
.live-insight-card {
  margin: 0.5rem 0 0.25rem;
  padding: 0.5rem 0.75rem;
  background: #eff6ff;
  border-left: 3px solid var(--color-accent, #2563eb);
  border-radius: 4px;
  font-size: 0.8125rem;
}
.live-insight-card-header {
  font-weight: 600;
  color: var(--color-accent, #2563eb);
  margin-bottom: 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.live-insight-card-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
}
.live-insight-row {
  background: #fff;
  border: 1px solid #bfdbfe;
  border-radius: 99px;
  padding: 0.1rem 0.55rem;
  color: var(--color-text-1, #1e293b);
  font-size: 0.75rem;
}

/* ── Processing view output expectation ────────────────────────── */
.proc-output-expectation {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.8rem;
  color: var(--color-text-muted, #6b7280);
}
.proc-output-expectation-label {
  font-weight: 600;
}

/* ── Processing view understanding summary ─────────────────────── */
.proc-understanding-summary {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--color-text-muted, #6b7280);
  font-style: italic;
}

/* ── Final response panel ───────────────────────────────────────── */
.final-response-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.final-response-body {
  padding: 1rem 1.125rem;
}

.response-section {
  margin-bottom: 1rem;
}
.response-section:last-child { margin-bottom: 0; }

.response-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-2);
  margin-bottom: 0.5rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--color-border);
}

/* ── Action bar ─────────────────────────────────────────────────── */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.625rem 1.125rem;
  background: var(--color-surface-alt);
  border-top: 1px solid var(--color-border);
}

.action-bar.hidden { display: none; }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.action-btn:hover {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  border-color: var(--color-accent-border);
}
.action-btn:active { opacity: 0.8; }

.action-btn-icon { font-size: 0.8em; }

/* Toast notification for action feedback */
.action-toast {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--color-text);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  white-space: nowrap;
  z-index: 100;
}
.action-bar { position: relative; }
.action-toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Governance view (admin only) ───────────────────────────────── */
.gov-panel {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  border-left: 3px solid var(--color-warning);
}

.gov-panel > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-warning);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.gov-panel > summary::-webkit-details-marker { display: none; }
.gov-panel > summary::before { content: "▸"; transition: transform var(--transition); }
.gov-panel[open] > summary::before { transform: rotate(90deg); }

.gov-panel-body {
  padding: 0.625rem 0.875rem 0.75rem;
}

.gov-trace-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 0.75rem;
  font-size: 0.75rem;
}

.gov-trace-list dt {
  color: var(--color-text-muted);
  font-weight: 500;
}

.gov-trace-list dd {
  font-family: var(--font-mono);
  color: var(--color-text);
  word-break: break-all;
}

.gov-exception {
  margin-top: 0.5rem;
  padding: 0.4rem 0.65rem;
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-light);
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  color: var(--color-error);
}

/* ══════════════════════════════════════════════════════════════════
   STANDALONE RESPONSE PAGE  (/response/{id})
   ══════════════════════════════════════════════════════════════════ */

body.standalone-page {
  background: var(--color-bg);
}

.standalone-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

.standalone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
}

.standalone-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-brand);
}

.standalone-brand-icon { font-size: 1.25rem; }

.standalone-back-link {
  font-size: 0.8125rem;
  color: var(--color-accent);
}

.standalone-main {
  flex: 1;
  padding-bottom: 2rem;
}

.standalone-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.standalone-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  padding: 2rem 0;
}

.standalone-error-msg {
  color: var(--color-error);
  font-size: 0.9375rem;
}

.standalone-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.standalone-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.standalone-section-title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

.standalone-footer {
  border-top: 1px solid var(--color-border);
  padding: 0.75rem 0;
  font-size: 0.75rem;
  color: var(--color-text-subtle);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
}

.auth-logo { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.375rem; }
.auth-logo-icon { font-size: 2.25rem; color: var(--color-accent); line-height: 1; }
.auth-logo-text { font-size: 2rem; font-weight: 800; color: var(--color-brand); letter-spacing: -0.04em; }

.auth-title { font-size: 1.25rem; font-weight: 700; color: var(--color-text); margin: 0; letter-spacing: -0.02em; }
.auth-subtitle { font-size: 0.875rem; color: var(--color-text-muted); margin: 0; line-height: 1.55; }

.auth-error {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-light);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: #991b1b;
  font-size: 0.8125rem;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.5;
}

.auth-btn-microsoft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.8125rem 1.25rem;
  margin-top: 0.375rem;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.auth-btn-microsoft:hover {
  background: var(--color-surface-alt);
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
  text-decoration: none;
}

.auth-success-icon {
  width: 52px; height: 52px;
  background: var(--color-success-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.375rem; color: var(--color-success); font-weight: 700;
  margin-bottom: 0.25rem;
}

.auth-footer { font-size: 0.75rem; color: var(--color-text-subtle); margin: 0.125rem 0 0; line-height: 1.55; }

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR TOGGLE + OVERLAY (mobile)
   ══════════════════════════════════════════════════════════════════ */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 40px; height: 40px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 8px;
  margin-bottom: 0.875rem;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
  flex-shrink: 0;
}

.sidebar-toggle:hover { box-shadow: var(--shadow-sm); border-color: var(--color-border-strong); }

.sidebar-toggle span {
  display: block;
  width: 16px; height: 1.5px;
  background: var(--color-text-muted);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ══════════════════════════════════════════════════════════════════
   FOCUS INDICATORS
   ══════════════════════════════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* ══════════════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }
.mono-sm {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
code {
  background: var(--color-surface-alt);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-xs);
  font-size: 0.85em;
  font-family: var(--font-mono);
  color: var(--color-text-2);
  border: 1px solid var(--color-border);
}

/* ══════════════════════════════════════════════════════════════════
   ASKIQ SHELL — Two-column chat layout (matches operation-intelligence.html)
   Left: sticky question navigator (280px)
   Right: chat pane (flex column)
   ══════════════════════════════════════════════════════════════════ */
.askiq-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  height: calc(100dvh - var(--header-height) - var(--footer-height) - 2 * clamp(1rem, 3vw, 1.75rem));
  min-height: 500px;
}

/* ── Ask page: shell fills the full viewport between topbar and footer ─ */
body.page-ask .main-content-topnav {
  padding: 0;
  max-width: none;
}
body.page-ask .askiq-shell {
  /* 56px fixed topbar + 36px fixed footer */
  height: calc(100dvh - 56px - 36px);
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  box-shadow: none;
  min-height: 0;
}

/* ── Left: Question navigator sidebar ───────────────────────────── */
.askiq-nav {
  position: relative; /* anchors collapse handle */
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
  transition: width var(--transition-md, 220ms ease);
  /* height is inherited from the grid row (askiq-shell sets height) */
}

/* Mobile drawer toggle (hidden on desktop) */
.askiq-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text);
  flex-shrink: 0;
  transition: background var(--transition);
}
.askiq-nav-toggle:hover { background: var(--color-surface-alt); }

/* Backdrop — made visible by JS when the nav drawer is open on mobile */
.askiq-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 399;
  cursor: pointer;
}

/* Quick Find */
.qnav-find {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.qnav-find-label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-subtle);
  margin-bottom: 8px;
}

.qnav-find-wrap {
  display: flex;
  align-items: center;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 4px 10px;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.qnav-find-wrap:focus-within {
  border-color: var(--color-accent);
  background: var(--color-surface);
  box-shadow: var(--shadow-focus);
}

.qnav-search-ico { width: 14px; height: 14px; color: var(--color-text-subtle); flex: 0 0 auto; }

.qnav-find-input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  min-width: 0;
}
.qnav-find-input::placeholder { color: var(--color-text-subtle); }

.qnav-clear-btn {
  background: none;
  border: none;
  color: var(--color-text-subtle);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
}
.qnav-clear-btn:hover { color: var(--color-text); }

.qnav-find-hint {
  font-size: 11px;
  color: var(--color-text-subtle);
  margin-top: 6px;
  line-height: 1.4;
}

/* Category list header */
.qnav-cats-header {
  padding: 10px 18px 6px;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-subtle);
  flex-shrink: 0;
}

/* Category accordion */
.askiq-cat {
  border-bottom: 1px solid var(--color-border);
}

.askiq-cat-head {
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--color-text);
  user-select: none;
  transition: background var(--transition), color var(--transition);
}
.askiq-cat-head:hover { background: var(--color-surface-alt); }
.askiq-cat-head.active { color: var(--color-accent); background: var(--color-accent-bg); }

.cat-icon {
  flex: 0 0 auto;
  font-size: 0.9rem;
  margin-right: 4px;
}
.cat-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-count {
  flex: 0 0 auto;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 400;
  font-family: var(--font-primary);
  margin: 0 6px;
}
.cat-caret {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.askiq-cat-questions {
  display: none;
  padding: 4px 10px 10px;
}
.askiq-cat.open .askiq-cat-questions { display: block; }

/* Question chips (text + star button) */
.question-chip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: 2px;
  line-height: 1.35;
  transition: background var(--transition), color var(--transition);
}
.question-chip:hover { background: var(--color-surface-alt); color: var(--color-text); }

.qchip-star {
  flex: 0 0 auto;
  color: var(--color-text-subtle);
  font-size: 14px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color var(--transition);
}
.qchip-star:hover { color: var(--color-warning); }
.qchip-star.is-fav { color: var(--color-warning); }

.qchip-text {
  flex: 1;
  cursor: pointer;
}

/* Search results */
.qnav-results { padding: 6px 8px; }

.qnav-result {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background var(--transition);
}
.qnav-result:hover { background: var(--color-surface-alt); }

.qnav-result-text {
  font-size: 13px;
  color: var(--color-text);
  line-height: 1.35;
}
.qnav-result-text mark {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  font-weight: 600;
  padding: 0 2px;
  border-radius: 3px;
}

.qnav-result-cat {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-heading);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--color-accent);
  background: var(--color-accent-bg);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  align-self: flex-start;
}

.qnav-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 12.5px;
}

/* ── Right: Chat pane ────────────────────────────────────────────── */
.askiq-chat-pane {
  display: flex;
  flex-direction: column;
  background: var(--color-surface-alt);
  min-height: 0;
  overflow: hidden;
}

.askiq-chat-toolbar {
  padding: 14px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 1rem;
}

.askiq-chat-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}
.askiq-chat-sub {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* Override chat messages inside the shell — full width, padded */
.askiq-chat-pane .chat-messages {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Executive summary block rendered above the main response content */
.final-response-summary {
  background: var(--color-surface);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.final-response-summary-text {
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.6;
  margin: 0;
}
.final-response-summary-highlights {
  margin: 0.5rem 0 0 1rem;
  padding: 0;
  list-style: disc;
}
.final-response-summary-highlights li {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: 0.2rem;
}

/* Data period / coverage badge — shown below summary, above content sections */
.data-period-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.5rem 0 0.75rem;
  padding: 0.25rem 0.65rem 0.25rem 0.5rem;
  background: var(--color-accent-bg, #eff6ff);
  border: 1px solid var(--color-accent-border, #bfdbfe);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-accent-text, #1d4ed8);
  white-space: nowrap;
}
.data-period-icon {
  font-size: 0.8rem;
  line-height: 1;
}
.data-period-label {
  letter-spacing: 0.01em;
}

.askiq-chat-pane .chat-msg.assistant {
  max-width: 100%;
}

/* Chat input area inside the shell */
.askiq-input-area {
  position: relative;
  bottom: auto;
  padding: 0.875rem 1.5rem 1rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* Welcome card inside the chat pane */
.askiq-chat-pane .welcome-card {
  margin: 1.5rem;
  margin-bottom: 0;
}

/* ── Improved KPI cards (professional spacing + accent indicator) ── */
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-lg);
  padding: clamp(0.875rem, 2.5vw, 1.25rem);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform 150ms ease;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Full-width canonical response inside assistant bubble */
.canonical-response-card {
  width: 100%;
}

/* Action bar sits at the TOP of the response panel */
.final-response-panel > .action-bar {
  border-bottom: 1px solid var(--color-border);
  padding: 0.5rem 0.875rem;
  background: var(--color-surface-alt);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE  (Phase 5 D3 — breakpoints: 1440 / 1024 / 768 / 480)
   ══════════════════════════════════════════════════════════════════ */

/* Large desktop (≥1440) — cap content width so long lines stay readable. */
@media (min-width: 1440px) {
  .main-content {
    /* Sidebar width is 256px; remaining viewport must cap at 1280px to keep
       chart/table readability consistent on 4K and 27" displays. */
    max-width: calc(var(--sidebar-width) + 1280px);
  }
  /* Top-nav layout: cap content at 1280px with auto side margins */
  .main-content-topnav {
    max-width: 1280px;
    margin-inline: auto;
  }
  .hero-title { font-size: 3rem; }
  .feature-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}

@media (max-width: 1024px) {
  .main-content { padding: 1.5rem 1.75rem 5rem; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .sidebar-toggle { display: flex; }

  .main-content { margin-left: 0; }
  .app-footer { left: 0; }

  .feature-grid { grid-template-columns: 1fr 1fr; }
  .qp-grid { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .page-header { margin-bottom: 1.25rem; padding-bottom: 0.875rem; }
  .chat-msg, .chat-msg.assistant { max-width: 98%; }
  .qp-controls { flex-direction: column; }
  .qp-category { min-width: unset; }

  /* Top-nav responsive: hide brand subtitle, keep IQ logo + title */
  .topbar-brand-sub { display: none; }
  .topbar-meta { padding: 0 0.5rem; gap: 0.25rem; }
  .topbar-brand { padding: 0 0.75rem; gap: 0.5rem; }
  .topbar-icon-btn { width: 26px; height: 26px; font-size: 0.875rem; }

  /* AskIQ shell — single-column; nav becomes a slide-in drawer */
  .askiq-shell {
    grid-template-columns: 1fr;
    height: calc(100dvh - 56px - 36px);
    min-height: 400px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  /* Remove the ask-page override padding (already 0 on desktop) */
  body.page-ask .main-content-topnav { padding: 0; }
  .askiq-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 85vw);
    max-height: 100vh;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    border-right: 1px solid var(--color-border);
  }
  .askiq-nav.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  .askiq-nav-toggle { display: flex; }
}

@media (max-width: 480px) {
  .feature-grid { grid-template-columns: 1fr; }
  .stat-row { gap: 0.5rem; }
  .nav-button-row { flex-direction: column; }
  .nav-button-row .btn { width: 100%; justify-content: center; }
  .page-header-row { flex-direction: column; gap: 0.75rem; }

  /* Top-nav on small phones: hide badge + icon labels, compress tabs */
  .topbar-meta .env-badge,
  .topbar-meta .mock-badge { display: none; }
  .topbar-icon-btn { display: none; }
  .topbar-brand-title { font-size: 0.8125rem; }
  .topbar-tabs { padding: 0 0.25rem; }
  .iqai-tab { padding: 0 0.65rem; font-size: 0.8125rem; }
}

/* ── Print mode ──────────────────────────────────────────────────── */
@media print {
  .sidebar, .ask-sidebar, .top-header, .action-bar,
  .response-footer, .ask-input-area, .progress-container,
  .gov-panel, .tab-bar, .tab-content:not(.tab-content--active),
  button, .btn, .icon-btn, .action-btn,
  .response-scope-chip .response-scope-inherited { display: none !important; }

  body, html { background: #fff !important; font-size: 12pt !important; }
  .main-area, .content-area { margin: 0 !important; padding: 0 !important; }
  .response-panel { box-shadow: none !important; border: none !important; page-break-inside: avoid; }
  .response-panel pre, .response-panel table { page-break-inside: avoid; }
  a[href]::after { content: none !important; }
}

/* ─────────────────────────────────────────────────────────────────────────
 * Clarification card — User Understanding Card produced by the Confirmation
 * Gate. Rendered inside .final-response-panel when finalResponse.controlledResponseCode
 * is "CLARIFICATION_REQUIRED". No data widgets are rendered for this turn.
 * ───────────────────────────────────────────────────────────────────────── */
.clarification-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-radius: 0.75rem;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e5e7eb);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
}
.clarification-card--high   { border-left: 4px solid var(--color-warning, #f59e0b); }
.clarification-card--medium { border-left: 4px solid var(--color-info, #3b82f6); }
.clarification-card--low    { border-left: 4px solid var(--color-border, #d1d5db); }

.clarification-card-header { display: flex; flex-direction: column; gap: 0.25rem; }
.clarification-card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-text, #111827);
  margin: 0;
}
.clarification-card-subtitle {
  font-size: 0.8125rem;
  color: var(--color-text-muted, #6b7280);
  margin: 0;
}
.clarification-card-primary-reason {
  font-size: 0.9375rem;
  color: var(--color-text, #111827);
  line-height: 1.5;
  margin: 0;
}

.clarification-card-fields {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1rem;
  row-gap: 0.5rem;
  margin: 0;
  font-size: 0.875rem;
}
.clarification-card-field {
  display: contents;
}
.clarification-card-field-label {
  color: var(--color-text-muted, #6b7280);
  font-weight: 500;
}
.clarification-card-field-value {
  color: var(--color-text, #111827);
  margin: 0;
}

.clarification-card-assumptions {
  background: var(--color-surface-2, #f9fafb);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}
.clarification-card-assumptions-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  margin: 0 0 0.5rem 0;
}
.clarification-card-assumptions ul {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text, #111827);
}
.clarification-card-assumptions li { margin: 0.125rem 0; }

.clarification-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.clarification-card-option {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.875rem;
  border-radius: 0.375rem;
  border: 1px solid var(--color-border, #d1d5db);
  background: var(--color-surface, #fff);
  color: var(--color-text, #111827);
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.clarification-card-option:hover {
  background: var(--color-surface-2, #f3f4f6);
  border-color: var(--color-primary, #2563eb);
}
.clarification-card-option:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  border-color: var(--color-primary, #2563eb);
}
.clarification-card-option[data-option-id="continue"] {
  background: var(--color-primary, #2563eb);
  color: #fff;
  border-color: var(--color-primary, #2563eb);
}
.clarification-card-option[data-option-id="continue"]:hover {
  background: var(--color-primary-hover, #1d4ed8);
  border-color: var(--color-primary-hover, #1d4ed8);
}

@media (max-width: 480px) {
  .clarification-card { padding: 1rem; }
  .clarification-card-fields {
    grid-template-columns: 1fr;
    row-gap: 0.25rem;
  }
  .clarification-card-field-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.025em; }
  .clarification-card-actions { flex-direction: column; }
  .clarification-card-option { width: 100%; }
}

/* ── Chat ask input — the core interaction surface ── */
.iq-ask-area {
  position: relative;
}
.iq-ask-input {
  width: 100%; padding: 16px 60px 16px 20px;
  font-size: var(--iqai-fs-md, 15px);
  border: 2px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface);
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
  resize: none; min-height: 56px; max-height: 160px;
  font-family: var(--font-primary);
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(15,23,42,0.06);
}
.iq-ask-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.1), 0 2px 8px rgba(15,23,42,0.06);
  outline: none;
}
.iq-ask-submit {
  position: absolute; right: 10px; bottom: 10px;
  width: 36px; height: 36px;
  background: var(--color-accent);
  border: none; border-radius: 9px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  transition: background 0.18s, transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
}
.iq-ask-submit:hover {
  background: var(--color-accent-hover);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(37,99,235,0.35);
}
.iq-ask-submit:active { transform: scale(0.96); }

/* ── Response entry animation ── */
.iq-response-block {
  animation: iqai-rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.iq-response-section {
  animation: iqai-rise 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.iq-response-section:nth-child(2) { animation-delay: 0.06s; }
.iq-response-section:nth-child(3) { animation-delay: 0.12s; }
.iq-response-section:nth-child(4) { animation-delay: 0.18s; }

/* ── Report card ── */
.iq-report-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15,23,42,0.05), 0 8px 24px rgba(15,23,42,0.03);
  margin-bottom: var(--iqai-s5, 20px);
}
.iq-report-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  background: linear-gradient(135deg, var(--color-accent-bg) 0%, rgba(255,255,255,0) 100%);
  display: flex; align-items: center; gap: 10px;
}
.iq-report-card-header h3 {
  margin: 0; font-size: 0.9375rem; font-weight: 600; color: var(--color-accent-hover);
}
.iq-report-card-body { padding: 20px; }

/* ── Chat message bubbles ── */
.iq-msg-user {
  display: flex; justify-content: flex-end; margin-bottom: 16px;
}
.iq-msg-user-bubble {
  max-width: 72%;
  background: var(--color-accent);
  color: #fff;
  padding: 11px 16px;
  border-radius: 16px 16px 4px 16px;
  font-size: var(--iqai-fs-base, 14px);
  line-height: 1.55;
  box-shadow: 0 2px 8px rgba(37,99,235,0.2);
}
.iq-msg-ai { margin-bottom: 16px; }

/* ── Source citation chips ── */
.iq-source-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  font-size: 11px; font-weight: 500; color: var(--color-text-muted);
  cursor: default;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.iq-source-chip:hover {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  border-color: var(--color-accent-border);
}

/* ── Thinking/loading indicator ── */
.iq-thinking {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px;
  color: var(--color-text-muted); font-size: 0.875rem;
}
.iq-thinking-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--color-accent);
  animation: iqai-think-bounce 1.2s infinite ease-in-out;
}
.iq-thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.iq-thinking-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes iqai-think-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Voice input — Sapience Blue (#2563EB) / Poppins labels ─────────────── */

/* Wrapper that holds textarea OR recording row */
.chat-input-text-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  width: 100%;
}

/* Mic and TTS icon buttons — Sapience brand accent on hover */
.chat-voice-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-subtle);
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s, box-shadow 0.18s;
  padding: 0;
}
.chat-voice-btn:hover {
  color: #2563EB;
  border-color: #2563EB;
  background: rgba(37, 99, 235, 0.06);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}
.chat-voice-btn:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 2px;
}
.chat-voice-btn.is-active {
  color: #2563EB;
  border-color: #2563EB;
  background: rgba(37, 99, 235, 0.09);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  animation: voice-btn-pulse 1.6s ease-in-out infinite;
}
@keyframes voice-btn-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
  50%       { box-shadow: 0 0 0 6px rgba(37,99,235,0.08); }
}

/* ── Recording row (replaces text row) ────────────────────────────────── */
.chat-recording-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-xs);
  min-height: 3rem;
}

/* Dotted waveform — animated dots in the centre */
.recording-waveform {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}
/* Waveform bars use Sapience Orange (#EC4E20) during recording — makes
   the active state unmistakably distinct from the idle blue input */
.rbar {
  display: inline-block;
  width: 4px;
  border-radius: 2px;
  background: #EC4E20;
  opacity: 0.75;
  animation: rbar-pulse 0.8s ease-in-out infinite alternate;
  min-height: 4px;
}
/* Stagger heights so it looks like a live waveform */
.rbar:nth-child(1)  { height: 8px;  animation-delay: 0.00s; }
.rbar:nth-child(2)  { height: 14px; animation-delay: 0.06s; }
.rbar:nth-child(3)  { height: 20px; animation-delay: 0.12s; }
.rbar:nth-child(4)  { height: 16px; animation-delay: 0.18s; }
.rbar:nth-child(5)  { height: 24px; animation-delay: 0.24s; }
.rbar:nth-child(6)  { height: 18px; animation-delay: 0.30s; }
.rbar:nth-child(7)  { height: 28px; animation-delay: 0.36s; }
.rbar:nth-child(8)  { height: 22px; animation-delay: 0.42s; }
.rbar:nth-child(9)  { height: 28px; animation-delay: 0.48s; }
.rbar:nth-child(10) { height: 20px; animation-delay: 0.54s; }
.rbar:nth-child(11) { height: 24px; animation-delay: 0.60s; }
.rbar:nth-child(12) { height: 16px; animation-delay: 0.66s; }
.rbar:nth-child(13) { height: 20px; animation-delay: 0.72s; }
.rbar:nth-child(14) { height: 12px; animation-delay: 0.78s; }
.rbar:nth-child(15) { height: 8px;  animation-delay: 0.84s; }

@keyframes rbar-pulse {
  from { transform: scaleY(0.35); opacity: 0.5; }
  to   { transform: scaleY(1.00); opacity: 1.0; }
}

/* Timer */
.recording-timer {
  font-size: 0.8125rem;
  font-family: var(--font-mono, monospace);
  color: var(--color-text-subtle);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Cancel (×) and Confirm (✓) action buttons */
.chat-rec-action {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.chat-rec-action:active { transform: scale(0.93); }

.chat-rec-cancel {
  background: var(--color-bg, #f4f6fb);
  color: var(--color-text-subtle);
  border: 1px solid var(--color-border);
}
.chat-rec-cancel:hover { background: var(--color-surface-hover, #e8ecf4); color: var(--color-text); }

.chat-rec-confirm {
  background: #2563EB;   /* Sapience Blue */
  color: #fff;
  font-family: 'Poppins', 'Segoe UI', sans-serif;
}
.chat-rec-confirm:hover { background: #1D4ED8; box-shadow: 0 2px 8px rgba(37,99,235,0.3); }

/* ── Work Insights page ─────────────────────────────────────────────────── */
.insights-kpi-strip {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.insights-kpi-card {
  flex: 1;
  min-width: 140px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.insights-kpi-value {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--color-accent);
}
.insights-kpi-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.insights-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.insights-category-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.insights-category-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}
.insights-category-icon { font-size: 1rem; flex-shrink: 0; }
.insights-category-title { font-weight: 600; font-size: 0.875rem; flex: 1; }
.insights-category-count {
  font-size: 0.7rem;
  background: var(--color-accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  font-weight: 600;
}
.insights-question-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
}
.insights-question-item { border-top: 1px solid var(--color-border-subtle, #f0f0f0); }
.insights-question-item:first-child { border-top: none; }
.insights-question-btn {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.65rem 1rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background var(--transition);
}
.insights-question-btn:hover { background: var(--color-surface-alt); }
.insights-question-text {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--color-text);
  line-height: 1.4;
}
.insights-question-arrow {
  font-size: 0.75rem;
  color: var(--color-accent);
  opacity: 0;
  transition: opacity var(--transition);
}
.insights-question-btn:hover .insights-question-arrow { opacity: 1; }
.insights-ask-strip {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
}
.insights-ask-input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

/* ── History search bar ─────────────────────────────────────────────────── */
.history-search-wrap {
  position: relative;
  margin-bottom: 1rem;
}
.history-search-input {
  width: 100%;
  padding: 0.55rem 0.9rem 0.55rem 2.2rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--color-surface);
}
.history-search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  pointer-events: none;
}
.history-group-section { margin-bottom: 1rem; }
