/* ============================================================
   DESIGN TOKENS
============================================================ */
:root {
  --bg:            #05050A;
  --bg-raised:     #0D0D14;
  --bg-panel:      #13131C;
  --bg-card:       #1A1A25;
  --bg-input:      #0F0F18;
  --bg-chat:       #0C0C16;
  --text:          #EAEAF4;
  --text-2:        #9292AE;
  --text-3:        #50506A;
  --border:        rgba(255,255,255,0.06);
  --border-2:      rgba(255,255,255,0.11);
  --accent:        #5B7FFF;
  --accent-2:      #9B6DFF;
  --accent-bg:     rgba(91,127,255,0.10);
  --accent-bg2:    rgba(91,127,255,0.18);
  --user-msg:      linear-gradient(155deg,#5B7FFF 0%,#4A6DE8 100%);
  --success:       #2ECC8A;
  --warn:          #F59E0B;
  --danger:        #EF4444;
  --shadow:        0 10px 44px rgba(0,0,0,0.55);
  --shadow-sm:     0 3px 18px rgba(0,0,0,0.35);
  --shadow-xs:     0 1px 6px rgba(0,0,0,0.25);
  --sb-w:          264px;
  --topbar-h:      52px;
  --r-xl:          20px;
  --r-lg:          16px;
  --r-md:          12px;
  --r-sm:          8px;
}
[data-theme="light"] {
  --bg:            #E8E8EF;
  --bg-raised:     #F6F6FA;
  --bg-panel:      #FFFFFF;
  --bg-card:       #FFFFFF;
  --bg-input:      #FAFAFE;
  --bg-chat:       #FFFFFF;
  --text:          #0C0C18;
  --text-2:        #505068;
  --text-3:        #9292AA;
  --border:        rgba(0,0,0,0.07);
  --border-2:      rgba(0,0,0,0.12);
  --accent-bg:     rgba(91,127,255,0.08);
  --accent-bg2:    rgba(91,127,255,0.14);
  --shadow:        0 8px 32px rgba(0,0,0,0.09);
  --shadow-sm:     0 2px 10px rgba(0,0,0,0.06);
  --shadow-xs:     0 1px 4px rgba(0,0,0,0.05);
}

/* ============================================================
   RESET
============================================================ */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 160ms ease, color 160ms ease;
}
button { cursor: pointer; font: inherit; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; outline: none; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }

/* ============================================================
   APP SHELL
============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sb-w) 1fr;
  grid-template-rows: 1fr;
  height: 100vh;   /* fallback for browsers without dvh */
  height: 100dvh;  /* excludes the mobile URL bar, which 100vh does not */
  width: 100vw;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
============================================================ */
.sidebar {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;   /* fallback for browsers without dvh */
  height: 100dvh;  /* excludes the mobile URL bar, which 100vh does not */
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: transform 240ms cubic-bezier(.4,0,.2,1);
}

.sb-brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
}
.sb-brand-mark {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(91,127,255,0.42);
}
.sb-brand-mark svg { width: 14px; height: 14px; }
.sb-brand-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.sb-brand-copy span {
  display: block;
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 1px;
  font-weight: 500;
}

/* Scrollable nav section */
.sb-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px 4px;
}
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }

.sb-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 10px 5px;
}
.sb-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.sb-group-label:first-child { padding-top: 8px; }

.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px 8px 11px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 130ms ease, color 130ms ease, box-shadow 130ms ease;
  cursor: pointer;
  position: relative;
}
.sb-item:hover {
  background: var(--bg-panel);
  color: var(--text);
}
.sb-item.active {
  background: linear-gradient(to right, rgba(91,127,255,0.14), rgba(91,127,255,0.03));
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}
.sb-item.active .sb-item-icon { color: var(--accent); }
.sb-item-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: var(--text-3);
  display: grid; place-items: center;
  transition: color 130ms ease;
}
.sb-item-icon svg {
  width: 15px; height: 15px;
  stroke: currentColor; fill: none;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.sb-item-copy { min-width: 0; flex: 1; }
.sb-item-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}
.sb-item-sub {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  line-height: 1.2;
}
.sb-item.active .sb-item-sub { color: rgba(91,127,255,0.6); }

/* Sidebar footer */
.sb-footer {
  flex: 0 0 auto;
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sb-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  gap: 10px;
}
.sb-control-meta { min-width: 0; }
.sb-control-meta strong { font-size: 12px; font-weight: 500; display: block; }
.sb-control-meta span { font-size: 11px; color: var(--text-3); display: block; margin-top: 1px; }

/* Theme toggle */
.theme-toggle {
  width: 44px; height: 24px;
  border-radius: 99px;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 160ms ease;
}
.theme-toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 160ms ease;
  box-shadow: 0 2px 6px rgba(91,127,255,0.44);
}
[data-theme="light"] .theme-toggle::after { transform: translateX(20px); }

/* Language switch */
.lang-switch {
  display: flex;
  border-radius: 99px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.lang-switch button {
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  transition: background 140ms ease, color 140ms ease;
}
.lang-switch button.active { background: var(--accent-bg2); color: var(--text); }

/* Sidebar overlay (mobile) */
.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.58);
  z-index: 98;
  backdrop-filter: blur(2px);
}
.sb-overlay.on { display: block; }

/* ============================================================
   MAIN PANEL
============================================================ */
.main {
  display: flex;
  flex-direction: column;
  height: 100vh;   /* fallback for browsers without dvh */
  height: 100dvh;  /* excludes the mobile URL bar, which 100vh does not */
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
}

/* ============================================================
   TOPBAR
============================================================ */
.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-raised) 78%, transparent);
  backdrop-filter: blur(14px);
  gap: 12px;
  z-index: 10;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.topbar-hamburger {
  display: none;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  align-items: center; justify-content: center;
  color: var(--text-2);
  flex-shrink: 0;
}
.topbar-hamburger svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

/* Live status badge */
.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 99px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 7px var(--success);
  animation: pulse-dot 2.2s infinite;
  flex-shrink: 0;
}
@keyframes pulse-dot { 0%,100%{opacity:1}50%{opacity:.3} }

/* Breadcrumb */
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.topbar-bc-group {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-bc-sep {
  font-size: 12px;
  color: var(--text-3);
  flex-shrink: 0;
}
.topbar-bc-flow {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-counter {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* New session button */
.new-session-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-panel);
  transition: border-color 140ms ease, color 140ms ease;
}
.new-session-btn:hover { border-color: var(--border-2); color: var(--text); }
.new-session-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

/* ============================================================
   CHAT STAGE
============================================================ */
.chat-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-chat);
  border-left: 1px solid var(--border);
}

/* Scrollable inner */
.chat-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  position: relative;
}
.chat-scroll::-webkit-scrollbar { width: 5px; }
.chat-scroll::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 99px;
  border: 1px solid transparent;
  background-clip: padding-box;
}

/* ============================================================
   WELCOME STATE — centered card
============================================================ */
.welcome {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.welcome.hidden { display: none; }
.welcome-body {
  width: 100%;
  max-width: 580px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Welcome container — borderless, layout only */
.welcome-card {
  width: 100%;
}
.welcome-card-top {
  padding: 28px 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Status pill */
.welcome-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px 5px 9px;
  border-radius: 99px;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 18px;
  letter-spacing: 0.01em;
}
.welcome-status .live-dot { animation: pulse-dot 2.2s infinite; }

/* Title */
.welcome-title {
  font-size: clamp(22px, 3.5vw, 36px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.08;
  margin-bottom: 10px;
  white-space: pre-line;
}
.welcome-desc {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  max-width: 440px;
  margin-bottom: 20px;
}

/* Stat strip */
.welcome-stats {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 20px;
}
.welcome-stat {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 6px 9px;
  text-align: center;
  transition: border-color 140ms ease;
}
.welcome-stat:hover { border-color: var(--border-2); }
.welcome-stat-val {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 4px;
}
.welcome-stat-label {
  display: block;
  font-size: 10px;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  line-height: 1.2;
}

/* Quick action chips — now below the composer */
.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  margin-top: 14px;
}
.welcome-chip {
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid var(--border-2);
  background: var(--bg-card);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  transition: border-color 130ms ease, color 130ms ease, background 130ms ease, transform 120ms ease;
  cursor: pointer;
}
.welcome-chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-bg);
  transform: translateY(-1px);
}

/* Demo call button — receptionist only */
.demo-call-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 22px;
  border-radius: 99px;
  background: #16A34A;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  margin-top: 14px;
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 4px 18px rgba(22,163,74,0.38);
  cursor: pointer;
}
.demo-call-btn:hover {
  background: #15803D;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(22,163,74,0.48);
}
.demo-call-btn svg {
  width: 16px; height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

/* Divider before composer */
.welcome-card-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* Composer section in welcome — full width, no side padding */
.welcome-card-composer {
  padding: 12px 0 0;
}

/* ============================================================
   AUDIT FORM CARD
============================================================ */
.audit-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-panel);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: 22px;
  box-shadow: var(--shadow);
  text-align: left;
  margin-top: 4px;
}
.audit-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.audit-card-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent-bg2);
  border: 1px solid rgba(91,127,255,0.3);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.audit-card-icon svg { width: 16px; height: 16px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; }
.audit-card-head-copy strong { display: block; font-size: 14px; font-weight: 600; }
.audit-card-head-copy span { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.audit-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.audit-field-full { grid-column: 1 / -1; }
.afield-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 5px;
}
.afield-input, .afield-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.afield-input:focus, .afield-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.afield-input::placeholder { color: var(--text-3); }
.afield-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235C5C72' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.afield-select option { background: var(--bg-card); }
.audit-run-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-md);
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  margin-top: 4px;
}
.audit-run-btn:hover { opacity: 0.90; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(91,127,255,0.38); }
.audit-run-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* ============================================================
   MESSAGES
============================================================ */
.messages {
  padding: 24px 24px 8px;
  max-width: 840px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.messages.hidden { display: none; }

.msg {
  display: flex;
  gap: 11px;
  opacity: 0;
  transform: translateY(8px);
  animation: msgIn 200ms ease forwards;
}
@keyframes msgIn { to { opacity: 1; transform: none; } }
.msg.user { justify-content: flex-end; }
.msg.user .msg-avatar { display: none; }
.msg.user .msg-body { align-items: flex-end; }

.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent-bg2), rgba(155,109,255,0.18));
  border: 1px solid rgba(91,127,255,0.22);
  display: grid; place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--accent);
}
.msg-avatar svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }

.msg-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: min(680px, 84%); }
.msg-meta { font-size: 10.5px; color: var(--text-3); padding: 0 3px; font-weight: 500; }
.msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 11px 15px;
  border-radius: 4px 18px 18px 18px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  box-shadow: var(--shadow-xs);
}
.msg.user .msg-bubble {
  background: var(--user-msg);
  border-color: transparent;
  color: #fff;
  border-radius: 18px 4px 18px 18px;
}

/* Typing indicator */
.msg-typing .msg-bubble {
  padding: 13px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: tdot 1.15s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes tdot { 0%,60%,100%{transform:translateY(0);opacity:.35} 30%{transform:translateY(-4px);opacity:1} }

/* Inline chips (quick replies inside messages) */
.msg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 0 2px;
}
.msg-chip {
  padding: 6px 13px;
  border-radius: 99px;
  border: 1px solid var(--border-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-panel);
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
  cursor: pointer;
}
.msg-chip:hover { border-color: var(--accent); color: var(--text); background: var(--accent-bg); }
.msg-chip:disabled { opacity: 0.4; cursor: default; }

/* ============================================================
   SCAN LOG (audit flow)
============================================================ */
.scan-log {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  font-family: ui-monospace, 'Geist Mono', 'SF Mono', monospace;
  font-size: 12px;
  line-height: 2;
  max-height: 220px;
  overflow-y: auto;
}
.scan-line { color: var(--text-3); }
.scan-line.ok { color: var(--success); }
.scan-line.ok::before { content: "✓  "; }
.scan-line.warn { color: var(--warn); }
.scan-line.warn::before { content: "⚠  "; }
.scan-line.run::before { content: "›  "; color: var(--text-3); }

/* Score card inside a message bubble */
.score-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-top: 6px;
}
.score-card-top {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.score-ring-wrap { position: relative; width: 80px; height: 80px; flex-shrink: 0; }
.score-ring-wrap svg { width: 100%; height: 100%; }
.score-ring-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.score-ring-num { font-size: 22px; font-weight: 700; line-height: 1; }
.score-ring-denom { font-size: 10px; color: var(--text-3); }
.score-card-copy { flex: 1; min-width: 0; }
.score-grade {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  margin-bottom: 7px;
}
.score-card-hl { font-size: 15px; font-weight: 600; }
.score-card-sub { font-size: 13px; color: var(--text-2); margin-top: 3px; }

.risk-bar {
  margin: 0 20px 16px;
  padding: 11px 14px;
  background: rgba(239,68,68,0.07);
  border: 1px solid rgba(239,68,68,0.18);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: 12px;
}
.risk-bar-icon { color: var(--danger); flex-shrink: 0; }
.risk-bar-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.risk-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--danger); margin-bottom: 2px; }
.risk-amount { font-size: 20px; font-weight: 700; color: var(--danger); line-height: 1; }
.risk-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.score-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 20px 20px;
}
.score-col-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.score-col-title.issues { color: var(--danger); }
.score-col-title.wins { color: var(--success); }
.score-col-title svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.score-item { display: flex; gap: 7px; font-size: 12px; color: var(--text-2); margin-bottom: 6px; line-height: 1.5; }
.score-item svg { flex-shrink: 0; margin-top: 2px; width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }

/* ============================================================
   CONTACT CAPTURE
============================================================ */
.contact-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}
.contact-card-head { font-size: 13px; font-weight: 500; }
.contact-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.contact-field-full { grid-column: 1 / -1; }
.cfield {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: 13px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.cfield:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.cfield::placeholder { color: var(--text-3); }
.contact-submit {
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-md);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: opacity 160ms ease, transform 160ms ease;
  align-self: flex-end;
}
.contact-submit:hover { opacity: 0.90; transform: translateY(-1px); }
.contact-submit svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }

/* ============================================================
   STRATEGY CHIP PANEL
============================================================ */
.chip-panel-wrap {
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}
.chip-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: 20px;
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: msgIn 220ms ease forwards;
  box-shadow: var(--shadow-sm);
}
.chip-panel.active { display: flex; }
.chip-panel-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.chip-panel-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent-bg2);
  border: 1px solid rgba(91,127,255,0.25);
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 15px;
  color: var(--accent);
  line-height: 1;
}
.chip-panel-copy { flex: 1; }
.chip-panel-title { font-size: 14px; font-weight: 600; line-height: 1.3; }
.chip-panel-desc { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.multi-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.multi-chip {
  padding: 8px 15px;
  border-radius: 99px;
  border: 1px solid var(--border-2);
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 130ms ease;
  cursor: pointer;
}
.multi-chip:hover { border-color: var(--accent); color: var(--text); }
.multi-chip.sel {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--text);
}
.chip-panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}
.chip-sel-count {
  font-size: 12px;
  color: var(--text-3);
  font-style: italic;
}
.chip-continue {
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-md);
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.chip-continue:hover { opacity: 0.90; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(91,127,255,0.32); }

/* ============================================================
   CONVERSION / CTA BANNER
============================================================ */
.conv-banner {
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}
.conv-banner.hidden { display: none; }
.conv-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  background: linear-gradient(105deg, var(--bg-panel) 0%, rgba(91,127,255,0.07) 100%);
  border: 1px solid rgba(91,127,255,0.22);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  animation: msgIn 220ms ease forwards;
}
.conv-copy strong { display: block; font-size: 13.5px; font-weight: 600; }
.conv-copy span { display: block; font-size: 12px; color: var(--text-2); margin-top: 2px; }
.conv-cta {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-md);
  padding: 9px 16px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.conv-cta:hover { opacity: 0.90; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(91,127,255,0.3); }

/* ============================================================
   COMPOSER
============================================================ */
.composer-wrap {
  flex: 0 0 auto;
  padding: 10px 20px 18px;
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
}

/* Contextual suggestions above composer (shown in conversation mode) */
.composer-suggestions {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 2px 10px;
  scrollbar-width: none;
}
.composer-suggestions::-webkit-scrollbar { display: none; }
.composer-suggestions.hidden { display: none; }
.composer-suggest-chip {
  padding: 6px 13px;
  border-radius: 99px;
  border: 1px solid var(--border-2);
  background: var(--bg-panel);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 130ms ease, color 130ms ease, background 130ms ease;
  cursor: pointer;
}
.composer-suggest-chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-bg);
}

/* Main composer box */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.composer:focus-within {
  border-color: rgba(91,127,255,0.45);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(91,127,255,0.08);
}
.composer textarea {
  flex: 1 1 auto;
  min-height: 26px;
  max-height: 180px;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 9px 0;
  line-height: 1.55;
  font-size: 14px;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer textarea:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn {
  width: 40px; height: 40px;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: opacity 150ms ease, transform 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 2px 10px rgba(91,127,255,0.32);
}
.send-btn:hover:not(:disabled) {
  opacity: 0.90;
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(91,127,255,0.42);
}
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; }
.send-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 4px 0;
  font-size: 11px;
  color: var(--text-3);
  gap: 10px;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 960px) {
  .app { grid-template-columns: 64px 1fr; }
  .sidebar { width: 64px; }
  .sb-brand-copy { display: none; }
  .sb-group-label { justify-content: center; padding: 10px 8px 4px; }
  .sb-group-label::after { display: none; }
  .sb-item-copy, .sb-control-meta, .lang-switch { display: none; }
  .sb-brand { padding: 12px 8px; justify-content: center; }
  .sb-brand-mark { width: 36px; height: 36px; }
  .sb-item { justify-content: center; padding: 10px 8px; }
  .sb-item-icon { width: 20px; height: 20px; }
  .sb-item-icon svg { width: 18px; height: 18px; }
  .sb-control { justify-content: center; padding: 8px; }
  .sb-footer { align-items: center; }
}
@media (max-width: 640px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 264px;
    z-index: 99;
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(.4,0,.2,1);
  }
  .sidebar.open {
    transform: translateX(0);
    width: 264px;
  }
  .sidebar.open .sb-brand-copy { display: block; }
  .sidebar.open .sb-group-label { justify-content: flex-start; padding: 12px 10px 5px; }
  .sidebar.open .sb-group-label::after { display: block; }
  .sidebar.open .sb-item-copy { display: block; }
  .sidebar.open .sb-control-meta { display: block; }
  .sidebar.open .lang-switch { display: flex; }
  .sidebar.open .sb-brand { justify-content: flex-start; padding: 16px 14px 14px; }
  .sidebar.open .sb-item { justify-content: flex-start; padding: 8px 10px 8px 11px; }
  .sidebar.open .sb-item-icon { width: 16px; height: 16px; }
  .sidebar.open .sb-item-icon svg { width: 15px; height: 15px; }
  .sidebar.open .sb-control { justify-content: space-between; padding: 8px 10px; }
  .sidebar.open .sb-footer { align-items: stretch; }
  .topbar-hamburger { display: flex; }
  .conv-inner { flex-direction: column; align-items: stretch; }
  .composer-wrap { padding: 8px 14px 16px; }
  .messages { padding: 18px 14px 8px; }
  .contact-fields { grid-template-columns: 1fr; }
  .score-cols { grid-template-columns: 1fr; }
  .audit-fields { grid-template-columns: 1fr; }
  .welcome-stats { flex-direction: column; gap: 8px; }
  .welcome { padding: 28px 18px 20px; }
}
/* ============================================================
   SMS MODE — missed call flow
============================================================ */
.messages.sms-mode {
  padding: 16px 20px 8px;
  gap: 8px;
  max-width: 680px;
}
.sms-header {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  padding: 8px 0 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.messages.sms-mode .msg {
  gap: 6px;
}
.messages.sms-mode .msg-avatar { display: none; }
.messages.sms-mode .msg-meta { display: none; }
.messages.sms-mode .msg-body { max-width: min(72%, 360px); }
.messages.sms-mode .msg.user .msg-body { align-items: flex-end; }
.messages.sms-mode .msg-bubble {
  padding: 9px 14px;
  border-radius: 18px 18px 4px 18px;
  background: #2A2A38;
  border: none;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: none;
}
[data-theme="light"] .messages.sms-mode .msg-bubble {
  background: #E5E5EA;
  color: #1C1C1E;
}
.messages.sms-mode .msg.user .msg-bubble {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  border-radius: 18px 18px 18px 4px;
}
.messages.sms-mode .msg-typing .msg-bubble {
  background: #2A2A38;
  border: none;
  border-radius: 18px 18px 4px 18px;
}
[data-theme="light"] .messages.sms-mode .msg-typing .msg-bubble {
  background: #E5E5EA;
}
/* SMS composer style */
.sms-composer-mode .composer {
  border-radius: 99px;
  padding: 6px 6px 6px 18px;
  background: var(--bg-card);
  border-color: var(--border-2);
}
.sms-composer-mode .send-btn {
  border-radius: 50%;
  width: 36px; height: 36px;
}

/* ============================================================
   DEMO CALL MODAL
============================================================ */
.demo-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  animation: fadeIn 200ms ease forwards;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.demo-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-2);
  border-radius: 24px;
  padding: 24px 24px 20px;
  max-width: 440px;
  width: calc(100% - 32px);
  text-align: center;
  box-shadow: var(--shadow);
  animation: slideUp 220ms cubic-bezier(.34,1.56,.64,1) forwards;
  position: relative;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.demo-modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  color: var(--text-3);
  display: grid; place-items: center;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease;
  font-size: 15px;
  line-height: 1;
}
.demo-modal-close:hover { color: var(--text); background: var(--bg-raised); }
.demo-modal-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(22,163,74,0.15);
  border: 2px solid rgba(22,163,74,0.4);
  display: grid; place-items: center;
  margin: 0 auto 14px;
  position: relative;
}
.demo-modal-icon::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(22,163,74,0.2);
  animation: callPulse 1.8s ease-in-out infinite;
}
.demo-modal-icon::after {
  content: '';
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  border: 2px solid rgba(22,163,74,0.1);
  animation: callPulse 1.8s ease-in-out infinite 0.3s;
}
@keyframes callPulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.08);opacity:0.5} }
.demo-modal-icon svg { width: 22px; height: 22px; color: #22C55E; fill: currentColor; }
.demo-modal-title { font-size: 17px; font-weight: 700; letter-spacing: -0.025em; margin-bottom: 5px; }
.demo-modal-sub { font-size: 13px; color: var(--text-2); line-height: 1.5; margin-bottom: 18px; }
/* GHL widget iframe container */
.demo-modal-widget {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  min-height: 420px;
}
.demo-modal-widget iframe {
  width: 100%;
  height: 480px;
  border: none;
  display: block;
  border-radius: 14px;
}
.demo-modal-widget-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 13px;
  pointer-events: none;
  transition: opacity 400ms ease;
  background: var(--bg-card);
  border-radius: 14px;
  z-index: 2;
}
.demo-modal-widget-loading.hidden { opacity: 0; pointer-events: none; }
.demo-modal-widget-loading .live-dot { animation: pulse-dot 2.2s infinite; }

/* ============================================================
   BOOKING MODAL — GHL Discovery Call calendar
============================================================ */
.demo-modal.booking-modal { max-width: 760px; padding: 20px 20px 16px; }
.booking-modal .demo-modal-title { margin-right: 32px; }
.booking-modal .demo-modal-sub { margin-bottom: 14px; }
.booking-modal .demo-modal-widget { min-height: 0; }
.booking-modal .demo-modal-widget iframe { height: min(68dvh, 640px); background: #fff; }
.booking-modal-alt { margin-top: 10px; font-size: 12px; color: var(--text-3); }
.booking-modal-alt a { font-weight: 600; }

/* ============================================================
   SYSTEM NOTICES — never styled or labelled as an AI reply
============================================================ */
.msg-notice {
  align-self: center;
  max-width: min(560px, 92%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px dashed var(--border-2);
  background: var(--bg-panel);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  animation: msgIn 200ms ease forwards;
}
.msg-notice.warn { border-color: rgba(245,158,11,0.45); }
.msg-notice-btn {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border-2);
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.msg-notice-btn:hover { border-color: var(--accent); }
.msg-meta.guide { color: var(--text-3); font-style: italic; }

/* Cards rendered inside a pre-wrap bubble: their template indentation is not content. */
.msg-bubble .contact-card, .msg-bubble .score-card { white-space: normal; }

/* Contact capture states */
.contact-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.contact-error { font-size: 12.5px; color: var(--danger); line-height: 1.5; }
.contact-error:empty { display: none; }
.contact-error a { color: inherit; text-decoration: underline; }
.contact-submit:disabled { opacity: 0.55; cursor: progress; transform: none; }
.contact-done { text-align: center; padding: 14px 0 4px; }
.contact-done-check { color: var(--success); font-size: 22px; margin-bottom: 8px; }
.contact-done-title { font-weight: 600; margin-bottom: 4px; }
.contact-done-sub { font-size: 13px; color: var(--text-2); }
.contact-done .contact-submit { margin: 14px auto 0; align-self: center; }

/* Audit: the real data the estimate was based on */
.score-facts { margin: 0 20px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.score-fact { font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.score-fact strong { color: var(--text); font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.score-note { margin: 0 20px 16px; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
@media (max-width: 640px) { .score-facts { grid-template-columns: 1fr; } }

