:root {
  color-scheme: light;
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e2e5ea;
  --text: #151a22; --muted: #5f6b7a;
  --accent: #0e7a6d; --accent-hover: #0b6559; --accent-soft: #e3f3f0; --on-accent: #ffffff;
  --danger: #c0362c; --danger-soft: #fde9e7;
  --c-blue: #1f6feb; --c-blue-soft: #e5efff; --c-violet: #7445d6; --c-violet-soft: #efe8fd;
  --c-amber: #a35a00; --c-amber-soft: #fff1dc; --c-gray: #5f6b7a; --c-gray-soft: #eceff3;
  --c-teal: #0e7a6d; --c-teal-soft: #e3f3f0; --c-green: #157a42; --c-green-soft: #e5f5ec;
  --c-red: #c0362c; --c-red-soft: #fde9e7;
  --radius: 10px; --shadow: 0 1px 2px rgb(16 24 40 / 6%);
}
/* Dark: follows the system unless the viewer picked Light or Dark in the sidebar (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2a313b;
    --text: #e7eaee; --muted: #9aa4b2;
    --accent: #3cc4b2; --accent-hover: #5fd3c3; --accent-soft: #123430; --on-accent: #06221e;
    --danger: #ff7b72; --danger-soft: #3a1714;
    --c-blue: #79a8ff; --c-blue-soft: #16253f; --c-violet: #b39af5; --c-violet-soft: #261d3d;
    --c-amber: #f0b45b; --c-amber-soft: #36270f; --c-gray: #a5afbd; --c-gray-soft: #232932;
    --c-teal: #3cc4b2; --c-teal-soft: #123430; --c-green: #4ccb7f; --c-green-soft: #12301f;
    --c-red: #ff7b72; --c-red-soft: #3a1714;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2a313b;
  --text: #e7eaee; --muted: #9aa4b2;
  --accent: #3cc4b2; --accent-hover: #5fd3c3; --accent-soft: #123430; --on-accent: #06221e;
  --danger: #ff7b72; --danger-soft: #3a1714;
  --c-blue: #79a8ff; --c-blue-soft: #16253f; --c-violet: #b39af5; --c-violet-soft: #261d3d;
  --c-amber: #f0b45b; --c-amber-soft: #36270f; --c-gray: #a5afbd; --c-gray-soft: #232932;
  --c-teal: #3cc4b2; --c-teal-soft: #123430; --c-green: #4ccb7f; --c-green-soft: #12301f;
  --c-red: #ff7b72; --c-red-soft: #3a1714;
  --shadow: none;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 22px 0 8px; }
p { margin: 0 0 10px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: grid; gap: 4px; font-weight: 500; font-size: 13px; color: var(--muted); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
code { overflow-wrap: anywhere; } /* long URLs in instructions wrap instead of widening the page */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-align: left; }
.link:hover { color: var(--text); }

/* Layout */
.layout { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 8px 4px; }
.brand-mark { width: 28px; height: 32px; object-fit: contain; }
.nav { display: grid; gap: 2px; }
.nav a { padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .icon { opacity: .85; }
.me { margin-top: auto; display: grid; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--border); font-size: 13px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who > div { display: grid; min-width: 0; }
.who span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.me-actions { display: flex; gap: 4px; }
.me-actions .icon-btn:first-child { flex: 1; justify-content: flex-start; }
.search-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--muted); cursor: pointer; text-align: left; }
.search-btn:hover { color: var(--text); }
.search-btn span { flex: 1; }
.away-btn { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 13px; text-align: left; }
.away-btn:hover { color: var(--text); }
.away-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.away-btn + .me { margin-top: 10px; }
.icon-btn.on { color: var(--accent); }
.device-list { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; }
.device-list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.device-list .error { overflow-wrap: anywhere; }
.push-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: min(640px, calc(100vw - 32px)); padding: 12px 14px; border: 1px solid var(--accent); border-radius: 12px; background: var(--surface); box-shadow: 0 8px 24px rgb(0 0 0 / 20%); }
.push-bar span { flex: 1 1 240px; }
.push-bar .icon { color: var(--accent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.prospect h3 { margin: 0 0 4px; font-size: 16px; }
.prospect p { margin: 6px 0; overflow-wrap: anywhere; }
.ai-test { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.ai-test p { margin: 4px 0; }
kbd { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--muted); }

/* Icons, avatars, small controls */
.icon { width: 16px; height: 16px; flex: none; }
.kpi .icon { width: 18px; height: 18px; color: var(--accent); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.avatar { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.avatar.a0 { background: var(--c-blue-soft); color: var(--c-blue); }
.avatar.a1 { background: var(--c-violet-soft); color: var(--c-violet); }
.avatar.a2 { background: var(--c-teal-soft); color: var(--c-teal); }
.avatar.a3 { background: var(--c-amber-soft); color: var(--c-amber); }
.avatar.a4 { background: var(--c-green-soft); color: var(--c-green); }
.avatar.a5 { background: var(--c-red-soft); color: var(--c-red); }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; flex-wrap: nowrap; }
.sub { margin: 2px 0 0; }
.pre { white-space: pre-wrap; }
.stack.tight { gap: 12px; }
.stack.tight h3 { margin: 8px 0 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; color: var(--muted); font-weight: 500; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.secret-field { display: grid; gap: 4px; align-content: start; }
details.card > summary { font-weight: 600; font-size: 15px; }
details.card[open] > summary { margin-bottom: 8px; }
.warn-row td { background: var(--c-amber-soft); }

/* Ctrl/⌘+K search */
dialog.palette { width: min(600px, calc(100vw - 32px)); margin-top: 12vh; padding: 0; overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 4px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input input { border: 0; padding: 12px 0; font-size: 16px; background: none; outline: none; }
dialog.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
dialog.palette li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
dialog.palette li[aria-selected="true"] { background: var(--accent-soft); }
dialog.palette li.none { justify-content: center; padding: 18px; cursor: default; }
.main { padding: 28px 32px 60px; max-width: 1280px; width: 100%; display: grid; gap: 20px; align-content: start; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 20px; align-content: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.empty { color: var(--muted); text-align: center; padding: 28px 16px; margin: 0; }
.error, .form-error { color: var(--danger); margin: 0; }
.form-error:empty { display: none; }
.back { color: var(--muted); justify-self: start; }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi strong { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--c-green); font-weight: 600; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.bar { flex: 1; min-height: 2px; background: var(--accent); border-radius: 3px 3px 0 0; opacity: .8; }
.bar:hover { opacity: 1; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border: 0; }
.list li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-main { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; }
.kpi { position: relative; }
.kpi .icon { position: absolute; top: 14px; right: 14px; opacity: .8; }
.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 140px auto; gap: 4px 8px; }
.axis-max { align-self: start; }
.axis-x { grid-column: 2; display: flex; justify-content: space-between; }

/* Tasks */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.task-list li:last-child { border-bottom: 0; }
.task-list input[type="checkbox"] { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.task-list .icon-btn { height: 26px; min-width: 26px; padding: 0 4px; opacity: .6; }
.task-list .icon-btn:hover { opacity: 1; }
.task-list.compact li { align-items: center; }
.task-list .done { text-decoration: line-through; color: var(--muted); }
.due { white-space: nowrap; font-size: 12px; color: var(--muted); }
.due.today { color: var(--c-amber); font-weight: 600; }
.due.late { color: var(--danger); font-weight: 600; }
.card.late { border-color: var(--danger); }
.card.late h2 { color: var(--danger); }
.task-form { display: grid; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.task-form .row > input, .task-form .row > select { flex: 1 1 140px; width: auto; }
.reply-list { list-style: none; margin: 0 0 16px; padding: 0; }
.reply-list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
.card:not(.flush) :is(th, td):first-child { padding-left: 0; }
.card:not(.flush) :is(th, td):last-child { padding-right: 0; }
.flush :is(th, td):first-child { padding-left: 20px; }
.flush :is(th, td):last-child { padding-right: 20px; }
.flush th { background: var(--surface-2); }
.flush tbody tr:hover { background: var(--surface-2); }
.flush td { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); color: var(--muted); }
.pager span { margin-right: auto; }

/* Badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--c-gray-soft); color: var(--c-gray); }
.src-google_ads, .stage-c1 { background: var(--c-blue-soft); color: var(--c-blue); }
.src-facebook_ads, .stage-c2 { background: var(--c-violet-soft); color: var(--c-violet); }
.src-website, .stage-c4 { background: var(--c-teal-soft); color: var(--c-teal); }
.stage-c3 { background: var(--c-amber-soft); color: var(--c-amber); }
.stage-won, .badge.ok { background: var(--c-green-soft); color: var(--c-green); }
.stage-lost, .badge.bad { background: var(--c-red-soft); color: var(--c-red); }

/* Contacts */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; }
.toolbar input { flex: 2 1 260px; }
.toolbar select { flex: 1 1 150px; width: auto; }
.detail { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid > h2, .span-2 { grid-column: 1 / -1; margin-bottom: 0; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
#reach .kv { grid-template-columns: minmax(0, 1fr); gap: 6px; }
#reach dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-top: 10px; }
#reach dt:first-child { margin-top: 0; }
#reach dd p { margin: 6px 0; }
.note-form { display: grid; gap: 8px; justify-items: end; margin-bottom: 18px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 18px; border-left: 2px solid var(--border); margin-left: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--c-gray); border: 2px solid var(--surface); }
.timeline li.t-note::before { background: var(--accent); }
.timeline li.t-stage::before { background: var(--c-violet); }
.timeline li.t-whatsapp::before, .timeline li.t-task::before { background: var(--c-green); }
.timeline li.t-call::before { background: var(--c-blue); }
.timeline li.t-meeting::before { background: var(--c-amber); }
.timeline li.t-email::before { background: var(--c-teal); }
.t-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.contact-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.name-cell { display: flex; align-items: center; gap: 10px; }
th.sel, td.sel { width: 36px; padding-right: 0; }
.sel input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.bulkbar { position: sticky; top: 12px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent-soft); box-shadow: 0 6px 18px rgb(0 0 0 / 12%); }
.bulkbar[hidden] { display: none; }
.bulkbar select { width: auto; padding: 4px 8px; font-size: 13px; }
.bulkbar strong { margin-right: 4px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 400; font-size: 14px; }
label.check input { width: auto; margin: 0; }
.timeline li:last-child { border-left-color: transparent; }
.timeline small { display: block; white-space: normal; }

/* Chats */
.nav a { display: flex; align-items: center; gap: 8px; }
.count { margin-left: auto; min-width: 20px; text-align: center; background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 700; line-height: 20px; }
.chats { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 16px; height: calc(100vh - 150px); min-height: 440px; }
.card.chat-list { overflow-y: auto; } /* .card.flush sets overflow: hidden; match its specificity */
.chat-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.chat-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.chat-item:hover { background: var(--surface-2); text-decoration: none; }
.chat-item.active { background: var(--accent-soft); }
.chat-item .row { justify-content: space-between; flex-wrap: nowrap; }
.preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-thread { display: flex; flex-direction: column; min-height: 0; }
.thread-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.thread-head h2 { margin: 0 0 2px; }
.thread-head label { min-width: 160px; }
.messages { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: min(75%, 560px); display: grid; gap: 2px; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; justify-items: end; }
.bubble { padding: 8px 12px; border-radius: 12px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .media { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin-bottom: 6px; }
.bubble audio { display: block; max-width: 100%; margin-bottom: 4px; }
pre.recovery { font-size: 15px; letter-spacing: .05em; line-height: 1.8; }
.msg.in .bubble { border-bottom-left-radius: 4px; }
.msg.out .bubble { background: var(--accent-soft); border-bottom-right-radius: 4px; }
.st-read { color: var(--c-blue); }
.st-failed { color: var(--danger); }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); align-items: end; }
.composer-actions { display: grid; gap: 6px; }
.composer-actions select { width: 150px; padding: 5px 8px; font-size: 13px; }
.composer textarea { resize: none; }
.window-note { display: grid; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); margin: 0; }
.window-note p { margin: 0; }
.only-mobile { display: none; }
.src-whatsapp { background: var(--c-green-soft); color: var(--c-green); }

/* Pipeline */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.column { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: grid; gap: 10px; min-height: 240px; align-content: start; }
.column.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.column header { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; }
.cards { display: grid; gap: 8px; }
.deal { display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text); box-shadow: var(--shadow); cursor: grab; }
.deal:hover { border-color: var(--accent); text-decoration: none; }
.deal .value { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Integrations */
.steps { margin: 0 0 14px; padding-left: 20px; color: var(--muted); display: grid; gap: 4px; }
.steps b, .card p b { color: var(--text); font-weight: 600; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.copy { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 5px 5px 5px 12px; margin-bottom: 10px; }
.copy code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; }
.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow-y: auto; }
.warning { background: var(--c-amber-soft); color: var(--c-amber); border-radius: 8px; padding: 10px 14px; margin: 0; }
.sticky-save { position: sticky; bottom: 12px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* Dialog, login, toast */
dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgb(0 0 0 / 25%); }
dialog::backdrop { background: rgb(15 18 22 / 45%); }
.dialog-form { display: grid; gap: 12px; padding: 22px; }
.dialog-form h2 { margin: 0 0 4px; font-size: 17px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; padding: 28px; }
.login-card h1 { font-size: 20px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / 20%); z-index: 100; max-width: calc(100vw - 32px); }
.toast-error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a, .deal, .bar { transition: background-color .15s, border-color .15s, opacity .15s; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav { display: flex; overflow-x: auto; flex: 1 1 100%; order: 3; scrollbar-width: none; }
  .brand { padding: 0; }
  .search-btn { order: 2; width: auto; margin-left: auto; }
  .search-btn span, .search-btn kbd { display: none; }
  .me { order: 2; margin: 0; padding: 0; border: 0; }
  .away-btn { order: 2; width: auto; margin: 0; }
  .away-btn span { display: none; }
  .away-btn + .me { margin-top: 0; }
  .who, .me-actions .icon-btn span:not(.sr-only) { display: none; }
  .main { padding: 20px 16px 48px; }
  .grid-2, .detail, .grid-main { grid-template-columns: minmax(0, 1fr); }
  .detail > :last-child { order: -1; } /* on phones, Reach (call / WhatsApp / email) comes first */
  .chats { grid-template-columns: minmax(0, 1fr); height: auto; }
  .chats.has-thread .chat-list, .chats:not(.has-thread) .chat-thread { display: none; } /* phones show the list or one chat */
  .chat-thread { height: calc(100vh - 210px); min-height: 420px; }
  .only-mobile { display: inline; }
  .nav .count { margin-left: 0; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

/* v4: QR, stage editor, routing, files, trend chart */
.qr { width: 200px; margin: 4px auto 8px; padding: 0; border-radius: 8px; overflow: hidden; }
.qr svg { display: block; width: 100%; height: auto; }
details summary { margin: 4px 0; }
.stage-editor { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; counter-reset: st; }
.stage-editor li { display: flex; align-items: center; gap: 4px; counter-increment: st; }
.stage-editor li::before { content: counter(st); width: 22px; color: var(--muted); font-size: 12px; text-align: right; margin-right: 4px; }
.stage-editor input { max-width: 260px; }
.stage-editor input[readonly] { background: var(--surface-2); }
.fixed-note { min-width: 72px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; padding-left: 26px; }
.inline-field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text); font-weight: 400; font-size: 14px; }
.inline-field input { width: 90px; }
.file-list { list-style: none; margin: 0 0 10px; padding: 0; }
.file-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.file-list li a { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-btn { cursor: pointer; position: relative; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.bar { position: relative; display: flex; align-items: flex-end; }
.bar .won { display: block; width: 100%; background: var(--c-green); border-radius: 3px 3px 0 0; }
.legend { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; }
.legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--accent); opacity: .8; }
.legend .key.won { background: var(--c-green); opacity: 1; margin-left: 10px; }
.backfill { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.backfill select { width: auto; }

/* ---------- Inbox channels ---------- */
.ch-whatsapp { --ch: #128c4a; }
.ch-instagram { --ch: #c13584; }
.ch-facebook { --ch: #0866ff; }
.ch-tiktok { --ch: #111; }
.ch-linkedin { --ch: #0a66c2; }
.ch-telegram { --ch: #229ed9; }
.ch-email { --ch: #b45309; }
.ch-website { --ch: #0f766e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ch-tiktok { --ch: #eee; } }
:root[data-theme="dark"] .ch-tiktok { --ch: #eee; }
.badge.ch { color: var(--ch); background: color-mix(in srgb, var(--ch) 12%, transparent); }
.badge.ch::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ch); display: inline-block; margin-right: 5px; vertical-align: middle; }
.channel-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 4px; scrollbar-width: thin; }
.channel-tabs .tab { flex: none; border: 1px solid var(--border, #ddd); background: transparent; color: inherit; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.channel-tabs .tab[data-ch]:not([data-ch=""])::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ch); }
.channel-tabs .tab[aria-pressed="true"] { background: var(--ch, var(--accent, #2563eb)); border-color: transparent; color: #fff; }
.channel-tabs .tab.ch-tiktok[aria-pressed="true"] { color: var(--bg, #fff); }
.channel-tabs .tab[aria-pressed="true"]::before { background: #fff !important; }
.channel-tabs .count { position: static; }
.channel-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.channel-list li { display: flex; flex-direction: column; gap: 4px; padding: 10px; border: 1px solid var(--border, #ddd); border-radius: 10px; }
.channel-list .badge { align-self: flex-start; }
.demo-note { background: color-mix(in srgb, #0f766e 10%, transparent); border: 1px solid color-mix(in srgb, #0f766e 35%, transparent); border-radius: 10px; padding: 8px 12px; margin: 0 0 12px; font-size: 14px; }
.channel-tabs .tab[data-ch=""][aria-pressed="true"] { color: var(--on-accent); }
