/* FreelanceReach — the Inbox additions (counts, filters, row marks, lead context, the "About this person" panel,
   quick replies, keyboard shortcuts) and the Inbox / follow-up pop-up cards. Loaded after theme.css.
   Colours come only from the design tokens, so Light, Dark and Auto all work without blocks of their own. */

/* ================= Inbox: filters, counts, list ================= */
.inbox-tools .ib-filters { flex-wrap: wrap; }
.inbox-tools .ib-filters > select { flex: 1 1 120px; min-width: 0; width: auto; }
.inbox-tools .seg button { padding: 0 8px; }
.seg-n {
  display: inline-block; min-width: 18px; margin-left: 5px; padding: 0 5px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-text); font-size: 0.7188rem; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px;
}
.seg-n:empty { display: none; }
@media (max-width: 480px) { .inbox-tools .seg-ico { display: none; } }
.ib-keys { width: 32px; height: 32px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); font-size: 0.875rem; font-weight: 700; color: var(--muted); }
@media (pointer: coarse) { .ib-keys { display: none; } }
.inbox-count .need-line { color: var(--warn); font-weight: 650; }

/* marks on a conversation row */
.conv-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; min-width: 0; }
.cf {
  display: inline-flex; align-items: center; gap: 3px; max-width: 100%; padding: 0 7px;
  border: 1px solid transparent; border-radius: 999px; background: var(--surface-3); color: var(--text-2);
  font-size: 0.7188rem; font-weight: 600; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cf.hot { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); } /* a hot lead needs you = warn, the same as .badge.hot */
.cf.wait { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.cf.fu.due { background: var(--err-soft); color: var(--err); border-color: var(--err-line); }
.cf.draft { background: transparent; border-color: var(--line-strong); color: var(--muted); font-style: italic; }
.cf.stage-contacted { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.cf.stage-talking { background: var(--info-soft); color: var(--info); border-color: var(--info-line); font-weight: 700; } /* in progress = info; the brand green is not a status */
.cf.ai { background: var(--ai-soft); color: var(--ai); border-color: var(--ai-line); }
.cf.stage-proposal { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.cf.stage-won { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.cf.stage-lost { background: var(--surface-3); color: var(--muted); }

/* ================= Inbox: layout with the person panel ================= */
/* Wide: list | thread | person, once the Inbox area itself is wide enough (the sidebar takes 256 px of the window, so a
   1200 px window would leave the conversation under 300 px). Narrower: a one-line bar under the messages; opened, the
   panel takes the messages' place (.pp-open) until you tap the bar again. Phones: the same, in one column. */
#tab-inbox { container: inbox / inline-size; }
.inbox-list-pane { grid-area: list; }
.inbox-thread-pane { grid-area: thread; }
.inbox-layout { grid-template-areas: "list thread"; grid-template-rows: minmax(0, 1fr); }
.inbox-layout.has-person { grid-template-areas: "list thread" "list person"; grid-template-rows: minmax(0, 1fr) auto; }
.inbox-person-pane {
  grid-area: person; display: none; flex-direction: column; min-height: 0; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden;
}
.inbox-layout.has-person .inbox-person-pane { display: flex; }
.inbox-layout.has-person.pp-open { grid-template-areas: "list person"; grid-template-rows: minmax(0, 1fr); }
.inbox-layout.has-person.pp-open .inbox-thread-pane { display: none; }
@container inbox (min-width: 1100px) {
  .inbox-layout.has-person, .inbox-layout.has-person.pp-open {
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) minmax(240px, 290px);
    grid-template-areas: "list thread person"; grid-template-rows: minmax(0, 1fr);
  }
  .inbox-layout.has-person.pp-open .inbox-thread-pane { display: flex; }
}
@media (max-width: 899.98px) {
  [data-role="lead-ctx"] { display: none; }
  .lead-ctx-inline { display: block; }
  .inbox-layout { grid-template-areas: "list"; }
  .inbox-layout.has-open { grid-template-areas: "thread"; }
  .inbox-layout.has-person { grid-template-columns: minmax(0, 1fr); grid-template-areas: "thread" "person"; grid-template-rows: minmax(0, 1fr) auto; }
  .inbox-layout.has-person.pp-open { grid-template-areas: "person"; grid-template-rows: minmax(0, 1fr); }
}

/* the chat agent's strip under the conversation head: whose conversation it is for the agent, and "Needs you" + Done.
   Its own row, because on a phone the head is one line. Each line stays short there (one line, or two for their text). */
.agent-bar { display: grid; gap: 4px; padding: 6px 14px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); min-width: 0; }
.agent-need { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--warn); } /* warn = needs you (styles.css colour meanings) */
.agent-need > .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-need .chip { flex: none; }
.agent-need.urgent b { color: var(--err); }
.agent-need-text {
  margin: 0; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.agent-note { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 899.98px) { .agent-bar { padding: 6px 10px; } }
/* a message the app sent by itself (chat agent, automatic follow-up, automatic answer): a dashed edge, and its label */
#tab-inbox .bubble.out.by-app { border-style: dashed; border-color: rgba(255, 255, 255, 0.6); }

/* what they asked for in a group (when they're one of your leads) */
.lead-ctx { display: grid; gap: 4px; padding: 8px 14px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); } /* what they asked for: plain context, not AI-written */
.lead-ctx-top { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; min-width: 0; }
.lead-ctx-acts { display: inline-flex; flex: none; gap: 4px; }
@media (pointer: fine) { .lead-ctx-acts .link { min-height: 28px; padding: 2px 4px; } }
.lead-ctx-inline { display: none; }
.lead-ctx-inline .lead-ctx { border: 1px solid var(--line); border-radius: var(--r); }
.lead-ctx-text {
  margin: 0; font-size: 0.8438rem; line-height: 1.45; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ================= the "About this person" panel ================= */
.pp { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.pp-heading { display: none; margin: 0; padding: 12px 14px 0; font-size: 0.875rem; }
.pp-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 14px;
  border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.pp-toggle:hover { background: var(--surface-2); }
.pp-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.pp-toggle-title { flex: none; font-size: 0.875rem; font-weight: 650; }
.pp-sum { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.7813rem; color: var(--muted); }
.pp-chev { flex: none; color: var(--muted); transition: transform var(--dur-2) var(--ease); }
.pp:not(.collapsed) .pp-chev { transform: rotate(180deg); }
.pp-scroll { display: grid; gap: 14px; align-content: start; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 14px 14px; overscroll-behavior: contain; }
.pp.collapsed .pp-scroll { display: none; }
.pp-back { display: none; flex: 1 1 auto; text-align: right; color: var(--primary-text); font-weight: 600; }
.pp:not(.collapsed) .pp-sum { display: none; }
.pp:not(.collapsed) .pp-back { display: inline; }
@container inbox (min-width: 1100px) {
  .pp-heading { display: block; }
  .pp-toggle { display: none; }
  .pp.collapsed .pp-scroll { display: grid; }
  .pp-scroll { padding-top: 10px; }
}
.pp-fields { display: grid; gap: 14px; }
.pp .field textarea { min-height: 84px; }
.field > label.pp-sub { margin-top: 4px; font-size: 0.7813rem; font-weight: 500; color: var(--muted); }
.pp-state { margin-left: 6px; font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.pp-state.err { color: var(--err); }
.pp-fu-now { font-size: 0.8125rem; color: var(--text-2); }
.pp-fu-now .due { color: var(--err); }
.pp-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.7813rem; }
.pp-facts:empty { display: none; }
.pp-facts dt { color: var(--muted); }
.pp-facts dd { margin: 0; color: var(--text-2); overflow-wrap: anywhere; }

/* phones: the secondary reply buttons show only their icon (their names stay for screen readers via the title) */
@media (max-width: 480px) { .composer .btn-lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; } }

/* ================= quick replies menu ================= */
.composer { position: relative; }
.composer > .qr-host { position: absolute; left: 14px; right: 14px; bottom: 100%; height: 0; z-index: 20; }
.composer .qr-menu { position: absolute; left: 0; right: 0; bottom: 6px; max-height: min(340px, 55vh); max-height: min(340px, 55dvh); box-shadow: var(--shadow-3); transform-origin: 50% 100%; animation: modal-in var(--dur-2) var(--ease) both; }
.qr-menu {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.qr-head { padding: 8px 12px 2px; }
.qr-list { position: relative; display: grid; gap: 2px; align-content: start; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px; overscroll-behavior: contain; }
.qr-item {
  display: grid; gap: 1px; width: 100%; min-width: 0; padding: 7px 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.qr-item:hover, .qr-item.on { background: var(--primary-soft); }
.qr-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.qr-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.qr-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8438rem; font-weight: 650; }
.qr-sc { flex: none; font: 0.75rem/1.4 var(--mono); color: var(--primary-text); }
.qr-prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.7813rem; color: var(--muted); }
.qr-empty { margin: 0; padding: 8px 12px 10px; }
.qr-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; padding: 2px 6px; border-top: 1px solid var(--line); }

/* keyboard shortcuts dialog */
.kbd-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; align-items: center; margin: 0; }
.kbd-list dt { white-space: nowrap; }
.kbd-list dd { margin: 0; font-size: 0.875rem; color: var(--text-2); }

/* ================= pop-up stack: room to scroll when cards and reply boxes don't fit ================= */
/* The padding keeps the cards' shadows inside the scroll box; the negative margin keeps the cards where they were. */
.lead-pops {
  max-height: calc(100vh - var(--topbar-h) - var(--bottombar-h) - 8px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  max-height: calc(100dvh - var(--topbar-h) - var(--bottombar-h) - 8px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  width: calc(min(380px, 100vw - 32px) + 40px); margin: -4px -16px 0 0; padding: 4px 16px 28px 24px;
}
.lead-pops::-webkit-scrollbar { display: none; }
.lead-pops:empty { display: none; }
@media (max-width: 700px) {
  .lead-pops { left: 0; right: 0; width: auto; margin: -4px 0 0; padding: 4px 16px 28px; }
}

/* ================= Inbox and follow-up pop-up cards ================= */
.lead-pop.ib-pop { border-left-color: var(--info); }
.lead-pop.fu-pop { border-left-color: var(--warn-dot); }
.lp-badges { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; min-width: 0; }
.lp-badge.ib { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--info-soft); color: var(--info); }
.lp-badge.due { background: var(--warn-soft); color: var(--warn); }
.lp-time { white-space: nowrap; }
.lp-more-links { display: flex; flex-wrap: wrap; gap: 2px 8px; min-width: 0; }
.lp-reply { display: grid; gap: 6px; margin-top: 2px; }
.lp-reply textarea { min-height: 72px; font-size: 0.875rem; }
.lp-reply-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.lp-reply-actions .btn.primary { white-space: normal; text-align: left; }
.lp-reply .qr-host { display: contents; }
.lp-reply .qr-menu { max-height: 240px; background: var(--surface-2); -webkit-backdrop-filter: none; backdrop-filter: none; }

/* ---------- Alerts tab: every buyer lead and message, opened or not ---------- */
.alerts-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.alert-row { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border: 1px solid var(--glass-edge, var(--line)); border-left: 3px solid var(--primary); border-radius: var(--r); background: var(--glass, var(--surface)); box-shadow: var(--shadow-1); }
.alert-row.opened { border-left-color: var(--line-strong); opacity: 0.88; }
.alert-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.alert-time { margin-left: auto; font-size: 0.75rem; color: var(--muted); }
.alert-who { font-size: 0.875rem; overflow-wrap: anywhere; }
.alert-text { margin: 0; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.alert-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.badge.hot { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.lead-pop.opened { border-left-color: var(--line-strong); }
.lp-badge.opened-tag { margin-left: auto; background: var(--ok-soft); color: var(--ok); }

/* ---------- Answer a lead (dialog) ---------- */
.lr { display: flex; flex-direction: column; gap: 12px; }
.lr-to { margin: 0; }
.lr-quote { margin: 0; padding: 10px 12px; border-left: 3px solid var(--primary-line); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--surface-2); color: var(--text-2); font-size: 0.8438rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9em; overflow: auto; }
.lr-mode { align-self: flex-start; }
.lr-box { position: relative; }
.lr-box textarea { width: 100%; min-height: 120px; }
.lr .field { display: flex; flex-direction: column; gap: 4px; }
.lp-when { color: var(--text-2); }

/* ---------- Activity log: readable counts on the selected account tab; skipped rows are not failures ---------- */
.log-tab-counts { font-size: 0.75rem; opacity: 0.85; }
.chip.on .log-tab-counts, .chip.on .muted { color: inherit; opacity: 0.95; }
.log-row.skip .log-main b { color: var(--text-2); }
/* On a phone the account chips are one row you swipe sideways, not a block that fills half the screen. */
@media (max-width: 600px) {
  .row.wrap.log-accounts { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity; scroll-padding-inline: 2px; scrollbar-width: none; padding: 2px; margin-inline: -2px; }
  .row.wrap.log-accounts::-webkit-scrollbar { display: none; }
  .log-accounts > .chip { flex: 0 0 auto; max-width: none; min-height: 44px; white-space: nowrap; scroll-snap-align: start; }
}

/* ---------- Multi-select filter (Leads: sources, status) ---------- */
.msel { position: relative; }
.msel > summary { list-style: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 34px 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--field-bg, var(--surface)) var(--select-arrow) no-repeat right 10px center / 16px; color: var(--text); font-size: 0.875rem; cursor: pointer; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.msel > summary::-webkit-details-marker { display: none; }
.msel[open] > summary { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.msel-pop { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 240px; max-height: 340px; overflow: auto; display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 1px solid var(--glass-edge, var(--line)); border-radius: var(--r); background: var(--glass-strong, var(--surface)); box-shadow: var(--shadow-3); -webkit-backdrop-filter: var(--blur, none); backdrop-filter: var(--blur, none); transform-origin: top left; animation: pop-in var(--dur-2) var(--ease) both; }
.msel-opt { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 8px; border-radius: 8px; font-size: 0.875rem; cursor: pointer; white-space: nowrap; }
.msel-opt:hover { background: var(--primary-soft); }
.msel-clear { align-self: flex-start; margin: 4px 8px 0; }
@media (max-width: 600px) { .msel > summary { max-width: 100%; } .msel-pop { min-width: min(280px, calc(100vw - 48px)); } }

/* ---------- Account health ---------- */
.health-list { display: flex; flex-direction: column; gap: 10px; }
.health-row { display: flex; gap: 14px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.health-score { flex: none; width: 64px; height: 64px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 3px solid var(--line-strong); }
.health-score b { font-size: 1.25rem; line-height: 1; }
.health-score span { font-size: 0.6875rem; color: var(--muted); }
.health-score.ok { border-color: var(--ok-dot); }
.health-score.warn { border-color: var(--warn-dot); }
.health-score.err { border-color: var(--err-dot); }
.health-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

/* ---------- Sales BD Agent ---------- */
.bd-banner { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bd-banner .callout .btn { margin-left: 8px; }
.bd-views { margin-bottom: 14px; max-width: 100%; }
.bd-view > .card + .card, .bd-view > .card + .table-wrap { margin-top: 14px; }
.bd-stats { margin-bottom: 2px; }
.bd-steps { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.875rem; }
.bd-steps li { display: flex; gap: 8px; align-items: baseline; }
.bd-steps li > span { width: 1.2em; flex: none; color: var(--muted); }
.bd-steps li.done > span { color: var(--ok); }
.bd-steps li.done .link { color: var(--muted); text-decoration: line-through; }
.bd-toolbar > input[type="search"] { flex: 2 1 240px; }
.bd-num { width: 110px !important; flex: none !important; }
.bd-date { width: 160px !important; flex: none !important; }
.bd-table td { vertical-align: top; }
.bd-table tr[data-open] { cursor: pointer; }
.bd-table tr[data-open]:hover td { background: var(--primary-soft); }
.bd-table tr[data-open]:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.table-wrap td.bd-wrap, .bd-wrap { white-space: normal; min-width: 160px; max-width: 360px; }
.bd-h { margin: 0; font-size: 1.125rem; }
.bd-stage { min-width: 190px; }
.bd-box { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); min-width: 0; }
.bd-box > h4, .bd-box h4 { margin: 0 0 8px; font-size: 0.875rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.bd-box > summary { cursor: pointer; }
.bd-box textarea, .bd-box input:not([type="checkbox"]) { width: 100%; }
.bd-box .row > input { width: auto; }
.bd-mini { width: 100%; font-size: 0.8125rem; }
.bd-mini td { padding: 4px 6px 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.bd-mini td.num { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 650; }
.bd-ul { margin: 4px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.bd-pick { max-height: 52vh; max-height: 52dvh; overflow: auto; margin-top: 8px; }
.bd-pick .check-item { display: flex; gap: 10px; align-items: flex-start; }
.bd-pick .check-item > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bd-draft { margin-top: 14px; }
.bd-draft textarea { width: 100%; font-family: inherit; line-height: 1.5; }
.bd-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.bd-col { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); min-height: 120px; }
.bd-col > h4 { margin: 0; font-size: 0.8125rem; display: flex; justify-content: space-between; gap: 6px; }
.bd-pcard { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 0.8438rem; cursor: pointer; transition: border-color var(--dur-1), transform var(--dur-1) var(--ease); }
.bd-pcard:hover { border-color: var(--primary); }
.bd-profile .bd-span { grid-column: 1 / -1; }
.bd-profile textarea { width: 100%; }
@media (max-width: 899.98px) { .bd-board { grid-auto-columns: minmax(180px, 78vw); } .bd-stage { min-width: 0; width: 100%; } }
.bd-view .card > .subhead:first-child { margin-top: 0; padding-top: 0; border-top: 0; margin-bottom: 6px; }
@media (min-width: 900px) { .bd-views { flex-wrap: wrap; overflow: visible; } }
/* Sales BD Agent — automation, analytics, approval */
.bd-today .bd-h { font-size: 1.0625rem; }
.bd-countries { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-top: 6px; }
.bd-country { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); cursor: pointer; font-size: 0.8438rem; }
.bd-country > span { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.bd-country.off { opacity: 0.55; cursor: not-allowed; }
.bd-chart { width: 100%; height: 160px; display: block; margin-top: 8px; }
/* chart: sent = ok, a reply that came back = info (the same meanings as every badge) */
.bd-chart .bar-sent { fill: var(--ok-dot); opacity: 0.8; }
.bd-chart .bar-reply { fill: var(--info-dot); }
.bd-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; margin: 0 4px 0 8px; }
.bd-key.sent { background: var(--ok-dot); opacity: 0.8; }
.bd-key.reply { background: var(--info-dot); }
.bd-research { padding: 10px 12px; }
.bd-research ul { margin-top: 6px; }
.bd-bulk { position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 2; padding: 8px 0; background: var(--bg, transparent); }
/* the phone card's address to type: large, monospaced, one tap selects it all */
.dev-url { font-family: var(--mono); font-size: 1.1875rem; font-weight: 650; line-height: 1.3; word-break: break-all; -webkit-user-select: all; user-select: all; }
.bd-draft input[data-pick] { width: 18px; height: 18px; vertical-align: middle; }

/* Sales BD: Automatic / Manual switch */
.bd-mode { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.bd-mode .seg { flex: none; }
.bd-mode .small { flex: 1 1 260px; min-width: 0; }
/* Sales BD: What's running */
.bd-now { margin: 0; font-size: 0.9375rem; }
.bd-now .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted-dot); margin-right: 4px; vertical-align: middle; }
.bd-now .dot.live { background: var(--ok-dot); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok-dot) 25%, transparent); animation: bd-pulse 1.6s ease-in-out infinite; }
.bd-now .dot.off { background: transparent; border: 1.5px solid var(--muted-dot); }
@keyframes bd-pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .bd-now .dot.live { animation: none; } }
.err-text { color: var(--err); }
.bd-slots { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bd-slot { padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line, rgba(127,127,127,.3)); font-variant-numeric: tabular-nums; }
.bd-slot.done { opacity: .65; }
.bd-slot.due { border-color: var(--warn, #c98a0b); }
.bd-flow { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 760px) { .bd-flow { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 420px) { .bd-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bd-flow-step { position: relative; padding: 10px 12px; border-radius: 10px; background: var(--surface-2, rgba(127,127,127,.08)); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bd-flow-step b { font-size: 1.375rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bd-flow-step span { font-size: 0.75rem; font-weight: 600; }
.bd-flow-step em { font-style: normal; font-size: 0.6875rem; color: var(--muted); overflow-wrap: anywhere; }
.bd-flow-step.attn { outline: 2px solid var(--warn-dot); } /* needs you = warn */
.bd-sources { display: grid; gap: 4px; }
.bd-brief { border-top: 1px dashed var(--line, rgba(127,127,127,.3)); padding-top: 8px; }
.bd-brief p { margin: 4px 0; }
.bd-slide { padding: 10px; border-radius: 8px; background: var(--surface-2, rgba(127,127,127,.08)); min-width: 0; overflow-wrap: anywhere; }
.bd-footer { margin-top: 6px; padding: 6px 8px; border-left: 2px solid var(--line, rgba(127,127,127,.3)); white-space: normal; overflow-wrap: anywhere; }

/* ---------- Sales BD: the swarm blueprint (a dark console panel in both themes) ---------- */
.sw { --sw-bg: #0b1216; --sw-card: #111b20; --sw-line: #1f3a3f; --sw-text: #d7e4e6; --sw-muted: #8aa3a8; --sw-accent: #5eead4; --sw-warn: #fbbf24; --sw-stop: #f87171;
  background: var(--sw-bg); color: var(--sw-text); border-radius: 14px; padding: 16px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.75rem; }
.sw a { color: var(--sw-accent); }
.sw-muted { color: var(--sw-muted); }
.sw-tag { display: inline-block; padding: 1px 6px; border: 1px solid var(--sw-accent); border-radius: 4px; color: var(--sw-accent); margin: 0 6px; }
.sw-plan { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--sw-line); border-radius: 10px; background: var(--sw-card); margin-bottom: 14px; }
.sw-run { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; }
.sw-grid { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 18px 34px; }
.sw-col { display: grid; gap: 14px; align-content: start; position: relative; z-index: 1; }
.sw-wires { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: visible; }
.sw-wires path { fill: none; stroke: var(--sw-accent); stroke-opacity: .35; stroke-width: 1.2; }
.sw-node { background: var(--sw-card); border: 1px solid var(--sw-line); border-radius: 8px; padding: 8px 10px; min-width: 0; font-size: 0.6875rem; }
.sw-node header { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--sw-line); color: var(--sw-accent); }
.sw-node dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
.sw-node dt { color: var(--sw-muted); white-space: nowrap; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
.sw-node dd { margin: 0; text-align: right; overflow-wrap: break-word; min-width: 0; }
.sw-note { margin: 6px 0 0; color: var(--sw-warn); }
.sw-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sw-accent); flex: none; }
.sw-dot.busy, .sw-busy .sw-dot { animation: sw-pulse 1.2s ease-in-out infinite; }
.sw-waiting .sw-dot, .sw-off .sw-dot { background: var(--sw-muted); }
.sw-warn .sw-dot { background: var(--sw-warn); }
.sw-stop { border-color: var(--sw-stop); }
.sw-stop .sw-dot { background: var(--sw-stop); }
.sw-stop header { color: var(--sw-stop); }
@keyframes sw-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .sw-dot.busy, .sw-busy .sw-dot { animation: none; } }
.sw-spark { display: flex; align-items: flex-end; gap: 2px; height: 22px; margin-top: 8px; }
.sw-spark i { flex: 1; background: var(--sw-accent); opacity: .7; border-radius: 1px; min-height: 2px; }
.sw-spark i.z { opacity: .15; }
.sw-funnel { margin-top: 16px; padding: 10px 12px; border-top: 1px solid var(--sw-line); display: grid; gap: 6px; }
.sw-funnel b { color: var(--sw-accent); font-size: 0.875rem; }
.sw-arrow { color: var(--sw-muted); margin: 0 4px; }
.sw-trace { margin-top: 14px; padding: 12px; border: 1px solid var(--sw-line); border-radius: 10px; background: var(--sw-card); }
.sw-trace select { background: var(--sw-bg); color: var(--sw-text); border: 1px solid var(--sw-line); border-radius: 6px; padding: 4px 6px; max-width: 100%; font: inherit; }
.sw-trace h4 { margin: 10px 0 6px; color: var(--sw-text); }
.sw-steps { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.sw-steps li { padding-left: 4px; overflow-wrap: anywhere; }
.sw-steps li b { color: var(--sw-accent); }
.sw-steps li.no b { color: var(--sw-warn); }
.sw-steps li > div { color: var(--sw-text); }
.sw-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
@media (max-width: 1100px) { .sw-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .sw { padding: 12px; } .sw-grid { grid-template-columns: 1fr; gap: 12px; } .sw-wires { display: none; } }

/* Sales BD drafts: collapse a card to its header and subject line */
.bd-draft .bd-fold{font-size: 0.9375rem;line-height:1;min-width:32px;min-height:32px;padding:4px 8px;margin-right:4px;border:1px solid var(--line,rgba(255,255,255,.15));border-radius:8px}
.bd-draft .bd-draft-sum{display:none;margin:6px 0 0}
.bd-draft.collapsed .bd-draft-body{display:none}
.bd-draft.collapsed .bd-draft-sum{display:block}

/* Weekly digest tab */
.digest-tip { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); line-height: 1.55; }
.digest-old + .digest-old { margin-top: 14px; }
.digest-todo { margin: 0; padding-left: 18px; display: grid; gap: 6px; }

/* touch screens: a tap must not leave this file's hover looks behind (these selectors out-rank the reset in styles.css) */
@media (hover: none) {
  .pp-toggle:hover, .qr-item:not(.on):hover, .msel-opt:hover { background: transparent; }
  .bd-pcard:hover { border-color: var(--line); }
  .bd-table tr[data-open]:hover td { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .composer .qr-menu, .msel-pop { animation-name: fade-in; }
}

/* people */
/* Settings → People who can log in: a person's Telegram accounts as small badges; a turned-off person reads greyed */
.person-accts { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
.list-item.is-off .strong, .list-item.is-off .person-accts { opacity: .6; }
/* Accounts tab for a member: the accounts they may use, read-only — no switches, buttons or proxy settings */
.acc.is-readonly .acc-switches, .acc.is-readonly [data-act], .acc.is-readonly details { display: none !important; }
/* A tab the logged-in person may not open (core.js): a calm note in place of the tab, never an error */
.callout.owner-only { max-width: 36rem; margin: 24px auto; }

/* ================= Inbox → 📋 Today (lib/today.js): who to act on, why, and one tap for what happened ================= */
.today-sec { padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.today-h { display: flex; align-items: center; gap: 6px; margin: 10px 12px 4px; font-size: 0.875rem; font-weight: 700; color: var(--text-2); }
.today-n { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-text); font-size: 0.7188rem; line-height: 18px; text-align: center; }
.today-hint, .today-more, .today-note { margin: 2px 12px 6px; }
.today-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); min-width: 0; }
.today-row.active { background: var(--primary-soft, var(--surface-3)); }
.today-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.today-why { font-size: 0.8438rem; color: var(--text-2); overflow-wrap: anywhere; }
.today-row .conv-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; font-size: 0.75rem; color: var(--muted); overflow-wrap: anywhere; }
.today-quote { margin: 2px 0; padding: 4px 8px; border-left: 3px solid var(--line-strong); color: var(--text-2); font-size: 0.8125rem; overflow-wrap: anywhere; white-space: pre-line; }
.today-draft { margin: 0; overflow-wrap: anywhere; }
.today-acts { margin-top: 4px; }
.today-acts .btn { min-height: 32px; }
.today-fold { margin: 4px 0 0; }
.today-fold > summary { margin: 0 12px; padding: 6px 0; cursor: pointer; color: var(--muted); }
.today-fold > .hint { margin: 0 12px 4px; }
@media (max-width: 480px) {
  .today-row { padding: 10px; gap: 8px; }
  .today-row .avatar { width: 34px; height: 34px; font-size: 0.875rem; }
  .today-acts .btn { flex: 1 1 auto; } /* the buttons share the line on a phone, none runs off the screen */
}

/* ================= Analytics → From request to client (lib/funnel.js) ================= */
.fn .grid2 { align-items: start; }
.fn-card .table td, .fn-card .table th { white-space: normal; }
.an-body .table td.num, .an-body .table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.th-sort { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap; }
.th-sort.on { color: var(--primary-text); }
.th-sort:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.fn-groups td:first-child { min-width: 150px; max-width: 260px; white-space: normal; overflow-wrap: anywhere; }
.fn-text { display: inline; white-space: normal; overflow-wrap: anywhere; }
.an-body .table td:has(> .fn-text) { min-width: 200px; white-space: normal; }

/* Settings → WhatsApp link: the preview of the link */
[data-wa-preview] .wa-link { overflow-wrap: anywhere; word-break: break-all; }
