/* ===== Palette matched to the "haara" project — pastel dusty-rose + slate =====
   brand #b8a5a9 (rose), slate neutrals, sage/blue-grey accents. */
:root {
  /* dark = slate-900 surfaces with the rose brand, slightly brightened */
  --bg: #0f172a;
  --bg-soft: #18212f;
  --card: #1e293b;
  --card-2: #28344a;
  --line: #344155;
  --text: #e6e9f0;
  --muted: #94a3b8;
  --primary: #c2a6ac;
  --primary-2: #a8868f;
  --accent: #d9b48a;
  --green: #82c2a3;
  --red: #e2918c;
  --yellow: #d8c188;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(0,0,0,.38);
  --topbar-bg: rgba(15,23,42,.72);
  --body-grad: radial-gradient(1200px 600px at 80% -10%, #2a2531 0, var(--bg) 55%);
}
/* Day / light theme — haara's soft pastel rose default */
:root[data-theme="light"] {
  --bg: #f2eef0;
  --bg-soft: #ece5e9;
  --card: #ffffff;
  --card-2: #f7f1f4;
  --line: #e6dce1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #b8a5a9;
  --primary-2: #a38087;
  --accent: #c79a73;
  --green: #6fae8f;
  --red: #d97a74;
  --yellow: #c5a463;
  --shadow: 0 10px 34px rgba(120,90,100,.12);
  --topbar-bg: rgba(255,255,255,.82);
  --body-grad: radial-gradient(1200px 600px at 80% -10%, #efe4e9 0, var(--bg) 55%);
}
* { box-sizing: border-box; }

/* Icons (Lucide-style) */
.ic { width: 1.05em; height: 1.05em; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.16em; flex: none; }
.ic.fill { fill: currentColor; stroke: none; }
.ic-lg { width: 1.5em; height: 1.5em; }
/* tweak buttons so icon + text sit nicely */
.btn, .tab, .dropdown-item, .icon-btn, .chip, .badge, .status-pill, .serious,
.engine-tag, .new-tag, .health { display: inline-flex; align-items: center; gap: 7px; }
body {
  margin: 0;
  font-family: "Segoe UI", "Heebo", system-ui, sans-serif;
  font-size: 15px;
  background: var(--body-grad);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;          /* never let a wide child force horizontal scroll on phones */
  transition: background .25s, color .25s;
}

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 36px; background: var(--topbar-bg);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { display: inline-flex; color: var(--primary); }
.logo .ic { width: 32px; height: 32px; stroke-width: 1.8; }
/* avatar icons inherit the avatar's text colour */
.avatar .ic { width: 1.2em; height: 1.2em; }
.topbar h1 { margin: 0; font-size: 20px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Icon buttons + settings dropdown (declutters the topbar) */
.icon-btn { display: inline-flex; align-items: center; justify-content: center;
  gap: 4px; min-width: 38px; height: 38px; padding: 0 10px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  cursor: pointer; font-size: 16px; transition: .15s; }
.icon-btn:hover { border-color: var(--primary); }
/* icon-only buttons blend into the pastel surface and give no touch feedback, so
   people (esp. on mobile) can't tell they're tappable. Make them read AS buttons:
   a clearer surface, and a pressed state that also works on touch (no hover). */
.icon-btn { box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.icon-btn:active, .btn:active, .pill:active,
.stage-chip:active, .subtab:active { transform: translateY(1px); }
/* labeled icon buttons — icon + a short word, so it's obviously a button AND says
   what it does (there's no hover tooltip on touch). */
.icon-btn.labeled { width: auto; padding: 0 14px; gap: 6px; font-weight: 600; }
.icon-btn .btn-label { font-size: 13.5px; font-weight: 600; line-height: 1;
  white-space: nowrap; }
/* touch / narrow screens: bigger tap targets (≥44px) so buttons are easy to hit,
   and the labels above keep every action findable without a hover tooltip. */
@media (max-width: 860px) {
  .icon-btn { min-height: 44px; height: 44px; font-size: 17px; }
  .conv-tools .icon-btn { height: 44px; }
  .btn.small { padding: 9px 13px; }
}
.menu-wrap { position: relative; }
.dropdown { position: absolute; top: calc(100% + 8px); inset-inline-end: 0;
  min-width: 220px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.dropdown-item { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; width: 100%; text-align: start; background: transparent; border: none;
  color: var(--text); padding: 10px 12px; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-family: inherit; }
.dropdown-item:hover { background: var(--bg-soft); }
.dropdown-item.toggle { cursor: default; }
.dropdown-item.toggle input { width: auto; margin: 0; }
.dropdown-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* Pills & buttons */
.pill { padding: 6px 12px; border-radius: 999px; font-size: 13px;
  background: var(--card-2); border: 1px solid var(--line); }
.health.ok { color: var(--green); border-color: rgba(67,201,138,.4); }
.health.bad { color: var(--red); border-color: rgba(255,107,107,.4); }
/* connected = just a bare green dot (no pill chrome) */
.health.dot-only { background: none; border: none; padding: 4px 6px; }
.health.dot-only .ic { width: 11px; height: 11px; }
.btn {
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  padding: 10px 18px; border-radius: 11px; cursor: pointer; font-size: 14.5px;
  transition: .15s; font-family: inherit;
}
.btn:hover { transform: translateY(-1px); border-color: var(--primary); }
.btn.primary { background: linear-gradient(180deg, var(--primary), var(--primary-2));
  border: none; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Scrollbars — the default white/grey OS bars look out of place on the pastel
   surface. Make them thin, rounded, floating and theme-aware (light + dark). */
* { scrollbar-width: thin; scrollbar-color: var(--muted) transparent; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text); }
::-webkit-scrollbar-corner { background: transparent; }

/* Tabs — round pills (no long/stretched tabs), active = filled */
.tabs { display: flex; gap: 8px; padding: 18px 40px 0; flex-wrap: wrap;
  max-width: 1440px; margin: 0 auto; }
.tab {
  box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted);
  padding: 9px 18px; cursor: pointer; font-size: 15px; font-family: inherit;
  border-radius: 999px; transition: .15s;
}
.tab .ic { width: 18px; height: 18px; flex: none; }
.tab:hover { color: var(--text); border-color: var(--muted); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary);
  font-weight: 600; }
.tab.active .ic { color: #fff; }

/* second-level navigation: the active area's panels as pills */
.subtabs-row { display: flex; gap: 8px; padding: 14px 40px 0; max-width: 1440px;
  margin: 0 auto; flex-wrap: wrap; }
.subtabs-row[hidden] { display: none; }
.subtab2 { background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted);
  padding: 8px 18px; cursor: pointer; font-family: inherit; font-size: 14px;
  border-radius: 999px; transition: .15s; }
.subtab2:hover { color: var(--text); border-color: var(--muted); }
.subtab2.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

main { padding: 32px 40px 72px; max-width: 1440px; margin: 0 auto; }
.panel { display: none; animation: fade .25s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1;} }

h2 { font-size: 20px; margin: 4px 0 8px; }
.hint { color: var(--muted); font-size: 13.5px; font-weight: 400; }
/* short explainer under a panel heading — helps orientation */
.panel-intro { color: var(--muted); font-size: 14px; margin: 0 0 22px;
  line-height: 1.5; max-width: 720px; }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: 400px 1fr; gap: 28px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* Forms */
form label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
input, textarea, .select {
  width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font-family: inherit; font-size: 14px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, .select:focus { outline: none; border-color: var(--primary); }
.file-label input { padding: 8px; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 14px; }
.list-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 13px;
  padding: 16px 18px; display: flex; gap: 16px; align-items: center;
}
.list-item img.thumb { width: 56px; height: 56px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item h3 { margin: 0 0 4px; font-size: 15px; }
.list-item .meta { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards grid (results / manufacturers) */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px,1fr));
  gap: 18px; }
.prod-card { background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.prod-card .img { height: 150px; background: var(--bg-soft) center/cover no-repeat; }
.prod-card .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex:1; }
.prod-card h3 { font-size: 14px; margin: 0; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod-card .price { color: var(--accent); font-weight: 600; }
.prod-card .footer { padding: 10px 14px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--muted); }
.score { font-weight: 700; }
.score.high { color: var(--green);} .score.mid { color: var(--yellow);} .score.low { color: var(--muted);}

.results-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.results-head .select { width: 320px; }

/* Conversations — list (right) · chat (center) · live AI summary (left) */
.conv-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr) 330px;
  gap: 24px; align-items: start; }
@media (max-width: 1200px){ .conv-layout { grid-template-columns: 320px minmax(0, 1fr); } .ai-summary { display: none; } }
/* minmax(0,1fr) — NOT plain 1fr (=minmax(auto,1fr)) — so the single column can
   shrink BELOW its content's min-content instead of forcing the page wider than
   the phone screen (the chat rows expanded the column to ~437px inside a 362px
   viewport → horizontal scroll / "desktop feel"). With minmax(0,1fr) the column
   fits the screen and the inner ellipsis/min-width:0 truncation engages. */
@media (max-width: 860px){ .conv-layout { grid-template-columns: minmax(0, 1fr); } }

/* always-on AI summary panel */
.ai-summary { padding: 0; height: calc(100vh - 210px); min-height: 460px; overflow: hidden;
  display: flex; flex-direction: column; }
.ai-summary > .empty { margin: auto; padding: 24px; }
.sum-head { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex: none;
  font-weight: 700; font-size: 14px; }
.sum-head .ic { color: var(--primary); }
.sum-body { flex: 1; overflow-y: auto; padding: 16px; }
.sum-verdict { display: flex; align-items: center; gap: 12px; padding: 12px;
  border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--line); margin-bottom: 14px; }
.sum-score { width: 48px; height: 48px; border-radius: 50%; flex: none; font-weight: 800;
  font-size: 19px; display: flex; align-items: center; justify-content: center; background: var(--card-2); }
.sum-verdict.serious-serious .sum-score { background: rgba(67,201,138,.18); color: var(--green); }
.sum-verdict.serious-promising .sum-score { background: rgba(184,165,169,.2); color: var(--primary); }
.sum-verdict.serious-uncertain .sum-score { background: rgba(245,196,81,.18); color: var(--yellow); }
.sum-verdict.serious-time_waster .sum-score { background: rgba(255,107,107,.18); color: var(--red); }
.sum-label { font-size: 16px; font-weight: 700; }
.sum-sec { margin-bottom: 14px; }
.sum-sec h5 { margin: 0 0 5px; font-size: 12.5px; color: var(--primary);
  display: inline-flex; align-items: center; gap: 6px; }
.sum-sec h5 .ic { width: 13px; height: 13px; }
.sum-sec p { margin: 0; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.sum-status { display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--muted); margin: 8px 0 12px; }
.sum-flags { margin: 4px 0 0; padding-inline-start: 18px; }
.sum-flags li { color: var(--red); font-size: 13px; margin: 3px 0; line-height: 1.45; }
.ai-summary #sumFull { width: 100%; justify-content: center; margin-top: 4px; }
/* cross-conversation insights */
.sum-cross { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.sum-cross h5 { color: var(--accent); }
.cross-list { margin: 4px 0 8px; padding-inline-start: 18px; }
.cross-list li { font-size: 13px; line-height: 1.5; margin: 6px 0; }
.cn-cids { white-space: nowrap; }
.cn-cid { display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 999px;
  padding: 1px 7px; margin: 0 1px; cursor: pointer; text-decoration: none; }
.cn-cid:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.cross-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.cross-acts .btn { flex: 1 1 46%; justify-content: center; }
.sum-fb { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.sum-fb .hint { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.sum-fb .fb-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.sum-fb .fb-btns .btn { flex: 1 1 45%; justify-content: center; }

/* conversations list header + sync tools */
.conv-list-head { display: flex; align-items: center; justify-content: space-between; }
.conv-list-head h2 { margin: 4px 0 12px; }
.conv-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.conv-tools .icon-btn { height: 38px; }
.icon-btn.wechat { color: #09b83e; }
.icon-btn.wechat:hover { border-color: #09b83e; }
.icon-btn.email { color: var(--primary); }
.icon-btn.email:hover { border-color: var(--primary); }
.wechat-banner { display: flex; align-items: center; gap: 7px; font-size: 12.5px;
  padding: 9px 11px; border-radius: 10px; margin-bottom: 10px; line-height: 1.4; }
.wechat-banner[hidden] { display: none; }
.wechat-banner.warn { background: rgba(245,196,81,.12); color: var(--yellow);
  border: 1px solid rgba(245,196,81,.35); }
.wechat-banner:not(.warn) { background: rgba(9,184,62,.12); color: #2ec46a;
  border: 1px solid rgba(9,184,62,.3); }

/* channel badge (Alibaba / MIC / WeChat) */
.ch-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid transparent; }
.ch-badge .ic { width: 12px; height: 12px; }
.ch-badge.ch-alibaba { background: rgba(255,180,84,.14); color: var(--accent); }
.ch-badge.ch-mic { background: rgba(184,165,169,.14); color: var(--primary); }
.ch-badge.ch-wechat { background: rgba(9,184,62,.16); color: #2ec46a; }
.ch-badge.ch-email { background: rgba(184,165,169,.14); color: var(--primary); }
.ch-badge.grp-tag { background: rgba(155,123,255,.16); color: #b39bff; }
/* channel shortcuts on a company group header */
.grp-ch { background: transparent; border: 1px solid var(--line); cursor: pointer;
  border-radius: 9px; padding: 5px 8px; display: inline-flex; flex: none; }
.grp-ch .ic { width: 16px; height: 16px; }
.grp-wechat { color: #2ec46a; }
.grp-wechat:hover { border-color: #09b83e; background: rgba(9,184,62,.1); }
.grp-email { color: var(--primary); }
.grp-email:hover { border-color: var(--primary); background: rgba(184,165,169,.1); }
.ch-note { display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: #2ec46a; padding: 8px 18px 0; }
.ch-note .ic { width: 14px; height: 14px; }

/* Avatars (initials circle / company / us / draft) */
.avatar { flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; }
.avatar.company { background: var(--card-2); border: 1px solid var(--line); font-size: 18px; }
.avatar.groupav { background: rgba(155,123,255,.18); border: 1px solid rgba(155,123,255,.5);
  color: #b39bff; }
.avatar.us { background: linear-gradient(180deg, var(--primary), var(--primary-2)); }
.avatar.draft { background: rgba(245,196,81,.18); border: 1px dashed var(--yellow);
  color: var(--yellow); }

/* shared row layout (company header + contact rows) */
.row-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-name { font-weight: 600; font-size: 14.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.row-sub { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12.5px; }
/* contact meta line — badges spaced out and allowed to wrap (no overlap) */
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  margin-top: 7px; font-size: 12px; }
.dim { color: var(--muted); }

/* clear "type" labels: what's a factory / group / conversation */
.company-tag { display: inline-flex; align-items: center; gap: 4px; flex: none;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  color: var(--muted); background: var(--bg-soft); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 6px; }
.company-tag .ic { width: 12px; height: 12px; }
.type-tag { display: inline-flex; align-items: center; gap: 4px; flex: none;
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.type-tag .ic { width: 12px; height: 12px; }
.type-tag.group { background: rgba(155,123,255,.16); color: #b39bff; }

/* status pill — "who's turn is it" at a glance */
.status-pill { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  border: 1px solid transparent; }
.status-pill.wait-us   { background: rgba(67,201,138,.16); color: var(--green); border-color: rgba(67,201,138,.4); }
.status-pill.wait-them { background: rgba(245,196,81,.14); color: var(--yellow); }
.status-pill.open      { background: rgba(184,165,169,.16); color: var(--primary); }
.status-pill.closed    { background: var(--card-2); color: var(--muted); }

/* Company group */
.conv-group { background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; }
.conv-group.has-new { border-color: var(--green); box-shadow: 0 0 0 1px rgba(67,201,138,.3); }
.conv-group { margin-bottom: 12px; }
.conv-group-head { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px;
  cursor: pointer; background: var(--bg-soft); }
.conv-group-head:hover { background: var(--card-2); }
.conv-group-head .chev { color: var(--muted); font-size: 11px; transition: transform .15s;
  flex-shrink: 0; margin-top: 12px; }
.conv-group.collapsed .chev { transform: rotate(-90deg); }
.conv-group.collapsed .conv-group-body { display: none; }
.conv-group .grow { min-width: 0; }
.grp-head-actions { display: flex; align-items: center; gap: 8px; flex: none; margin-top: 2px; }

/* smart folders (channel / status) */
.conv-folders { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.folder-chip { display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-family: inherit; font-size: 12.5px; padding: 6px 11px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--muted);
  transition: .12s; }
.folder-chip:hover { border-color: var(--primary); color: var(--text); }
.folder-chip.active { background: var(--primary); border-color: var(--primary);
  color: #fff; font-weight: 600; }
.folder-chip .ic { width: 14px; height: 14px; }
.folder-n { font-size: 11px; background: rgba(255,255,255,.18); border-radius: 999px;
  padding: 0 6px; min-width: 16px; text-align: center; }
.folder-chip:not(.active) .folder-n { background: var(--bg-soft); color: var(--muted); }
.folder-actions { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; padding: 8px 11px; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 10px; }
.folder-actions[hidden] { display: none; }

/* contact selection (bulk send) */
.icon-btn.on { border-color: var(--primary); color: var(--primary);
  background: rgba(184,165,169,.14); }
.conv-pick { display: none; width: auto; margin: 0; flex: none; cursor: pointer; }
.conversationsList.select-mode .conv-pick,
#conversationsList.select-mode .conv-pick { display: inline-block; }
.bulk-bar { background: var(--card); border: 1px solid var(--primary);
  border-radius: 12px; padding: 12px; margin-bottom: 12px; box-shadow: var(--shadow); }
.bulk-head { display: flex; align-items: center; justify-content: space-between;
  font-size: 13.5px; margin-bottom: 8px; }
.bulk-head b { color: var(--primary); }
.bulk-x { background: transparent; border: none; color: var(--muted); cursor: pointer;
  display: inline-flex; padding: 2px; }
.bulk-x:hover { color: var(--text); }
.bulk-bar textarea { margin: 0 0 8px; }
.bulk-actions { display: flex; gap: 8px; align-items: center; }
.bulk-actions .primary { margin-inline-start: auto; }

/* contact row inside a group */
.conv-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px 14px 30px;
  cursor: pointer; border-top: 1px solid var(--line); transition: background .12s; }
.conv-row:hover { background: var(--bg-soft); }
.conv-row.active { background: rgba(184,165,169,.12); box-shadow: inset 3px 0 0 var(--primary); }
.conv-row.has-new .row-name::after { content: "●"; color: var(--green); font-size: 9px;
  vertical-align: middle; margin-right: 5px; }
.conv-row .grow { min-width: 0; }
.conv-row .avatar { width: 36px; height: 36px; font-size: 12px; margin-top: 1px; }
.conv-row .conv-pick { margin-top: 12px; }
.conv-row .serious { margin-top: 2px; }

.serious { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.serious.serious-serious { color: var(--green); background: rgba(67,201,138,.14); }
.serious.serious-promising { color: var(--primary); background: rgba(184,165,169,.14); }
.serious.serious-uncertain { color: var(--yellow); background: rgba(245,196,81,.14); }
.serious.serious-time_waster { color: var(--red); background: rgba(255,107,107,.14); }

/* Conversation detail header — identity + status on top, metadata row below */
.conv-head { display: flex; flex-direction: column; gap: 14px;
  padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.ch-id { display: flex; align-items: center; gap: 14px; }
.ch-id .avatar { width: 46px; height: 46px; font-size: 16px; flex: none; }
.ch-text { flex: 1; min-width: 0; }
.ch-contact { font-size: 18px; font-weight: 700; }
.ch-company { color: var(--muted); font-size: 13px; margin-top: 3px;
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.ch-company .ic { width: 14px; height: 14px; }
.ch-date { color: var(--muted); font-size: 12px; margin-top: 4px;
  display: inline-flex; align-items: center; gap: 5px; }
.ch-date .ic { width: 13px; height: 13px; }
.ch-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  justify-content: flex-end; flex: none; }
.ch-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ch-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--card-2);
  border: 1px solid var(--line); color: var(--muted); text-decoration: none; }
.chip.ok { color: var(--green); border-color: rgba(67,201,138,.4); }
.chip.warn { color: var(--yellow); border-color: rgba(245,196,81,.4); }

/* Conversation detail = a self-contained messaging column */
.conv-detail { display: flex; flex-direction: column;
  height: calc(100vh - 210px); min-height: 460px; padding: 0; overflow: hidden; }
.conv-detail > .empty { margin: auto; }
.conv-head { padding: 20px 24px; margin: 0; flex: none; }

/* Chat — clear who-vs-who, scrolls; everything else stays pinned */
.chat { flex: 1 1 auto; display: flex; flex-direction: column; gap: 16px;
  margin: 0; overflow-y: auto; padding: 22px 24px;
  background: linear-gradient(180deg, rgba(0,0,0,.06), transparent 120px); }
.chat .empty { margin: auto; }
.msg-row { display: flex; gap: 9px; align-items: flex-end; max-width: 82%; }
.msg-row.them { align-self: flex-start; }
.msg-row.us, .msg-row.draft { align-self: flex-end; flex-direction: row-reverse; }
.msg-row .avatar { width: 30px; height: 30px; font-size: 11px; }
.bubble { padding: 11px 15px 9px; border-radius: 16px; min-width: 90px;
  box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.bubble-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.bubble-head .who { font-size: 11.5px; font-weight: 700; }
.bubble .orig { font-size: 14px; line-height: 1.45; word-break: break-word;
  white-space: pre-wrap; }
.bubble .trans { font-size: 13px; color: var(--muted); margin-top: 6px;
  border-top: 1px dashed var(--line); padding-top: 6px; line-height: 1.4;
  white-space: pre-wrap; }
.bubble.them { background: var(--card-2); border-bottom-right-radius: 5px; }
.bubble.them .who { color: var(--green); }
.bubble.us { background: rgba(184,165,169,.2); border-bottom-left-radius: 5px; }
.bubble.us .who { color: var(--primary); }
.bubble.draft { background: rgba(245,196,81,.1); border: 1px dashed var(--yellow);
  border-bottom-left-radius: 5px; }
.bubble.draft .who { color: var(--yellow); }
/* timestamp + delivery status line */
.bubble-foot { display: flex; align-items: center; gap: 6px; margin-top: 4px;
  justify-content: flex-end; }
.bubble.them .bubble-foot { justify-content: flex-start; }
.bubble-foot .time { font-size: 10.5px; color: var(--muted); }
.tick { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px;
  font-weight: 600; }
.tick .ic { width: 13px; height: 13px; }
.tick.sent { color: var(--primary); }
.tick.draft { color: var(--yellow); }
.draft-note { margin-top: 8px; font-size: 11.5px; color: var(--yellow);
  display: flex; align-items: center; gap: 5px; opacity: .9; }
.draft-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* Day separator chip between messages of different days */
.day-sep { align-self: center; margin: 4px 0; }
.day-sep span { font-size: 11.5px; color: var(--muted); background: var(--bg-soft);
  border: 1px solid var(--line); padding: 3px 12px; border-radius: 999px; }

/* Photos inside a message bubble */
.msg-imgs { display: grid; gap: 4px; margin: 2px 0 4px; border-radius: 10px;
  overflow: hidden; max-width: 260px; }
.msg-imgs.n1 { grid-template-columns: 1fr; }
.msg-imgs.n2, .msg-imgs.n4 { grid-template-columns: 1fr 1fr; }
.msg-imgs.n3 { grid-template-columns: 1fr 1fr; }
.msg-img { padding: 0; border: none; background: var(--bg-soft); cursor: pointer;
  display: block; overflow: hidden; }
.msg-img img { width: 100%; height: 100%; max-height: 200px; object-fit: cover;
  display: block; transition: transform .2s; }
.msg-imgs.n1 .msg-img img { max-height: 240px; }
.msg-img:hover img { transform: scale(1.04); }

.flags-wrap { margin-top: 8px; }
.flags-wrap ul { margin: 6px 0 0; padding-right: 18px; }

.analysis-box { background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin: 0 18px; flex: none; }
.analysis-box summary { cursor: pointer; list-style: none; }
.analysis-box summary::-webkit-details-marker { display: none; }
.analysis-box summary h4 { display: inline-flex; }
.analysis-box h4 { margin: 0 0 8px; }
.analysis-box[open] h4 { margin-bottom: 8px; }
.flag { color: var(--red); font-size: 13px; }

/* AI / management toolbar */
/* symmetric, equal-width action buttons (wrap evenly, never ragged) */
.conv-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px; padding: 12px 18px 0; flex: none; }
.conv-actions .btn.small, .conv-actions .btn { padding: 8px 12px; font-size: 13px;
  justify-content: center; }

.empty { color: var(--muted); text-align: center; padding: 40px 10px; }

/* Supplier-reply panel (log a message that came FROM them) */
.incoming-panel { margin: 12px 18px 0; flex: none; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.ip-head { display: flex; align-items: center; gap: 7px; font-weight: 600;
  font-size: 13.5px; color: var(--green); margin-bottom: 8px; }
.ip-x { margin-inline-start: auto; background: transparent; border: none;
  color: var(--muted); cursor: pointer; display: inline-flex; padding: 2px; }
.ip-x:hover { color: var(--text); }
.ip-actions { display: flex; gap: 8px; margin-top: 8px; }
.ip-actions .primary { margin-inline-start: auto; }

/* WhatsApp-style composer pinned at the bottom */
.composer { flex: none; padding: 14px 22px 18px; border-top: 1px solid var(--line);
  background: var(--bg-soft); }
.composer-bar { display: flex; align-items: flex-end; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 5px 6px 5px 14px; }
.composer-bar:focus-within { border-color: var(--primary); }
.composer-bar textarea { flex: 1; margin: 0; border: none; background: transparent;
  padding: 8px 4px; resize: none; max-height: 140px; line-height: 1.4; }
.composer-bar textarea:focus { outline: none; }
.composer-icon { flex: none; background: transparent; border: none; cursor: pointer;
  color: var(--muted); display: inline-flex; padding: 8px; border-radius: 50%; }
.composer-icon:hover { color: var(--primary); background: var(--bg-soft); }
.composer-icon .ic { width: 22px; height: 22px; }
.composer-send { flex: none; width: 40px; height: 40px; border-radius: 50%;
  border: none; cursor: pointer; color: #fff; display: inline-flex;
  align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--primary), var(--primary-2)); }
.composer-send:hover { filter: brightness(1.08); }
.composer-send .ic { width: 19px; height: 19px; }
.composer-send:disabled { opacity: .6; cursor: default; }
.composer-add-incoming { margin: 8px auto 0; display: flex; align-items: center;
  gap: 6px; background: transparent; border: none; color: var(--muted);
  font-size: 12.5px; cursor: pointer; font-family: inherit; }
.composer-add-incoming:hover { color: var(--green); }

/* Composer toolbar: translate / style the free-text note before sending */
.composer-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-bottom: 8px; padding: 0 2px; }
.composer-tools .ct-hint { color: var(--muted); font-size: 12px;
  display: inline-flex; align-items: center; gap: 5px; flex-basis: 100%; }
/* the two prep buttons (translate / style) share the row equally */
.composer-tools .btn { flex: 1 1 0; justify-content: center; }
.composer-tools .ct-hint .ic { width: 14px; height: 14px; }

/* inline click-to-translate button on a supplier message */
.msg-translate { display: inline-flex; align-items: center; gap: 5px;
  margin-top: 4px; padding: 3px 9px; font-size: 11.5px; font-family: inherit;
  cursor: pointer; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--muted); }
.msg-translate:hover { color: var(--primary); border-color: var(--primary); }
.msg-translate .ic { width: 13px; height: 13px; }
.msg-translate:disabled { opacity: .6; cursor: default; }

/* visual language picker popup (translate to…) */
.lang-menu { position: absolute; z-index: 150; width: 180px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.28); display: flex; flex-direction: column; gap: 2px;
  animation: fade .12s ease; }
.lang-menu-head { display: flex; align-items: center; gap: 6px; font-size: 11.5px;
  color: var(--muted); padding: 6px 8px 4px; }
.lang-menu-head .ic { width: 14px; height: 14px; color: var(--primary); }
.lang-opt { text-align: start; background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 14px; color: var(--text); padding: 9px 10px;
  border-radius: 8px; }
.lang-opt:hover { background: var(--bg-soft); color: var(--primary); }

/* file (non-image) attachments inside a message bubble */
.msg-files { display: flex; flex-direction: column; gap: 5px; margin: 4px 0; }
.msg-file { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card-2);
  color: var(--text); text-decoration: none; font-size: 12.5px; }
.msg-file span { max-width: 220px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.msg-file:hover { border-color: var(--primary); }
.msg-file .ic { width: 15px; height: 15px; flex: none; color: var(--muted); }

/* Attachment preview tray (staged photos before sending) */
.att-tray { display: flex; flex-wrap: wrap; gap: 8px; }
.att-tray:not(:empty) { margin-bottom: 10px; }
.composer .att-tray:not(:empty) { padding: 0 4px; }
.att-thumb { position: relative; width: 60px; height: 60px; border-radius: 10px;
  overflow: hidden; border: 1px solid var(--line); }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-del { position: absolute; top: 2px; inset-inline-end: 2px; width: 20px;
  height: 20px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(0,0,0,.6); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; padding: 0; }
.att-del .ic { width: 13px; height: 13px; }

/* Image lightbox */
.lightbox { position: fixed; inset: 0; z-index: 200; display: flex;
  align-items: center; justify-content: center; background: rgba(0,0,0,.85);
  backdrop-filter: blur(4px); }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lb-close, .lb-download { position: fixed; top: 22px; width: 44px; height: 44px;
  border-radius: 50%; border: none; cursor: pointer; color: #fff;
  background: rgba(255,255,255,.14); display: inline-flex; align-items: center;
  justify-content: center; text-decoration: none; }
.lb-close { inset-inline-end: 22px; }
.lb-download { inset-inline-end: 76px; }
.lb-close:hover, .lb-download:hover { background: rgba(255,255,255,.28); }
.lb-close .ic, .lb-download .ic { width: 22px; height: 22px; }

/* Modal (email settings) */
.modal { position: fixed; inset: 0; z-index: 150; display: flex;
  align-items: center; justify-content: center; background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px); padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 22px; width: 100%;
  max-width: 460px; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.modal-x { background: transparent; border: none; color: var(--muted);
  cursor: pointer; display: inline-flex; padding: 4px; }
.modal-x:hover { color: var(--text); }
.modal-hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 8px 0 14px; }
.modal-warn { display: flex; align-items: center; gap: 7px; font-size: 12.5px;
  line-height: 1.4; background: rgba(245,196,81,.12); color: var(--yellow);
  border: 1px solid rgba(245,196,81,.35); border-radius: 10px; padding: 9px 11px;
  margin-bottom: 12px; }
.modal-warn[hidden] { display: none; }
.modal-card label { font-size: 13px; color: var(--muted); }
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 16px; }
.modal-status { color: var(--muted); font-size: 13px; }

/* Outbox modal — send all unsent drafts */
#outboxModal .modal-card { max-width: 640px; }
.outbox-list { display: flex; flex-direction: column; gap: 8px; max-height: 52vh;
  overflow-y: auto; margin: 4px 0 2px; }
.outbox-row { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card-2); }
.outbox-row .ob-main { min-width: 0; flex: 1; }
.outbox-row .ob-main b { display: inline-flex; align-items: center; gap: 6px; }
.outbox-row .ob-text { font-size: 12.5px; line-height: 1.45; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; }
.ob-side { display: flex; align-items: center; gap: 8px; flex: none; }
.ob-side .ob-open { white-space: nowrap; }
.ob-status { white-space: nowrap; font-size: 12px; font-weight: 700; }
.ob-status .ob-ok { color: var(--green); display: inline-flex; align-items: center; gap: 3px; }
.ob-status .ob-fail { color: var(--red, #e0556e); display: inline-flex; align-items: center; gap: 3px; }
.outbox-count, #outboxBtn .badge-count { margin-inline-start: 4px; }
#outboxBtn.has-pending { border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* Loud send-failure banner with a one-click fix (#3) */
.fix-banner { position: fixed; inset-inline: 0; top: 0; z-index: 200;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  justify-content: center; padding: 11px 16px;
  background: #5b2330; color: #ffe3e8; border-bottom: 1px solid #7a3344;
  box-shadow: 0 4px 16px rgba(0,0,0,.35); animation: fbDrop .2s ease; }
.fix-banner .fb-msg { display: inline-flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 600; }
.fix-banner .fb-msg .ic { width: 16px; height: 16px; }
.fix-banner .fb-actions { display: inline-flex; gap: 8px; }
.fix-banner .fb-x { background: transparent; border: none; color: #ffd0d8;
  cursor: pointer; display: inline-flex; padding: 4px; }
@keyframes fbDrop { from { transform: translateY(-100%); } to { transform: none; } }

/* background-task chip — lets you keep using Makor while a job runs */
.bg-task { position: fixed; inset-block-end: 18px; inset-inline-start: 18px; z-index: 190;
  display: none; align-items: center; gap: 9px; max-width: min(440px, 90vw);
  padding: 10px 14px; border-radius: 12px; background: var(--card);
  border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13px; }
.bg-task.show { display: flex; }
.bg-task .bg-label { font-weight: 700; white-space: nowrap; }
.bg-task .bg-msg { color: var(--muted); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.bg-task .bg-x { background: transparent; border: none; color: var(--muted);
  cursor: pointer; display: inline-flex; padding: 2px; margin-inline-start: auto; }
.bg-spin { width: 14px; height: 14px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
  flex: none; }

/* Broadcast (bulk send) */
.broadcast { margin-bottom: 18px; }
.broadcast-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.broadcast label { display: block; color: var(--muted); font-size: 13px; margin: 6px 0; }
.broadcast textarea { margin-bottom: 10px; }
.prod-card h3 .pick { width: auto; margin: 0 0 0 6px; vertical-align: middle; }

/* Reference image in results */
.ref-box { display: flex; align-items: center; gap: 10px; }
.ref-box img { width: 54px; height: 54px; object-fit: cover; border-radius: 10px;
  border: 2px solid var(--primary); }

/* Toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--card-2); border: 1px solid var(--primary); color: var(--text);
  padding: 12px 22px; border-radius: 12px; box-shadow: var(--shadow);
  transition: .3s; opacity: 0; z-index: 100; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.err { border-color: var(--red); }

/* Notification badges */
.badge-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  vertical-align: middle;
}
/* the [hidden] attribute must win over the display rule above */
.badge-count[hidden] { display: none; }
.bell { position: relative; }
.bell.has-new { animation: ring 1s ease; }
@keyframes ring { 0%,100%{transform:rotate(0)} 20%{transform:rotate(14deg)}
  40%{transform:rotate(-12deg)} 60%{transform:rotate(8deg)} 80%{transform:rotate(-4deg)} }
.auto-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  color: var(--muted); cursor: pointer; }
.auto-toggle input { width: auto; margin: 0; }
.conv-item.has-new { border-color: var(--green); box-shadow: 0 0 0 1px rgba(67,201,138,.3); }
.new-tag { background: var(--green); color: #062; font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px; }
/* FLOW ENGINE — stage pills (rows + conversation header) */
.stage-pill { display: inline-flex; align-items: center; gap: 3px; font-size: 11px;
  font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid transparent; }
.stage-pill .ic { width: 11px; height: 11px; }
.st-new     { background: rgba(150,160,175,.16); color: #8b94a3; border-color: rgba(150,160,175,.35); }
.st-draft   { background: #fff3d6; color: #8a5a00; border-color: #f0d28a; }
.st-sent    { background: rgba(91,140,255,.16); color: #5b8cff; border-color: rgba(91,140,255,.4); }
.st-replied { background: #dff3e6; color: #136c3a; border-color: #a9dcbd; }

/* FLOW ENGINE — pipeline filter bar above the chat list */
.stage-pipeline { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.stage-pipeline:empty { display: none; }
.stage-chip { display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--muted); }
.stage-chip b { font-weight: 800; color: var(--text); }
.stage-chip:hover { border-color: var(--accent); }
.stage-chip.active { outline: 2px solid var(--accent); outline-offset: -1px; color: var(--text); }
.stage-chip.st-draft.active   { background: #fff3d6; color: #8a5a00; }
.stage-chip.st-sent.active    { background: rgba(91,140,255,.16); color: #5b8cff; }
.stage-chip.st-replied.active { background: #dff3e6; color: #136c3a; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.par-why { color: var(--muted); font-size: 12.5px; }

/* Similar companies (web research) */
.similar-bar { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.similar-bar input { flex: 1 1 320px; }
.similar-bar .select { flex: 0 1 200px; }
.similar-bar .btn { flex: none; }
.understood { margin: 14px 0; border-right: 3px solid var(--primary); }
.understood h3 { margin: 0 0 6px; }
.understood p { margin: 0; color: var(--muted); }
.similar-sources { margin-top: 14px; }
.similar-sources summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.similar-sources ul { margin: 8px 0 0; padding-inline-start: 18px; }
.similar-sources li { margin: 3px 0; font-size: 13px; }
.similar-sources a { color: var(--primary); }

/* "Include parallels" checkbox in the product row */
.par-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px;
  color: var(--muted); cursor: pointer; user-select: none; }
.par-check input { width: auto; margin: 0; }

/* Engine tag on similar-companies results */
.engine-line { margin-bottom: 8px; }
.engine-tag { display: inline-block; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; }
.engine-tag.gem { background: rgba(184,165,169,.16); color: var(--primary); }
.engine-tag.oll { background: rgba(245,196,81,.16); color: var(--yellow); }

/* OEM/ODM + Chinese filter UI */
.engine-tag.filt { background: rgba(67,201,138,.16); color: var(--green); margin-inline-start: 6px; }
.badge.oem { background: var(--green); color: #062; font-weight: 700; }
.badge.so-status { margin-inline-start: 6px; font-weight: 700; }
.badge.so-status.drafted { background: #fff3d6; color: #8a5a00; border-color: #f0d28a; }
.badge.so-status.contacted { background: #dff3e6; color: #136c3a; border-color: #a9dcbd; }
.similar-count { margin: 6px 0 10px; }
.similar-toolbar { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 6px 0 12px; flex-wrap: wrap; }
.similar-more-wrap { display: flex; justify-content: center; margin: 18px 0 4px; }

/* OSINT deep-research report */
.card.osint { margin: 14px 0; border-right: 3px solid var(--accent); }
.osint-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.osint-head h3 { margin: 0; }
.osint-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.osint-sec { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.osint-sec h4 { margin: 0 0 6px; font-size: 14px; }
.osint-sec ul { margin: 0; padding-inline-start: 18px; }
.osint-sec li { margin: 3px 0; }
.osint-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.osint-flags li { color: var(--red); }

/* Recent searches (persisted) */
.recent-box { margin: 14px 0; }
.recent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: .12s; }
.recent-item:hover { border-color: var(--primary); background: var(--bg-soft); }
.recent-item .grow { min-width: 0; flex: 1; }
.recent-item .row-sub { margin-top: 2px; }
.recent-del { padding: 4px 7px; }

/* ===== Groups ===== */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title { display: inline-flex; align-items: center; gap: 8px; font-size: 15px;
  margin: 4px 0 12px; }
.section-title .ic { color: var(--primary); }
.wgroup-row { cursor: pointer; }
.wgroup-row:hover { border-color: var(--primary); background: var(--bg-soft); }
.wgroup-row .avatar { width: 40px; height: 40px; }
.group-new { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.group-new input { margin: 0; }
.group-new .btn { flex: none; }
.group-card { background: var(--card); border: 1px solid var(--line);
  border-inline-start: 4px solid var(--gc, var(--primary)); border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer;
  transition: .12s; }
.group-card:hover { border-color: var(--gc); background: var(--bg-soft); }
.group-card.active { box-shadow: 0 0 0 1px var(--gc); background: var(--bg-soft); }
.group-card .grow { flex: 1; min-width: 0; }
.group-name { font-weight: 600; font-size: 15px; display: inline-flex;
  align-items: center; gap: 7px; }
.group-name .ic { color: var(--gc); }
.group-detail { margin-top: 18px; border-inline-start: 4px solid var(--gc, var(--primary)); }
.gd-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; }
.gd-head h3 { margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.gd-head h3 .ic { color: var(--gc); }

/* group chip (on manufacturer cards + conversation header) */
.group-chip { font-size: 11.5px; font-weight: 600; padding: 2px 9px;
  border-radius: 999px; display: inline-flex; align-items: center; gap: 5px;
  background: color-mix(in srgb, var(--gc, var(--primary)) 18%, transparent);
  color: var(--gc, var(--primary)); }
.group-chip .ic { width: 12px; height: 12px; }
.chip-btn { background: var(--card-2); border: 1px dashed var(--line);
  color: var(--muted); cursor: pointer; font-family: inherit; }
.chip-btn:hover { border-color: var(--primary); color: var(--primary); }

/* connection row on manufacturer cards (products / chats / channels) */
.conn-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
  margin-top: 8px; }
.conn { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.conn b { color: var(--text); }
.conn.ok { color: var(--green); }

/* ===== Dashboard ===== */
.dash-head { display: flex; align-items: center; justify-content: space-between; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 20px; }
.kpi { display: flex; align-items: center; gap: 13px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
  box-shadow: var(--shadow); }
.kpi-ic { width: 42px; height: 42px; border-radius: 11px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(184,165,169,.14); color: var(--primary); }
.kpi-ic .ic { width: 22px; height: 22px; }
.kpi.ok .kpi-ic { background: rgba(67,201,138,.14); color: var(--green); }
.kpi.warn .kpi-ic { background: rgba(245,196,81,.16); color: var(--yellow); }
.kpi-num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.kpi-lbl { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (max-width: 820px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.dash-card { padding: 18px; }
.dash-card.wide { grid-column: 1 / -1; }
.dash-card h3 { margin: 0 0 14px; font-size: 15px; display: inline-flex;
  align-items: center; gap: 8px; }
.chart-empty { color: var(--muted); text-align: center; padding: 24px 0; font-size: 13px; }

/* donut + shared legend */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { flex: none; }
.donut-num { font-size: 26px; font-weight: 800; fill: var(--text);
  text-anchor: middle; }
.donut-lbl { font-size: 11px; fill: var(--muted); text-anchor: middle; }
.legend { display: flex; flex-direction: column; gap: 7px; }
.lg-item { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.lg-item b { color: var(--text); }
.lg-dot { width: 11px; height: 11px; border-radius: 3px; flex: none; }

/* horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 34px; align-items: center; gap: 10px; }
.hbar-lbl { font-size: 12.5px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: var(--bg-soft); border-radius: 999px; height: 12px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 999px; transition: width .4s; }
.hbar-val { font-size: 12.5px; font-weight: 700; text-align: center; }

/* funnel */
.funnel { display: flex; flex-direction: column; gap: 12px; }
.fn-step { display: grid; grid-template-columns: 92px minmax(0, 1fr) 40px; align-items: center; gap: 10px; }
.fn-step > span { font-size: 12.5px; color: var(--muted); }
.fn-step > i { font-size: 12px; color: var(--muted); font-style: normal; }
.fn-bar { background: linear-gradient(90deg, var(--primary), var(--primary-2));
  height: 26px; border-radius: 8px; display: flex; align-items: center;
  justify-content: flex-end; padding: 0 8px; min-width: 26px; transition: width .4s; }
.fn-bar b { font-size: 12.5px; font-weight: 700; color: #fff; }
.fn-bar.ok { background: linear-gradient(90deg, #43c98a, #2ea571); }
.fn-bar.best { background: linear-gradient(90deg, #ffb454, #e0823f); }

/* timeline */
.timeline { width: 100%; height: 160px; }
.timeline .axis { stroke: var(--line); stroke-width: 1; }
.timeline .tl-x { font-size: 10px; fill: var(--muted); }

/* top-suppliers table */
.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table th { text-align: start; color: var(--muted); font-weight: 600;
  padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 12px; }
.dash-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.dash-table tr[data-conv] { cursor: pointer; }
.dash-table tbody tr:hover { background: var(--bg-soft); }
.dash-table .serious { font-size: 11.5px; }

/* Capability focus input */
.similar-focus-label { display: block; margin-top: 10px; font-size: 13px; color: var(--muted); }
.similar-focus-label input { margin-top: 5px; }
/* "only companies with an Alibaba store" toggle */
.similar-opt { display: flex; align-items: center; gap: 9px; margin-top: 12px;
  font-size: 13px; color: var(--text); cursor: pointer; }
.similar-opt input { width: 17px; height: 17px; accent-color: var(--primary); flex: none; cursor: pointer; }
.similar-opt .ic { width: 14px; height: 14px; vertical-align: -2px; color: var(--accent); }
.similar-opt .hint { font-size: 12px; }
.btn.small.alibaba { color: var(--accent); border-color: rgba(255,180,84,.45); }
.btn.small.alibaba:hover { background: rgba(255,180,84,.12); }

/* bulk first-contact bar in the search results */
.similar-outreach { margin: 0 0 16px; padding: 16px; border-radius: 14px;
  background: var(--bg-soft); border: 1px solid rgba(255,180,84,.35); }
.similar-outreach .so-head { display: flex; align-items: center; flex-wrap: wrap;
  justify-content: flex-start; gap: 10px 12px; margin-bottom: 10px; }
.similar-outreach .so-head #soCount { margin-inline-start: auto; }
.similar-outreach textarea { width: 100%; margin: 0 0 10px; }
.similar-outreach .row-actions { gap: 8px; }
.similar-outreach .hint .ic { width: 13px; height: 13px; vertical-align: -2px; color: var(--accent); }
/* per-card selection checkbox (only on Alibaba companies) */
.prod-card { position: relative; }
.prod-card .card-pick { position: absolute; top: 10px; inset-inline-start: 10px;
  display: inline-flex; cursor: pointer; }
.prod-card .card-pick input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.prod-card.has-ali { border-color: rgba(255,180,84,.4); }

/* ============ Conversations v2 (Telegram-style) ============ */
.conv-list-head { display: flex; flex-direction: column; gap: 10px; align-items: stretch; margin-bottom: 10px; }
.conv-subtabs { display: flex; gap: 6px; flex-wrap: wrap; background: none;
  border: none; border-radius: 0; padding: 0; }
.subtab { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 600; border-radius: 999px; cursor: pointer; transition: .12s; }
.subtab .ic { width: 15px; height: 15px; }
.subtab:hover { color: var(--text); border-color: var(--muted); }
.subtab.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: none; }
.sub-n { font-size: 11px; background: var(--card-2); color: var(--muted); border-radius: 999px; padding: 0 6px; min-width: 16px; text-align: center; }
.subtab.active .sub-n { background: rgba(255,255,255,.22); color: #fff; }
.conv-list-head .conv-tools { display: flex; justify-content: flex-end; gap: 6px; }

/* compact, rounded "pill" filter bar — search + two filters + outbox icon.
   nowrap + horizontal scroll so it stays ONE tidy row and never stack-breaks. */
.conv-toolbar { display: flex; flex-wrap: wrap; align-items: center;
  gap: 7px; margin-bottom: 10px; }
/* search: a round icon button that EXPANDS on tap (and stays open while typed in) */
.conv-search-wrap { position: relative; flex: 0 0 auto; width: 38px;
  display: flex; align-items: center; overflow: hidden; transition: width .22s ease; }
.conv-search-wrap:focus-within,
.conv-search-wrap:has(.conv-search:not(:placeholder-shown)) {
  width: 210px; flex: 1 1 210px; }
.conv-search-ic { position: absolute; inset-inline-start: 12px; z-index: 1;
  width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.conv-search { width: 100%; height: 38px; margin: 0; padding: 8px 14px;
  padding-inline-start: 34px; border-radius: 999px; font-size: 13px;
  background: var(--bg-soft); cursor: pointer; }
.conv-search-wrap:focus-within .conv-search { cursor: text; }
/* selects + outbox as compact rounded pills that hug their content */
.conv-toolbar .pill { width: auto; flex: 0 0 auto; margin: 0;
  padding: 8px 14px; border-radius: 999px; font-size: 13px;
  background: var(--bg-soft); cursor: pointer; }
/* a native <select> otherwise grows to fit its LONGEST option (huge bar). Pin it
   to a fixed compact width (no shrink) so it's a small pill; the row scrolls. */
.conv-toolbar select.pill { flex: 1 1 132px; width: auto; min-width: 118px;
  padding-inline-end: 28px; text-overflow: ellipsis; }
.conv-toolbar .pill:hover { border-color: var(--primary); }
.conv-toolbar #outboxBtn.pill { gap: 0; position: relative; }
.conv-toolbar #outboxBtn .badge-count { margin-inline-start: 4px; }

.chat-list { display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 330px); overflow-y: auto; }
.chat-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 12px;
  cursor: pointer; transition: background .12s; }
.chat-row:hover { background: var(--bg-soft); }
.chat-row.active { background: rgba(184,165,169,.12); box-shadow: inset 3px 0 0 var(--primary); }
.chat-row.has-new .chat-name { font-weight: 700; }
.chat-row .avatar { width: 46px; height: 46px; font-size: 15px; flex: none; }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.chat-line1 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--muted); flex: none; }
.chat-line2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-sub { display: flex; align-items: center; gap: 7px; min-width: 0; overflow: hidden; }
.chat-company { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.chat-end { display: flex; align-items: center; gap: 7px; flex: none; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.wait-us { background: var(--green); } .status-dot.wait-them { background: var(--yellow); }
.status-dot.open { background: var(--primary); } .status-dot.closed { background: var(--muted); }
.serious-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.serious-dot.serious-serious { background: var(--green); } .serious-dot.serious-promising { background: var(--primary); }
.serious-dot.serious-uncertain { background: var(--yellow); } .serious-dot.serious-time_waster { background: var(--red); }
.unread-badge { background: var(--green); color: #04361f; font-size: 11px; font-weight: 800;
  min-width: 18px; height: 18px; border-radius: 999px; display: inline-flex; align-items: center;
  justify-content: center; padding: 0 5px; }
.chat-row .conv-pick { display: none; flex: none; }
.chat-list.select-mode .conv-pick { display: inline-block; }
.ingroup-tag { display: inline-flex; align-items: center; gap: 4px; flex: none;
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: rgba(67,201,138,.16); color: var(--green); }
.ingroup-tag .ic { width: 12px; height: 12px; }

/* AI report screen */
.report-screen { display: flex; flex-direction: column; height: 100%; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--line); flex: none; }
.report-head h3 { margin: 0; font-size: 16px; display: inline-flex; align-items: center; gap: 8px; }
.report-body { flex: 1; overflow-y: auto; padding: 18px; }
.rep-verdict { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px;
  margin-bottom: 18px; background: var(--bg-soft); border: 1px solid var(--line); }
.rep-score { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 22px; font-weight: 800; background: var(--card-2); flex: none; }
.rep-verdict.serious-serious .rep-score { background: rgba(67,201,138,.18); color: var(--green); }
.rep-verdict.serious-promising .rep-score { background: rgba(184,165,169,.18); color: var(--primary); }
.rep-verdict.serious-uncertain .rep-score { background: rgba(245,196,81,.18); color: var(--yellow); }
.rep-verdict.serious-time_waster .rep-score { background: rgba(255,107,107,.18); color: var(--red); }
.rep-label { font-size: 18px; font-weight: 700; }
.rep-sec { margin-bottom: 16px; }
.rep-sec h4 { margin: 0 0 6px; font-size: 14px; display: inline-flex; align-items: center; gap: 7px; color: var(--primary); }
.rep-sec p { margin: 0; line-height: 1.6; white-space: pre-wrap; }
.rep-flags { margin: 6px 0 0; padding-inline-start: 18px; }
.rep-flags li { color: var(--red); margin: 3px 0; }
.rep-feedback { margin-top: 8px; padding: 14px; border-radius: 12px;
  background: var(--bg-soft); border: 1px dashed var(--line); }
.rep-feedback .hint { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.fb-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* =====================================================================
   Responsive — breathe on big screens, stack cleanly on tablet / phone.
   ===================================================================== */
/* tablets: trim the outer padding so columns keep their room */
@media (max-width: 1024px) {
  .tabs { padding-inline: 22px; }
  main { padding-left: 22px; padding-right: 22px; }
}

/* phones & small tablets: single column, scrollable areas, touch-friendly */
@media (max-width: 760px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; row-gap: 8px; }
  .topbar h1 { font-size: 18px; }
  .subtitle { display: none; }
  .topbar-actions { gap: 8px; }

  /* tabs scroll horizontally instead of wrapping into a tall block */
  .tabs { padding: 12px 14px 0; gap: 4px; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  /* on phones the tabs scroll horizontally, so keep their natural size */
  .tab { flex: 0 0 auto; white-space: nowrap; height: 46px; padding: 0 16px; font-size: 14.5px; }
  .area-tab { flex: 1 1 0; }     /* 4 areas stay equal-width even on phones */
  .subtabs-row { padding: 10px 14px 0; overflow-x: auto; flex-wrap: nowrap;
    scrollbar-width: none; }
  .subtabs-row::-webkit-scrollbar { display: none; }
  .subtab2 { flex: 0 0 auto; }

  main { padding: 16px 14px 64px; }
  .panel-intro { margin-bottom: 16px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }

  /* conversations: list and chat each get their own scroll area, stacked */
  .conv-layout { gap: 14px; }
  .chat-list { max-height: 44vh; }
  .conv-detail { height: auto; min-height: unset; }
  .conv-detail .chat { max-height: 58vh; min-height: 300px; }
  .msg-row { max-width: 92%; }

  /* re-show the AI summary (the center duplicate was removed) below the chat */
  .ai-summary { display: flex; height: auto; min-height: unset; }
  .ai-summary .sum-body { max-height: 52vh; }

  /* results / cards comfortable on one column */
  .cards-grid { grid-template-columns: minmax(0, 1fr); }
  .results-head { flex-wrap: wrap; }
  .results-head .select { width: 100%; }
}

/* narrow phones */
@media (max-width: 460px) {
  .topbar-actions { gap: 6px; }
  .composer { padding: 8px 12px 14px; }
  .composer-tools { gap: 6px; }
  .composer-tools .ct-hint { flex-basis: 100%; margin: 0 0 2px; }
  .bubble .orig { font-size: 13.5px; }
  .conv-search-wrap:focus-within,
  .conv-search-wrap:has(.conv-search:not(:placeholder-shown)) {
    flex: 0 0 180px; width: 180px; }

  /* modals: stack paired inputs and let the action row wrap so nothing clips */
  .modal { padding: 12px; align-items: flex-start; }
  .modal-card { padding: 16px; max-height: 92vh; }
  .modal-row { grid-template-columns: 1fr; }
  .modal-actions { flex-wrap: wrap; gap: 8px; }
  .modal-actions .btn { flex: 1 1 auto; }
  .outbox-row { flex-direction: column; gap: 6px; }
  .outbox-row .ob-actions { align-self: flex-end; }
}

/* ===== Mobile full-screen chat (WhatsApp/Telegram pattern) ===============
   On a phone, tapping a conversation opens the chat FULL-SCREEN instead of
   stacking it under the list (which was cramped). You see EITHER the list OR
   the open chat; a back arrow returns to the list. Desktop is unaffected. */
.conv-back { display: none; }                 /* hidden on desktop — always */

@media (max-width: 860px) {
  /* list view (no chat open): show only the list, full height */
  #convDetail, #aiSummary { display: none; }
  .conv-layout:not(.chat-active) .chat-list { max-height: calc(100dvh - 320px); }

  /* chat view: hide the list; the chat pane is a FIXED-HEIGHT messaging column
     with its OWN scroll — only the bubbles scroll, the header + action buttons +
     composer stay pinned, so you never scroll the whole page to reach the input
     and the chat opens at its newest message. */
  .conv-layout.chat-active > .conv-list { display: none; }
  .conv-layout.chat-active > #convDetail {
    display: flex; flex-direction: column;
    height: calc(100dvh - 120px); min-height: 0; overflow: hidden;
  }
  .conv-layout.chat-active .chat {
    flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto;
    background: var(--bg);          /* darkest = the messages canvas; bubbles pop */
    padding: 12px 14px; gap: 10px;  /* tighter so more messages are visible */
  }

  /* ---- CLEAR VISUAL ZONES (so it's obvious: header vs messages vs actions) ----
     header = a raised CARD bar at the top · messages = the dark canvas ·
     actions+composer = a distinct SOFT bar at the bottom. */
  .conv-layout.chat-active > #convDetail { background: var(--bg); }
  .conv-layout.chat-active .conv-actions,
  .conv-layout.chat-active .composer,
  .conv-layout.chat-active .ch-note { background: var(--bg-soft); }
  .conv-layout.chat-active .conv-actions { border-top: 1px solid var(--line); }

  /* SLIM header on a raised card — one tight line + a small badges line. Date,
     extra chips and the verbose WeChat note are dropped on phones so the MESSAGES
     get the screen (they're still on desktop / in the list). */
  .conv-layout.chat-active .conv-head { padding: 6px 12px 8px; gap: 6px;
    background: var(--card); border-bottom: 1px solid var(--line); }
  .conv-layout.chat-active .ch-id { flex-wrap: wrap; align-items: center; gap: 9px; }
  .conv-layout.chat-active .ch-id .avatar { width: 34px; height: 34px; font-size: 13px; }
  .conv-layout.chat-active .ch-text { flex: 1 1 auto; min-width: 0; }
  .conv-layout.chat-active .ch-contact { font-size: 15px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
  .conv-layout.chat-active .ch-company { font-size: 11.5px; margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .conv-layout.chat-active .ch-date,
  .conv-layout.chat-active .ch-meta,
  .conv-layout.chat-active .ch-note,
  .conv-layout.chat-active .composer-add-incoming,
  .conv-layout.chat-active .composer-tools .ct-hint { display: none; }
  .conv-layout.chat-active .ch-status { flex-basis: 100%; flex-wrap: nowrap;
    overflow: hidden; gap: 5px; }

  /* compact, organised bottom bar (action buttons + composer) */
  .conv-layout.chat-active .conv-actions { padding: 8px 12px; gap: 6px; }
  .conv-layout.chat-active .conv-actions .btn { padding: 7px 8px; font-size: 12.5px; }
  .conv-layout.chat-active .composer { padding: 8px 12px 10px; }
  .conv-layout.chat-active .composer-tools { margin-bottom: 6px; gap: 6px; }
  /* slimmer send box */
  .conv-layout.chat-active .composer-bar { padding: 3px 5px 3px 10px; }
  .conv-layout.chat-active .composer-bar textarea { padding: 6px 2px; font-size: 14px; }
  .conv-layout.chat-active .composer-send { width: 36px; height: 36px; }
  .conv-layout.chat-active .composer-icon { padding: 6px; }
  .conv-layout.chat-active .composer-icon .ic { width: 20px; height: 20px; }

  /* the AI summary sits BELOW the chat pane (scroll the page down to reach it) */
  .conv-layout.chat-active > #aiSummary {
    display: flex; height: auto; min-height: unset; margin-top: 12px;
  }
  .conv-layout.chat-active > #aiSummary .sum-body { max-height: none; }

  /* back control = a slim top bar on the header card (RTL: arrow → = back) */
  .conv-back {
    display: flex; align-items: center; gap: 7px; width: 100%;
    background: var(--card); border: none; cursor: pointer; font: inherit;
    color: var(--primary); font-weight: 700; font-size: 14px;
    padding: 7px 12px 3px; margin: 0; align-self: stretch; flex: none;
  }
  .conv-back .ic { width: 17px; height: 17px; }
}
