/* AAAM CRM — soft workspace.
   Warm canvas, floating rounded panes, a quiet left rail, ink for primary actions.
   Colour belongs to the messengers: each thread takes the look of its channel
   (wallpaper, bubbles, send button). Orange/red mean «waiting for an answer» and nothing else.
   No pure black/white, no side stripes, no gradients, no emoji. */
:root {
  --canvas: #f1efea; --surface: #fdfdfc; --surface-2: #f5f3ef; --surface-3: #ebe8e2;
  --ink: #1d1c1a; --ink-2: #45423d; --muted: #6d6962; --on-ink: #f6f5f2; --on-ink-muted: #b9b5ad;
  --line: #e6e3dd; --line-strong: #cfcbc3;
  --accent: #1d1c1a; --accent-press: #35332f; --on-accent: #f6f5f2;
  --danger: #c0291f; --danger-bg: #fbe7e4; --ok: #1f7a45; --ok-bg: #e1f1e6; --wait: #9a4a06; --wait-bg: #fde9d2; --info: #2563c9; --info-bg: #e3ecfb;
  --tg: #1a76b8; --wa: #0d7c5c; --vk: #0a6ae0; --mx: #6b3fd4; --web: #8a5a00; --tel: #a8324e;
  --r: 10px; --r-lg: 16px; --rail: 76px; --top: 0px; --gap: 8px;
  --shadow: 0 0 0 1px rgba(40, 32, 20, .06), 0 1px 2px rgba(40, 32, 20, .05);
  --shadow-pop: 0 0 0 1px rgba(40, 32, 20, .08), 0 12px 32px rgba(40, 32, 20, .16);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sans: "Onest", "Segoe UI", -apple-system, Roboto, Arial, sans-serif;
  --mono: var(--sans);
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; padding-left: var(--rail); font: 14px/1.45 var(--sans); background: var(--canvas); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 14px; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 8px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 14px; z-index: 100; border-radius: var(--r); }
.skip:focus { left: 8px; top: 8px; }
.err { color: var(--danger); }
.muted { color: var(--muted); }
.center { text-align: center; margin-top: 32px; }
.hint { font-size: 12.5px; margin: 4px 0 0; }
svg.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* controls */
button, .btn { font: 500 14px/1 var(--sans); padding: 0 14px; min-height: 36px; border: 0; border-radius: var(--r); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; transition: background .12s, box-shadow .12s, transform .12s var(--ease); }
button:hover, .btn:hover { background: var(--surface-2); }
button:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; transform: none; }
button.primary { background: var(--accent); color: var(--on-accent); box-shadow: none; font-weight: 600; }
button.primary:hover { background: var(--accent-press); }
button.ghost, .btn.ghost { background: var(--surface-2); box-shadow: none; }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-3); }
button.icon { padding: 0; min-width: 36px; }
button.link { box-shadow: none; background: none; padding: 0; min-height: 0; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; color: inherit; }
input, select, textarea { font: 400 14px/1.4 var(--sans); color: var(--ink); padding: 8px 12px; border: 0; border-radius: var(--r); width: 100%; background: var(--surface-2); box-shadow: inset 0 0 0 1px transparent; transition: box-shadow .12s, background .12s; }
input:hover, select:hover, textarea:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
input:focus, select:focus, textarea:focus { outline: none; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--ink); }
input::placeholder, textarea::placeholder { color: #7a766e; }
textarea { resize: vertical; }
select { appearance: none; padding-right: 30px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236d6962' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
label { color: var(--muted); font-size: 12.5px; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #d4480c; color: #fff; font: 600 11px/18px var(--sans); text-align: center; }

/* rail */
header.top { position: fixed; left: 0; top: 0; bottom: 0; width: var(--rail); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 14px 0; color: var(--ink); }
.brand { display: inline-flex; font-size: 0; text-decoration: none; }
.brand-mark { display: inline-flex; width: 36px; height: 36px; border-radius: 11px; background: var(--ink); color: var(--on-ink); align-items: center; justify-content: center; font: 700 16px/1 var(--sans); }
header nav { display: flex; flex-direction: column; gap: 4px; }
header nav a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 62px; padding: 9px 0 7px; border-radius: 12px; color: var(--muted); text-decoration: none; font: 500 11px/1.2 var(--sans); transition: background .12s, color .12s; }
header nav a svg.ico { width: 20px; height: 20px; }
header nav a:hover { color: var(--ink); background: var(--surface-3); }
header nav a[aria-current] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
header nav .badge { position: absolute; top: 3px; right: 6px; }
.top-user { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 11px; }
.top-user .who { display: flex; }
.who-ava { display: inline-flex; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); align-items: center; justify-content: center; font: 600 13px/1 var(--sans); }
.who-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.logout { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 62px; padding: 8px 0 6px; border-radius: 12px; color: var(--muted); text-decoration: none; font: 500 11px/1.2 var(--sans); }
.logout svg.ico { width: 20px; height: 20px; }
.logout:hover { color: var(--ink); background: var(--surface-3); }
main { padding: 22px 22px 22px 6px; }

/* toasts, dialog */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--top, 0px) + 14px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: min(420px, calc(100vw - 28px)); }
.toast { background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow-pop); animation: toast-in .22s var(--ease); }
.toast-err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.97); } }
dialog { border: 0; border-radius: var(--r-lg); padding: 22px; width: min(440px, calc(100vw - 28px)); color: var(--ink); background: var(--surface); box-shadow: var(--shadow-pop); }
dialog[open] { animation: pop-in .2s var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
dialog::backdrop { background: rgba(29, 28, 26, .4); }
dialog h2 { font-size: 17px; }
dialog label { display: block; margin-bottom: 8px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* login */
body.login-body { padding: 22px; display: grid; place-items: center; min-height: 100vh; }
body.login-body main { padding: 0; width: min(400px, 100%); }
form.login { display: flex; flex-direction: column; gap: 6px; padding: 32px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); }
form.login h1 { display: flex; align-items: center; gap: 12px; font-size: 24px; margin: 0; }
.login-sub { font-size: 14px; margin: 2px 0 18px; }
form.login label { margin-top: 8px; }
form.login .pw { display: flex; gap: 8px; }
form.login input, form.login button { min-height: 42px; }
form.login button.primary { margin-top: 22px; }
.alert { background: var(--danger-bg); color: var(--danger); padding: 9px 12px; border-radius: var(--r); margin: 0 0 8px; }

/* channel and status marks: a dot + text */
.chan, .st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chan::before, .st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: none; }
.chan-telegram::before { background: var(--tg); } .chan-whatsapp::before { background: var(--wa); } .chan-vk::before { background: var(--vk); }
.chan-max::before { background: var(--mx); } .chan-site::before { background: var(--web); } .chan-call::before { background: var(--tel); }
.st { color: var(--ink-2); }
.st-new::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-2); } .st-work::before { background: var(--info); }
.st-noanswer::before, .st-callback::before { background: #c08a00; }
.st-booked::before, .st-came::before { background: var(--ok); }
.st-refused::before, .st-notlead::before, .st-lost::before { background: var(--line-strong); }
/* the avatar slot names the channel in the channel's own colour */
.ava { display: inline-flex; flex: none; width: 38px; height: 38px; border-radius: 12px; align-items: center; justify-content: center; font: 700 10.5px/1 var(--sans); letter-spacing: .03em; color: #fff; background: var(--muted); }
.ava.chan-telegram { background: var(--tg); } .ava.chan-whatsapp { background: var(--wa); } .ava.chan-vk { background: var(--vk); }
.ava.chan-max { background: var(--mx); } .ava.chan-site { background: var(--web); } .ava.chan-call { background: var(--tel); }
.ava::before { display: none; }

/* inbox: three floating panes */
body.page-inbox main { padding: var(--gap) var(--gap) var(--gap) 0; height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); }
.inbox { display: grid; grid-template-columns: 372px minmax(0, 1fr) 332px; gap: var(--gap); height: 100%; }
.inbox:not(.has-conv) { grid-template-columns: 372px minmax(0, 1fr); }
.inbox:not(.has-conv) > .card { display: none; }
.inbox > aside, .inbox > section { min-height: 0; overflow: hidden; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.convlist { display: flex; flex-direction: column; }
.list-head { display: flex; flex-direction: column; gap: 10px; padding: 12px 12px 8px; }
.list-top { display: flex; gap: 4px; align-items: center; }
.search { position: relative; flex: 1; min-width: 0; }
.search input { height: 38px; padding-left: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236d6962' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5L14 14'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 11px center; }
.search .clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 18px; text-decoration: none; }
.search .clear:hover { color: var(--ink); background: var(--surface-3); }
.search input::-webkit-search-cancel-button { display: none; }
.filters { display: flex; }
.tabs { display: flex; gap: 2px; flex: 1; padding: 3px; border-radius: var(--r); background: var(--surface-2); }
.tabs a { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 8px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500; font-size: 13px; transition: background .12s, color .12s; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.tabs .n { font-size: 12px; color: var(--muted); }
.tabs .n.hot { background: #d4480c; color: #fff; padding: 0 5px; border-radius: 8px; font-weight: 600; font-size: 11px; line-height: 16px; }
.list-top select { width: auto; flex: none; padding: 6px 26px 6px 8px; background-color: transparent; color: var(--ink-2); font-size: 13px; background-position: right 7px center; }
.list-top select:hover { background-color: var(--surface-2); box-shadow: none; }
.list-top button.icon { background: transparent; min-height: 32px; min-width: 32px; color: var(--muted); }
.list-top button.icon:hover { background: var(--surface-2); }
#sound-toggle .ico-off, #sound-toggle[aria-pressed=true] .ico-on { display: block; }
#sound-toggle .ico-on, #sound-toggle[aria-pressed=true] .ico-off { display: none; }
#sound-toggle[aria-pressed=true] { color: var(--ink); }
#convs { list-style: none; margin: 0; padding: 0 6px 8px; overflow: auto; flex: 1; }
#convs li a { display: grid; grid-template-columns: 38px minmax(0, 1fr); column-gap: 12px; row-gap: 2px; padding: 9px 8px; margin-bottom: 1px; border-radius: 12px; color: var(--ink); text-decoration: none; transition: background .12s; }
#convs li a:hover { background: var(--surface-2); }
#convs li a:focus-visible { outline-offset: -2px; }
#convs .ava { grid-row: 1 / span 2; align-self: center; }
#convs .row1, #convs .row2 { display: flex; align-items: center; gap: 8px; min-width: 0; }
#convs .title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
#convs li.unanswered .title { font-weight: 600; }
#convs li.unanswered .title::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e8590c; margin-right: 7px; vertical-align: 1px; }
#convs .time { font-size: 12px; color: var(--muted); flex: none; }
#convs .last { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#convs li.unanswered .last { color: var(--ink-2); }
#convs .wait { flex: none; font: 600 11.5px/1 var(--sans); padding: 4px 7px; border-radius: 7px; background: var(--wait-bg); color: var(--wait); }
#convs li.overdue .wait { color: #fff; background: var(--danger); }
#convs .row1 .st { font-size: 12px; flex: none; }
#convs li.active a { background: var(--surface-3); }
#convs li.empty { padding: 32px 16px; color: var(--muted); }

/* thread: takes the look of its messenger */
.thread { display: flex; flex-direction: column;
  --th-bg: var(--surface-2); --th-in: var(--surface); --th-out: var(--surface-3); --th-accent: var(--ink); --th-meta: var(--muted); --th-out-meta: var(--muted); }
.thread.th-telegram { --th-bg: #d5e4ef; --th-in: #ffffff; --th-out: #e3fbd0; --th-accent: var(--tg); --th-out-meta: #3f8a3d; }
.thread.th-whatsapp { --th-bg: #efe9df; --th-in: #ffffff; --th-out: #d9fdd3; --th-accent: var(--wa); --th-out-meta: #55705b; }
.thread.th-vk { --th-bg: #e9edf3; --th-in: #ffffff; --th-out: #cfe4ff; --th-accent: var(--vk); --th-out-meta: #4a6a94; }
.thread.th-max { --th-bg: #e9e4f6; --th-in: #ffffff; --th-out: #dfd4fb; --th-accent: var(--mx); --th-out-meta: #645394; }
.placeholder { margin: auto; padding: 22px; max-width: 320px; text-align: center; }
.placeholder b { font-size: 16px; }
.thread-head { padding: 0 14px; min-height: 62px; display: flex; gap: 12px; align-items: center; background: var(--surface); box-shadow: 0 1px 0 var(--line); position: relative; z-index: 1; }
.thread-head .who { min-width: 0; flex: 1; }
.thread-head .name { font-size: 16px; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.thread-head .sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 12px; align-items: center; }
.thread-head .sub .chan { color: var(--th-accent); font-weight: 500; }
.thread-head .sub .chan::before { display: none; }
.thread-head .sub a { font-size: 12.5px; color: var(--ink-2); text-decoration: none; }
.thread-head .sub a:hover { text-decoration: underline; }
.head-actions { display: flex; gap: 8px; flex: none; }
.back, .card-open, .card-close { display: none; }
.msgs { flex: 1; overflow: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 4px; background: var(--th-bg); }
.day { align-self: center; margin: 12px 0 8px; padding: 3px 10px; border-radius: 10px; font-size: 12px; font-weight: 500; color: var(--ink-2); background: rgba(255, 255, 255, .6); }
.msg { display: flex; } .msg.out { justify-content: flex-end; }
.bubble { max-width: min(68%, 560px); padding: 7px 12px 5px; border-radius: 16px 16px 16px 5px; background: var(--th-in); box-shadow: 0 1px 1px rgba(40, 32, 20, .1); word-break: break-word; overflow-wrap: anywhere; }
.bubble .text { white-space: pre-wrap; }
.msg.out .bubble { background: var(--th-out); border-radius: 16px 16px 5px 16px; }
.bubble .meta { font-size: 11.5px; line-height: 1.5; color: var(--th-meta); margin-top: 1px; text-align: right; }
.msg.out .bubble .meta { color: var(--th-out-meta); }
.msg.failed .bubble { background: var(--danger-bg); box-shadow: inset 0 0 0 1px var(--danger); color: var(--ink); }
.msg.failed .bubble .meta { color: var(--ink-2); text-align: left; }
.msg.failed .retry { display: flex; margin-top: 6px; min-height: 30px; padding: 0 12px; box-shadow: inset 0 0 0 1px var(--danger); border-radius: 8px; color: var(--danger); background: var(--surface); font-weight: 600; text-decoration: none; }
.msg.failed .retry:hover { background: var(--danger-bg); }
.msg.queued .bubble { opacity: .65; }
.att-img { max-width: 260px; max-height: 260px; border-radius: 10px; display: block; margin-top: 4px; }
.att { display: inline-block; margin-top: 4px; font-size: 13px; font-weight: 500; }
.att::before { content: "Файл: "; font-weight: 400; opacity: .65; }
.reply { padding: 10px 14px 8px; position: relative; background: var(--surface); box-shadow: 0 -1px 0 var(--line); }
.reply-row { display: flex; gap: 6px; align-items: flex-end; padding: 5px; border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px transparent; transition: box-shadow .12s, background .12s; }
.reply-row:focus-within { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--th-accent); }
.reply textarea { flex: 1; resize: none; min-height: 36px; max-height: 200px; background: transparent; box-shadow: none; padding: 8px 6px; }
.reply textarea:hover, .reply textarea:focus { background: transparent; box-shadow: none; }
.reply button { min-height: 36px; }
.reply button.icon { background: transparent; color: var(--muted); }
.reply button.icon:hover { background: var(--surface-3); color: var(--ink); }
.reply button.primary { background: var(--th-accent); color: #fff; border-radius: 10px; }
.reply button.primary:hover { background: var(--th-accent); filter: brightness(.92); }
.reply-foot { display: flex; justify-content: space-between; gap: 14px; margin-top: 5px; min-height: 17px; font-size: 12.5px; padding: 0 6px; }
.reply-foot .hint { font-size: 12px; margin: 0; }
.quick { position: absolute; left: 14px; right: 14px; bottom: calc(100% - 4px); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-pop); max-height: 264px; overflow: auto; z-index: 5; padding: 6px; animation: pop-in .16s var(--ease); }
.quick ul { list-style: none; margin: 0; padding: 0; }
.quick li { padding: 8px 10px; border-radius: 9px; cursor: pointer; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; }
.quick li b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick li span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick li[aria-selected=true], .quick li[data-i]:hover { background: var(--surface-3); }
.quick li.empty { cursor: default; color: var(--muted); display: block; }
.noreply { padding: 14px 18px; background: var(--surface); box-shadow: 0 -1px 0 var(--line); }

/* contact card */
.card { padding: 4px 16px 22px; overflow: auto !important; position: relative; }
.card-empty { margin-top: 22px; }
.blk { padding: 16px 0; border-bottom: 1px solid var(--line); }
.blk:last-child { border-bottom: 0; }
.blk h2 { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.field { margin-bottom: 10px; }
.field label { display: block; margin-bottom: 4px; }
.field-row { display: flex; gap: 6px; }
.field-row button { flex: none; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sub-h { font-size: 12.5px; color: var(--muted); margin: 14px 0 4px; }
.ids, .links, .past ul { list-style: none; padding: 0; margin: 10px 0 0; font-size: 13px; }
.ids li, .links li, .past li { padding: 3px 0; overflow-wrap: anywhere; }
.ids .muted { font-size: 12px; }
.links a { text-decoration: none; display: inline-flex; gap: 12px; }
.links a:hover .chan { color: var(--ink); text-decoration: underline; }
.lead-meta { font-size: 12.5px; color: var(--muted); }
.statuses { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 12px; }
.st-btn { justify-content: flex-start; min-height: 34px; padding: 0 10px; font-size: 13px; font-weight: 400; background: var(--surface-2); box-shadow: none; color: var(--ink-2); }
.st-btn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.st-btn:hover { background: var(--surface-3); }
.st-btn[aria-pressed=true] { background: var(--ink); color: var(--on-ink); font-weight: 500; }
.past summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
.card textarea + button { margin-top: 8px; }

/* leads board */
body.page-leads main { padding: 18px 0 0 6px; height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); display: flex; flex-direction: column; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; margin: 0 22px 14px 8px; }
.page-head h1 { margin: 0; }
.page-head .count { font-size: 15px; font-weight: 400; margin-left: 6px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input, .toolbar select { background-color: var(--surface); box-shadow: var(--shadow); }
.toolbar input:focus, .toolbar select:focus { box-shadow: inset 0 0 0 1.5px var(--ink); }
.toolbar input[type=search] { width: 240px; }
.toolbar select { width: auto; }
.toolbar .reset { font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.board { display: flex; gap: var(--gap); overflow-x: auto; scroll-snap-type: x proximity; align-items: stretch; padding: 2px 8px 8px 2px; flex: 1; min-height: 0; }
.col { scroll-snap-align: start; flex: 0 0 280px; display: flex; flex-direction: column; min-height: 0; border-radius: var(--r-lg); background: var(--surface-3); transition: background .12s, box-shadow .12s; }
.col.over { background: var(--surface); box-shadow: inset 0 0 0 2px var(--ink); }
.col.closed { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.col h2 { display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 12px 14px 6px; font-size: 13px; }
.col h2 .st { font-size: 13px; font-weight: 600; color: var(--ink); }
.col h2 .n { font-size: 12px; font-weight: 500; color: var(--muted); }
.cards { list-style: none; margin: 0; padding: 6px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; min-height: 80px; flex: 1; }
.lead { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 11px 12px; cursor: grab; display: flex; flex-direction: column; gap: 6px; transition: box-shadow .15s, transform .15s var(--ease); }
.lead:hover { box-shadow: 0 0 0 1px rgba(40, 32, 20, .1), 0 4px 12px rgba(40, 32, 20, .08); }
.lead.stale { box-shadow: inset 0 0 0 1.5px var(--danger); }
.lead.dragging { opacity: .35; }
.lead.busy { opacity: .6; pointer-events: none; }
.lead-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.lead-top .title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
a.title:hover { text-decoration: underline; }
.lead-top .muted { font-size: 12px; }
.lead-tags { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.tag { font-size: 12px; color: var(--muted); }
.lead-phone a { font-size: 12.5px; color: var(--ink-2); text-decoration: none; }
.lead-phone a:hover { text-decoration: underline; }
.lead-reason { font-size: 13px; }
.lead-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; min-height: 26px; }
.lead-foot select { width: auto; padding: 3px 24px 3px 8px; font-size: 12px; border-radius: 8px; background-position: right 6px center; }
@media (hover: hover) { .lead-foot select { opacity: 0; } .lead:hover .lead-foot select, .lead:focus-within .lead-foot select { opacity: 1; } }
.cards .empty { color: var(--muted); padding: 14px 8px; font-size: 13px; }

/* settings */
.settings { max-width: 940px; margin-left: 8px; }
.panel { display: grid; grid-template-columns: 190px minmax(0, 1fr); column-gap: 28px; padding: 22px; margin-bottom: var(--gap); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.panel > h2 { grid-column: 1; grid-row: 1 / span 12; font-size: 15px; }
.panel > :not(h2) { grid-column: 2; }
.kv-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv-row label { font-size: 14px; color: var(--ink); }
.kv-row .num { display: grid; grid-template-columns: 84px 30px; align-items: center; gap: 8px; color: var(--muted); flex: none; font-size: 13px; }
.kv-row input { width: 84px; text-align: right; }
.kv-form button { margin-top: 14px; }
.reply-item { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 14px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.reply-item:first-child { padding-top: 0; }
.reply-item label { padding-top: 8px; }
.reply-item .r-del { grid-column: 2; justify-self: start; min-height: 28px; font-size: 13px; }
.replies { margin: 8px 0 14px; }
.tbl { border-collapse: collapse; width: 100%; }
.tbl th, .tbl td { text-align: left; padding: 9px 14px 9px 0; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.connectors { display: flex; flex-wrap: wrap; gap: var(--gap); }
.conn-card { padding: 14px; min-width: 240px; flex: 1; border-radius: 12px; background: var(--surface-2); }
.conn-card h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.conn-card p { margin: 4px 0; font-size: 13px; }
.conn-badge { display: inline-flex; align-items: center; gap: 6px; font: 500 12.5px var(--sans); color: var(--danger); }
.conn-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.conn-badge.ok { color: var(--ok); }
.conn-card img#wa-qr { display: block; width: 240px; height: 240px; margin: 8px 0; border-radius: 8px; image-rendering: pixelated; }

/* medium: the card becomes a slide-over */
@media (max-width: 1200px) {
  .inbox { grid-template-columns: 348px minmax(0, 1fr); }
  .inbox > .card { position: fixed; top: calc(var(--top) + var(--gap)); right: var(--gap); bottom: var(--gap); width: min(368px, calc(100vw - 2 * var(--gap))); z-index: 30; box-shadow: var(--shadow-pop); transform: translateX(110%); visibility: hidden; transition: transform .24s var(--ease), visibility .24s; }
  .inbox > .card.open { transform: none; visibility: visible; }
  .card-open, .card-close { display: inline-flex; }
  .card-close { position: sticky; top: 8px; float: right; z-index: 2; font-size: 18px; padding: 0; min-width: 36px; }
}
/* phone: top bar, one pane at a time, edge to edge */
@media (max-width: 900px) {
  :root { --top: 52px; --rail: 0px; --gap: 0px; }
  header.top { position: sticky; bottom: auto; width: auto; height: var(--top); flex-direction: row; gap: 8px; padding: 0 10px; background: var(--canvas); }
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; font-size: 14px; }
  header nav { flex-direction: row; gap: 2px; }
  header nav a { flex-direction: row; width: auto; gap: 6px; padding: 0 10px; min-height: 36px; font-size: 13.5px; }
  header nav a svg.ico { display: none; }
  header nav .badge { position: static; }
  .top-user { margin: 0 0 0 auto; flex-direction: row; }
  .top-user .who { display: none; }
  .logout { flex-direction: row; width: auto; padding: 0 10px; min-height: 36px; font-size: 13.5px; }
  .logout svg.ico { display: none; }
  main { padding: 14px; }
  body.page-inbox main { padding: 0; }
  .inbox, .inbox:not(.has-conv) { grid-template-columns: minmax(0, 1fr); }
  .inbox > aside, .inbox > section { border-radius: 0; box-shadow: none; }
  .inbox > .card { top: var(--top); right: 0; bottom: 0; width: 100vw; }
  .inbox.has-conv > .convlist { display: none; }
  .inbox:not(.has-conv) > .thread { display: none; }
  .back { display: inline-flex; padding: 0; min-width: 40px; }
  .thread-head { padding: 0 8px; gap: 8px; }
  .msgs { padding: 14px 10px; }
  .bubble { max-width: 86%; }
  .reply { padding: 8px; }
  .reply-foot .hint { display: none; }
  button, .btn { min-height: 40px; }
  button.link { min-height: 36px; padding: 0 6px; }
  .msg.failed .retry { min-height: 36px; }
  .st-btn { min-height: 40px; }
  .list-top button.icon { min-height: 36px; min-width: 36px; }
  .col { flex-basis: 84vw; }
  .board { gap: 8px; padding: 2px 14px 14px; }
  .page-head { margin: 0 14px 14px; }
  body.page-leads main { padding: 14px 0 0; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; padding: 2px 2px 4px; width: 100%; }
  .toolbar > * { flex: none; }
  .toolbar input[type=search] { width: 200px; }
  .toolbar button { display: none; }
  .settings { margin-left: 0; }
  .panel { grid-template-columns: minmax(0, 1fr); padding: 16px; margin-bottom: 8px; }
  .panel > h2, .panel > :not(h2) { grid-column: 1; grid-row: auto; }
  .reply-item { grid-template-columns: minmax(0, 1fr); }
  .reply-item .r-del { grid-column: 1; }
  .reply-item label { padding-top: 0; }
  .kv-row { flex-wrap: wrap; }
  .quick li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  body.login-body { padding: 14px; }
  form.login { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
