:root {
  --bg: #0f1720;
  --surface: #182230;
  --surface-2: #202c3d;
  --border: #2c3a4f;
  --text: #e6edf3;
  --text-dim: #9aa7b8;
  --accent: #ff9900;
  --accent-hover: #ffb347;
  --success: #2ea043;
  --warn: #d29922;
  --danger: #f85149;
  --focus: #79b8ff;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--sans); line-height: 1.5; }

body { min-height: 100vh; display: flex; flex-direction: column; }

a { color: var(--focus); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px 28px;
  background: linear-gradient(180deg, #141e2b 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 1.15rem; letter-spacing: 0.2px; }
.tagline { margin: 0; font-size: 0.82rem; color: var(--text-dim); }
.logo { color: var(--accent); font-size: 1.6rem; line-height: 1; }

.session { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
.session label { color: var(--text-dim); font-weight: 500; }
.session input {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 0.85rem;
  min-width: 220px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.pill-muted { background: #2a3647; color: var(--text-dim); }
.pill-ok { background: rgba(46, 160, 67, 0.2); color: var(--success); }
.pill-bad { background: rgba(248, 81, 73, 0.2); color: var(--danger); }

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 18px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

main#panels { flex: 1; padding: 28px; max-width: 1100px; width: 100%; margin: 0 auto; }

.panel { display: block; }
.panel[hidden] { display: none; }

.panel-head { margin-bottom: 18px; }
.panel-head h2 { margin: 0 0 4px; font-size: 1.2rem; }
.panel-head p { margin: 0; color: var(--text-dim); font-size: 0.92rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.form-grid .full { grid-column: 1 / -1; }

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
}

label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--text-dim); }

input[type="text"], input[type="number"], select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--sans);
  font-size: 0.92rem;
}
textarea { font-family: var(--mono); font-size: 0.85rem; resize: vertical; }

input:focus, select:focus, textarea:focus { border-color: var(--focus); }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #27344a; }
.btn-primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.result { margin-top: 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 10px; font-size: 1rem; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 4px 12px; font-size: 0.9rem; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 0.85rem; word-break: break-word; }

.score-header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.score-value { font-size: 2.4rem; font-weight: 700; color: var(--accent); }
.score-max { color: var(--text-dim); }

.summary-stats { display: flex; gap: 32px; flex-wrap: wrap; align-items: baseline; }
.summary-stat { display: flex; align-items: baseline; gap: 8px; }

.readiness-ready { color: var(--success); }
.readiness-needs_improvement { color: var(--warn); }
.readiness-not_ready { color: var(--danger); }

.bars { display: grid; gap: 10px; margin: 14px 0; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 44px; align-items: center; gap: 12px; font-size: 0.88rem; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #ffb347, var(--accent)); }

.list-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.list-table th, .list-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.list-table th { color: var(--text-dim); font-weight: 600; background: var(--surface); }
.list-table tr:hover td { background: var(--surface); }
.list-table button { background: transparent; color: var(--focus); border: none; font: inherit; cursor: pointer; padding: 0; }

.tag { display: inline-block; padding: 2px 8px; background: var(--surface-2); border-radius: 999px; font-size: 0.75rem; margin: 2px 4px 2px 0; color: var(--text-dim); }

ul.bullets { margin: 6px 0 0; padding-left: 22px; }
ul.bullets li { margin-bottom: 4px; }

.raw-json { margin-top: 14px; }
.raw-json summary { cursor: pointer; color: var(--text-dim); font-size: 0.82rem; }
.raw-json pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; overflow-x: auto; font-family: var(--mono); font-size: 0.78rem; margin-top: 8px; }

.error-card { border-color: rgba(248, 81, 73, 0.6); background: rgba(248, 81, 73, 0.08); }
.error-card h3 { color: var(--danger); }
.error-code { font-family: var(--mono); font-size: 0.8rem; color: var(--text-dim); }

.loading { color: var(--text-dim); font-style: italic; }

.update-block { margin-top: 28px; border: 1px dashed var(--border); border-radius: var(--radius); padding: 10px 18px; }
.update-block summary { cursor: pointer; color: var(--text-dim); font-weight: 500; padding: 6px 0; }
.update-block[open] summary { color: var(--text); margin-bottom: 12px; }

.app-footer {
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
  gap: 20px;
  flex-wrap: wrap;
}
.app-footer code { font-family: var(--mono); background: var(--surface); padding: 2px 6px; border-radius: 4px; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 100px 1fr 36px; }
  .session input { min-width: 140px; }
}


/* ---------- Qualify tab: split layout + chat ---------- */

.panel-wide { max-width: 100%; }

main#panels:has(.panel-wide:not([hidden])) { max-width: 1400px; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: stretch;
  /* Bound total height so middle scrolls independently, chat stays in viewport */
  height: calc(100vh - 240px);
  min-height: 520px;
}

.split-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* no longer the scroll container */
}

.split-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.chat-head strong { font-size: 0.95rem; }
.chat-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); padding: 4px 10px; font-size: 0.8rem; }
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg { display: flex; }
.chat-msg-agent { justify-content: flex-start; }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-system { justify-content: center; }

.chat-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.chat-msg-user .chat-bubble { background: rgba(255, 153, 0, 0.12); border-color: rgba(255, 153, 0, 0.4); }
.chat-msg-system .chat-bubble { background: transparent; border: 1px dashed var(--border); color: var(--text-dim); font-size: 0.78rem; font-style: italic; }
.chat-bubble p { margin: 0 0 6px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul { margin: 6px 0 0; padding-left: 20px; font-size: 0.84rem; }
.chat-bubble code { font-family: var(--mono); font-size: 0.78rem; background: var(--bg); padding: 1px 5px; border-radius: 3px; }
.chat-bubble .rationale { color: var(--text-dim); font-size: 0.78rem; margin-top: 4px; }

.chat-typing { color: var(--text-dim); font-size: 0.8rem; font-style: italic; padding: 2px 4px; }

.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.chat-input textarea {
  resize: none;
  font-family: var(--sans);
  font-size: 0.88rem;
}
.chat-input button { align-self: stretch; }

/* progress readout */

.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 14px;
}
.progress-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.progress-top strong { font-size: 0.95rem; }
.progress-track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #ffb347, var(--accent)); transition: width 0.3s ease; }
.progress-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.78rem; color: var(--text-dim); margin-top: 10px; }
.progress-meta .tag { margin: 0; }

@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; height: auto; }
  .split-main { overflow-y: visible; }
  .chat { position: static; height: auto; max-height: 520px; }
}


/* ---------- Wizard ---------- */

.wizard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.wizard-head h2 { margin: 0 0 4px; font-size: 1.25rem; }
.wizard-sub { margin: 0; color: var(--text-dim); font-size: 0.92rem; }
.wizard-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.wizard-dots {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.wizard-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.wizard-dot:hover { color: var(--text); }
.wizard-dot .dot-num {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 600;
}
.wizard-dot[data-state="active"] { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
.wizard-dot[data-state="active"] .dot-num { background: var(--accent); color: #1a1a1a; }
.wizard-dot[data-state="done"] { color: var(--success); border-color: rgba(46,160,67,0.45); }
.wizard-dot[data-state="done"] .dot-num { background: var(--success); color: #0a1a0f; }

.progress-track { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #ffb347, var(--accent)); transition: width 0.3s ease; }

#wizard-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  min-height: 400px;
}

.field {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 14px;
}
.field-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.field-label { font-size: 0.88rem; font-weight: 600; color: var(--text); line-height: 1.25; }
.field-label .required { color: var(--accent); margin-left: 4px; }
.field-helper { color: var(--text-dim); font-size: 0.76rem; margin-top: 2px; line-height: 1.35; }
.field-badges { display: inline-flex; gap: 6px; align-items: center; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-user { background: rgba(46, 160, 67, 0.18); color: #6dd57e; }
.badge-ai { background: rgba(137, 99, 247, 0.2); color: #c2b5ff; }
.badge-ai-pop { background: rgba(56, 166, 232, 0.2); color: #8ccdf5; }
.badge-crm { background: rgba(255, 153, 0, 0.22); color: #ffc166; }
.badge-empty { background: var(--surface-2); color: var(--text-dim); }

.field-row { display: flex; gap: 8px; align-items: stretch; }
.field-row > input, .field-row > textarea, .field-row > select { flex: 1; }

.field textarea { min-height: 64px; }

.wand-btn {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 0 10px;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
}
.wand-btn:hover { border-color: #8963f7; color: #c2b5ff; background: rgba(137, 99, 247, 0.08); }
.wand-btn[data-busy="true"] { pointer-events: none; opacity: 0.6; }

.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.suggestion-box {
  margin-top: 8px;
  background: rgba(137, 99, 247, 0.08);
  border: 1px solid rgba(137, 99, 247, 0.35);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.85rem;
}
.suggestion-box .suggestion-label { font-size: 0.72rem; text-transform: uppercase; color: #c2b5ff; letter-spacing: 0.3px; }
.suggestion-box .suggestion-value { margin: 6px 0 8px; font-family: var(--mono); font-size: 0.82rem; white-space: pre-wrap; word-break: break-word; }
.suggestion-box .suggestion-rationale { color: var(--text-dim); font-size: 0.78rem; margin-bottom: 8px; }
.suggestion-box .suggestion-actions { display: flex; gap: 8px; }

.field-pulse input, .field-pulse textarea, .field-pulse select {
  animation: pulse-ai 1.2s ease;
}
@keyframes pulse-ai {
  0%   { box-shadow: 0 0 0 0 rgba(137, 99, 247, 0); }
  30%  { box-shadow: 0 0 0 3px rgba(137, 99, 247, 0.5); }
  100% { box-shadow: 0 0 0 0 rgba(137, 99, 247, 0); }
}

.wizard-nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 0;
}
.wizard-step-count { color: var(--text-dim); font-size: 0.85rem; }

.wizard-warnings { margin-top: 8px; flex-shrink: 0; }
.wizard-warnings .warning-card {
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.4);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wizard-warnings .warning-card strong { color: var(--warn); }
.wizard-warnings .warning-card ul { margin: 6px 0 0; padding-left: 20px; color: var(--text-dim); }
.wizard-warnings .btn-dismiss {
  padding: 0 10px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text-dim);
}

/* Review page */

.review-grid { display: grid; gap: 12px; }
.review-section { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 14px 16px; }
.review-section h4 { margin: 0 0 8px; font-size: 0.9rem; color: var(--text); text-transform: uppercase; letter-spacing: 0.3px; }
.review-row { display: grid; grid-template-columns: 200px 1fr auto; gap: 10px; padding: 6px 0; font-size: 0.88rem; border-bottom: 1px solid var(--border); }
.review-row:last-child { border-bottom: none; }
.review-row .review-key { color: var(--text-dim); }
.review-row .review-value { color: var(--text); word-break: break-word; }
.review-row .review-empty { color: var(--text-dim); font-style: italic; }

/* MEDDPICC scorecard */
.meddpicc-summary-line { display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px; }
.meddpicc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.meddpicc-dim { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.meddpicc-dim-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.meddpicc-dim-label { font-weight: 600; color: var(--text); font-size: 0.9rem; }
.meddpicc-dim-score { font-family: var(--mono); color: var(--accent); font-size: 0.85rem; }
.meddpicc-qs { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.meddpicc-qs li { display: grid; grid-template-columns: 16px 1fr auto; gap: 8px; align-items: baseline; font-size: 0.82rem; line-height: 1.35; }
.meddpicc-mark { font-weight: 700; }
.meddpicc-pts { color: var(--text-dim); font-family: var(--mono); font-size: 0.78rem; }
.meddpicc-yes .meddpicc-mark { color: var(--success); }
.meddpicc-yes .meddpicc-q { color: var(--text); }
.meddpicc-no .meddpicc-mark { color: var(--text-dim); }
.meddpicc-no .meddpicc-q { color: var(--text-dim); }

@media (max-width: 720px) {
  .field-pair { grid-template-columns: 1fr; }
  .review-row { grid-template-columns: 1fr; gap: 2px; }
}


/* Home panel */
#panel-home .home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
#panel-home .home-head h2 { margin: 0; font-size: 1.6rem; }
#panel-home .home-sub { color: var(--text-dim); font-size: 0.9rem; margin: 4px 0 0; }
#panel-home .home-actions { display: flex; gap: 10px; flex-shrink: 0; }

#panel-home .home-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
#panel-home .stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}
#panel-home .stat-label { color: var(--text-dim); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.3px; }
#panel-home .stat-value { font-size: 2.2rem; font-weight: 600; margin-top: 6px; }

#panel-home .home-section { margin-top: 28px; }
#panel-home .home-section h3 { font-size: 1rem; margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-dim); }

.home-activity { display: flex; flex-direction: column; gap: 8px; }
.activity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.activity-row:hover { border-color: var(--accent); background: var(--surface-3, var(--surface-2)); }
.activity-title { font-weight: 500; font-size: 0.95rem; }
.activity-sub { color: var(--text-dim); font-size: 0.82rem; margin-top: 2px; }
.pill-active { background: rgba(73, 197, 120, 0.15); color: #2f9a58; }
.pill-submitted { background: rgba(120, 120, 130, 0.15); color: var(--text-dim); }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.quick-action {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.quick-action:hover { border-color: var(--accent); }
.qa-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; background: var(--surface); border: 1px solid var(--border);
}
.qa-title { font-weight: 500; }
.qa-sub { color: var(--text-dim); font-size: 0.82rem; margin-top: 2px; }

.how-it-works {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  list-style: none; padding: 0; margin: 0;
  counter-reset: how;
}
.how-it-works li {
  counter-increment: how;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  position: relative;
}
.how-it-works li::before {
  content: counter(how);
  position: absolute;
  top: 14px; right: 14px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600;
}
.how-it-works li strong { display: block; margin-bottom: 4px; }
.how-it-works li div { color: var(--text-dim); font-size: 0.85rem; }

@media (max-width: 900px) {
  #panel-home .home-stats,
  .quick-actions,
  .how-it-works { grid-template-columns: 1fr; }
}


/* App shell with sidebar */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  gap: 14px;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; }
.sidebar-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.8rem;
}
.sidebar-title { font-weight: 600; font-size: 0.95rem; }

.sidebar-new {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text);
}

.sidebar-section { display: flex; flex-direction: column; gap: 6px; min-height: 0; flex: 1; }
.sidebar-section-head {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 4px 6px;
}

.sidebar-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.sidebar-empty { color: var(--text-dim); font-size: 0.8rem; padding: 8px; }

.sidebar-item {
  text-align: left;
  width: 100%;
  background: transparent;
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
}
.sidebar-item:hover { background: var(--surface); }
.sidebar-item-title {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-item-meta {
  display: flex; gap: 8px;
  color: var(--text-dim);
  font-size: 0.72rem;
  margin-top: 2px;
}
.sidebar-item-meta span:first-child {
  color: var(--accent);
  font-weight: 500;
}

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.sidebar-footer-stats {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.75rem;
}
.sidebar-footer-stats div {
  display: flex; justify-content: space-between;
  color: var(--text-dim);
}
.sidebar-footer-stats strong { color: var(--text); font-weight: 600; }

.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 6px 4px; }
.sidebar-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600;
}
.sidebar-user-text { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
}
.sidebar-user-sub[data-state="ok"] { color: #2f9a58; }
.sidebar-user-sub[data-state="bad"] { color: #c84343; }

@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .app-sidebar { width: auto; min-height: 0; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-section { max-height: 200px; }
}


/* Captured-fields chip row shown after an AI extraction turn */
.chat-msg-captured {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  flex-wrap: wrap;
}
.captured-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
}
.captured-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.captured-chip {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.3);
}


/* Captured-fields grouped by page, with off-page signal */
.captured-group { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.captured-page-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  font-weight: 600;
}
.captured-page-title.is-current { color: var(--accent); }

/* Pulse a step dot when fields land on a page the user isn't viewing */
@keyframes dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(137, 99, 247, 0.6); }
  50%  { box-shadow: 0 0 0 6px rgba(137, 99, 247, 0); }
  100% { box-shadow: 0 0 0 0 rgba(137, 99, 247, 0); }
}
.wizard-dot.dot-pulse { animation: dot-pulse 1.5s ease-out 1; }
.wizard-dot.dot-pulse .dot-num { background: var(--accent); color: white; }


/* Suggestion preview: render lists as bullets, not raw JSON */
.suggestion-list { margin: 4px 0 0; padding-left: 18px; font-size: 0.85rem; line-height: 1.45; }
.suggestion-list li { margin-bottom: 4px; }
.suggestion-note { color: var(--text-dim); font-size: 0.8rem; }
.suggestion-json {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 0;
}


/* Activity rows: main open-button + trailing icon actions */
.activity-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}
.activity-row .activity-open {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}
.activity-row .activity-open:hover { background: var(--surface-2); }
.activity-row .icon-btn {
  flex: 0 0 auto;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 1rem;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.activity-row .icon-btn:hover {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
}
.activity-row .icon-delete:hover {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
}
.archive-row .activity-open {
  opacity: 0.85;
}
