:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel2: #f0f2f5; --line: #e3e6ea; --text: #16191d; --muted: #6a7480;
  --brand: #16a34a; --brand-ink: #ffffff; --accent: #2563eb; --danger: #dc2626; --warn: #d97706;
  --bubble-in: #ffffff; --bubble-out: #d9fdd3; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1114; --panel: #171b20; --panel2: #1f242a; --line: #2a3038; --text: #e8ebee; --muted: #8b96a3;
    --bubble-in: #232a31; --bubble-out: #14492a; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1114; --panel: #171b20; --panel2: #1f242a; --line: #2a3038; --text: #e8ebee; --muted: #8b96a3;
  --bubble-in: #232a31; --bubble-out: #14492a; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.shell { display: grid; grid-template-columns: 208px 1fr; height: 100%; }
.nav { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; padding: 4px 8px 14px; }
.brand i { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); display: grid; place-items: center; color: #fff; font-style: normal; }
.nav button.item { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 8px 10px; border-radius: 8px; text-align: left; color: var(--muted); }
.nav button.item:hover { background: var(--panel2); color: var(--text); }
.nav button.item.on { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--text); font-weight: 600; }
.nav .badge { margin-left: auto; background: var(--brand); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; line-height: 17px; }
.nav .spacer { flex: 1; }
.nav .status { font-size: 12px; color: var(--muted); padding: 8px; display: flex; gap: 7px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--brand); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--danger); }

main { min-width: 0; height: 100%; overflow: hidden; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar h1 { font-size: 17px; margin: 0; }
.topbar .grow { flex: 1; }
.content { flex: 1; min-height: 0; overflow: auto; padding: 18px 20px; }
.content.flush { padding: 0; overflow: hidden; }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 8px; }
.btn:hover { background: var(--panel2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
label.f { display: block; margin-bottom: 11px; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat .n { font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.tag { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; padding: 0 8px; font-size: 11.5px; margin: 0 3px 3px 0; }
.tag.hot { background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: transparent; color: var(--danger); }
.pill { border-radius: 20px; padding: 1px 9px; font-size: 11.5px; background: var(--panel2); }
.pill.ok { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.pill.bad { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr.click:hover { background: var(--panel2); cursor: pointer; }

/* inbox */
.inbox { display: grid; grid-template-columns: 330px 1fr 320px; height: 100%; }
.inbox > section { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.inbox > section:last-child { border-right: 0; }
.list { overflow: auto; flex: 1; }
.chat-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.chat-item:hover { background: var(--panel2); } .chat-item.on { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.chat-item .meta { flex: 1; min-width: 0; }
.chat-item .name { font-weight: 600; display: flex; gap: 6px; }
.chat-item .name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .prev { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.chat-item .time { margin-left: auto; font-size: 11.5px; color: var(--muted); flex: none; }
.unread { background: var(--brand); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; line-height: 18px; }
.thread { flex: 1; overflow: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 6px; background: var(--panel2); }
.msg { max-width: 72%; padding: 7px 11px; border-radius: 10px; background: var(--bubble-in); box-shadow: 0 1px 1px rgba(0,0,0,.08); white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--bubble-out); }
.msg .by { font-size: 11px; color: var(--muted); margin-top: 2px; text-align: right; }
.msg .by.agent { color: var(--accent); }
.msg img { max-width: 260px; border-radius: 6px; display: block; }
.composer { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel); align-items: flex-end; }
.composer textarea { min-height: 38px; max-height: 140px; }
.side { overflow: auto; padding: 14px; }
.side h3 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.side h3:first-child { margin-top: 0; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.ai-banner { background: color-mix(in srgb, var(--warn) 16%, transparent); padding: 6px 14px; font-size: 12.5px; display: flex; gap: 8px; align-items: center; }

/* board */
.board { display: flex; gap: 12px; padding: 16px 20px; height: 100%; overflow-x: auto; align-items: flex-start; }
.col { width: 268px; flex: none; background: var(--panel2); border-radius: 12px; display: flex; flex-direction: column; max-height: 100%; border: 1px solid var(--line); }
.col.over { outline: 2px dashed var(--accent); }
.col header { padding: 10px 12px 8px; display: flex; align-items: center; gap: 8px; }
.col header b { flex: 1; }
.col .sum { font-size: 12px; color: var(--muted); padding: 0 12px 6px; }
.col .cards { padding: 0 8px 8px; overflow: auto; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.deal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; cursor: grab; box-shadow: var(--shadow); }
.deal.dragging { opacity: .4; }
.deal .t { font-weight: 600; } .deal .v { color: var(--brand); font-weight: 600; }
.deal .score { height: 3px; border-radius: 2px; background: var(--line); margin-top: 7px; overflow: hidden; }
.deal .score i { display: block; height: 100%; background: var(--brand); }
.stripe { height: 3px; border-radius: 12px 12px 0 0; }

/* misc */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 950; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; padding: 20px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; z-index: 1000; }
.login { height: 100%; display: grid; place-items: center; }
.login .card { width: 340px; }
.timeline { font-size: 12.5px; } .timeline div { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 4px 8px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.toggle { position: relative; width: 38px; height: 22px; flex: none; }
.toggle input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; z-index: 1; }
.toggle i { position: absolute; inset: 0; background: var(--line); border-radius: 12px; transition: .15s; }
.toggle i::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .15s; }
.toggle input:checked + i { background: var(--brand); } .toggle input:checked + i::after { left: 19px; }
.kill { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); padding: 7px 20px; font-weight: 600; display: flex; gap: 10px; align-items: center; }
pre.code { background: var(--panel2); padding: 10px; border-radius: 8px; overflow: auto; font-size: 12px; margin: 6px 0; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }

@media (max-width: 1100px) { .inbox { grid-template-columns: 290px 1fr; } .inbox .side { display: none; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .nav { flex-direction: row; order: 2; padding: 4px; border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; }
  .nav .brand, .nav .spacer, .nav .status { display: none; }
  .nav button.item { flex-direction: column; gap: 2px; font-size: 11px; padding: 5px 9px; flex: none; }
  .inbox { grid-template-columns: 1fr; } .inbox.chat-open > section:first-child { display: none; }
  .inbox:not(.chat-open) > section:nth-child(2) { display: none; }
  .content { padding: 12px; }
}

.grid > * { min-width: 0; }
.content { overflow-x: hidden; }
.content.flush { overflow: hidden; }

/* message actions, quotes, reactions */
.msg { position: relative; }
.msg .acts { display: none; position: absolute; top: -14px; right: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 1px 2px; z-index: 2; }
.msg:hover .acts { display: flex; }
.msg .act { border: 0; background: none; padding: 2px 6px; border-radius: 6px; font-size: 14px; }
.msg .act:hover { background: var(--panel2); }
.msg .quote { border-left: 3px solid var(--brand); background: rgba(127,127,127,.12); border-radius: 4px; padding: 3px 8px; margin: 0 0 4px; font-size: 12.5px; color: var(--muted); }
.msg .reacts { margin-top: 3px; } .msg .react { display: inline-block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0 6px; font-size: 12px; margin-right: 3px; }
.msg.deleted { opacity: .65; }
.replybar { display: flex; gap: 8px; align-items: center; padding: 6px 14px; background: var(--panel2); border-top: 1px solid var(--line); border-left: 3px solid var(--brand); }
details > summary { cursor: pointer; }
.nav { overflow-y: auto; }
.nav button.item { padding: 6px 10px; }
.nav .status .btn { padding: 1px 7px; }

.nav { overflow: hidden; }
.navlist { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.inbox { flex: 1; min-height: 0; }
@media (max-width: 760px) { .navlist { flex-direction: row; overflow-x: auto; overflow-y: hidden; } .nav { overflow-x: auto; } }
/* below 1100px the contact side pane is hidden: hide the whole third column, not just its inner panel */
@media (max-width: 1100px) { .inbox > section:nth-child(3) { display: none; } }

/* ===== native-WhatsApp-style chat screen ===== */
.avatar { object-fit: cover; flex: none; }
.wa { display: flex; flex-direction: column; flex: 1; min-height: 0; height: 100%; }
.wa-top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; flex-wrap: wrap; }
.wa-label { font-size: 11px; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.wa-profile { width: auto; min-width: 150px; padding: 5px 10px; border-radius: 20px; font-weight: 600; }
.wa-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 380px minmax(0, 1fr); }
.wa-body.info-open { grid-template-columns: 380px minmax(0, 1fr) 330px; }
.wa-left, .wa-mid, .wa-right { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.wa-right { border-right: 0; display: none; background: var(--panel); overflow: auto; }
.wa-body.info-open .wa-right { display: flex; }
.wa-left { background: var(--panel); }
.wa-left-head { display: flex; align-items: center; gap: 4px; padding: 12px 14px 6px; font-size: 18px; }
.wa-search-wrap { padding: 4px 12px 8px; }
.wa-search { border-radius: 20px; background: var(--panel2); border-color: transparent; padding: 8px 14px; }
.wa-tabs { display: flex; gap: 6px; padding: 0 12px 8px; flex-wrap: wrap; }
.wa-tab { border: 0; background: var(--panel2); color: var(--muted); padding: 5px 12px; border-radius: 18px; font-weight: 600; font-size: 13px; }
.wa-tab:hover { color: var(--text); }
.wa-tab.on { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand); }
.wa-tool { border: 0; background: none; color: var(--muted); font-size: 18px; width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; }
.wa-tool:hover { background: var(--panel2); color: var(--text); }
.wa-chats { flex: 1; overflow: auto; }
.wa-row { display: flex; gap: 12px; padding: 10px 14px; cursor: pointer; align-items: center; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.wa-row:hover { background: var(--panel2); }
.wa-row.on { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.wa-row .meta { flex: 1; min-width: 0; }
.wa-row .top, .wa-row .bot { display: flex; align-items: center; gap: 6px; }
.wa-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-row .time { margin-left: auto; font-size: 12px; color: var(--muted); flex: none; }
.wa-row .time.hot { color: var(--brand); font-weight: 600; }
.wa-row .prev { color: var(--muted); font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 9.5px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 8px; flex: none; }
.chip.lead { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand); }
.chip.cust { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

.wa-mid { background: var(--panel2); position: relative; }
.wa-head { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.wa-head .who { min-width: 0; line-height: 1.25; }
.wa-head .back { display: none; }
.seg { display: inline-flex; background: var(--panel2); border-radius: 20px; padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 12px; border-radius: 18px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg button:disabled { cursor: default; }
.seg button.on.contact { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.seg button.on.lead { background: var(--brand); color: #fff; }
.seg button.on.customer { background: var(--accent); color: #fff; }
.wa-hint { display: flex; gap: 10px; align-items: center; padding: 6px 14px; background: color-mix(in srgb, var(--accent) 12%, transparent); font-size: 13px; }
.wa-thread { flex: 1; overflow: auto; padding: 14px 6% 10px; display: flex; flex-direction: column; gap: 2px;
  background-image: radial-gradient(color-mix(in srgb, var(--muted) 14%, transparent) 1px, transparent 1px); background-size: 22px 22px; }
.wa-empty { margin: auto; text-align: center; color: var(--muted); display: grid; gap: 6px; }
.wa-empty .big { font-size: 54px; }
.wa-day { align-self: center; margin: 10px 0 6px; }
.wa-day span { background: var(--panel); color: var(--muted); font-size: 12px; padding: 3px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.wa-msg { position: relative; max-width: min(68%, 560px); padding: 6px 9px 4px; border-radius: 9px; box-shadow: 0 1px 1px rgba(0,0,0,.1); word-wrap: break-word; white-space: pre-wrap; line-height: 1.38; }
.wa-msg.in { align-self: flex-start; background: var(--bubble-in); }
.wa-msg.out { align-self: flex-end; background: var(--bubble-out); }
.wa-msg.start { margin-top: 6px; }
.wa-msg.in.start { border-top-left-radius: 0; } .wa-msg.out.start { border-top-right-radius: 0; }
.wa-msg.in.start::before, .wa-msg.out.start::before { content: ""; position: absolute; top: 0; border: 7px solid transparent; }
.wa-msg.in.start::before { left: -7px; border-top-color: var(--bubble-in); border-right-color: var(--bubble-in); }
.wa-msg.out.start::before { right: -7px; border-top-color: var(--bubble-out); border-left-color: var(--bubble-out); }
.wa-msg .wa-sender { font-size: 12.5px; font-weight: 600; margin-bottom: 1px; }
.wa-msg .txt { margin-right: 4px; }
.wa-msg .meta { float: right; margin: 6px 0 0 10px; font-size: 11px; color: var(--muted); white-space: nowrap; line-height: 1; }
.wa-msg .meta .by.agent { color: var(--accent); }
.wa-msg .tick { margin-left: 3px; letter-spacing: -2px; } .wa-msg .tick.read { color: #34b7f1; }
.wa-msg img, .wa-msg video { max-width: 280px; max-height: 320px; border-radius: 6px; display: block; margin-bottom: 3px; }
.wa-msg audio { max-width: 250px; }
.wa-msg .quote { border-left: 3px solid var(--brand); background: rgba(127,127,127,.14); border-radius: 4px; padding: 3px 8px; margin: 0 0 4px; font-size: 12.5px; color: var(--muted); }
.wa-msg .reacts { margin-top: 2px; clear: both; } .wa-msg .react { display: inline-block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0 6px; font-size: 12px; margin-right: 3px; }
.wa-msg .acts { display: none; position: absolute; top: -14px; right: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 1px 2px; z-index: 2; }
.wa-msg:hover .acts { display: flex; }
.wa-msg .act { border: 0; background: none; padding: 2px 6px; border-radius: 6px; font-size: 14px; } .wa-msg .act:hover { background: var(--panel2); }
.wa-msg.deleted { opacity: .65; }
.wa-composer { display: flex; align-items: flex-end; gap: 4px; padding: 8px 12px; background: var(--panel); border-top: 1px solid var(--line); position: relative; flex: none; }
.wa-input { flex: 1; border-radius: 22px; padding: 10px 16px; min-height: 42px; max-height: 130px; resize: none; background: var(--panel2); border-color: transparent; }
.wa-send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 17px; flex: none; }
.wa-send:hover { filter: brightness(.94); }
.wa-pop { position: absolute; bottom: 58px; left: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 20; max-width: 340px; }
.wa-emojis { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; }
.wa-emojis button { border: 0; background: none; font-size: 22px; padding: 4px; border-radius: 6px; } .wa-emojis button:hover { background: var(--panel2); }
.wa-menu { display: grid; padding: 6px; } .wa-menu button { border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 8px; } .wa-menu button:hover { background: var(--panel2); }
.wa-info-inner { padding: 14px; }

.profile-card .stats-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; text-align: center; }
.profile-card .stats-mini div { background: var(--panel2); border-radius: 10px; padding: 6px 2px; display: grid; }
.profile-card .stats-mini b { font-size: 18px; } .profile-card .stats-mini span { font-size: 11px; color: var(--muted); }

@media (max-width: 1100px) { .wa-body.info-open { grid-template-columns: 330px minmax(0, 1fr); } .wa-body.info-open .wa-right { display: none; } .wa-body { grid-template-columns: 330px minmax(0, 1fr); } }
@media (max-width: 760px) {
  .wa-body, .wa-body.info-open { grid-template-columns: 1fr; }
  .wa-body .wa-mid { display: none; } .wa-body.chat-open .wa-mid { display: flex; } .wa-body.chat-open .wa-left { display: none; }
  .wa-head .back { display: inline-grid; } .wa-thread { padding: 10px 8px; } .wa-msg { max-width: 86%; }
}

/* ===== calls, lead details, setup, navigation, phone layout ===== */
.callbtns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.btn.call { font-weight: 600; }
.btn.call.phone { background: color-mix(in srgb, var(--brand) 14%, var(--panel)); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.btn.call.wa { background: color-mix(in srgb, #25d366 14%, var(--panel)); border-color: color-mix(in srgb, #25d366 40%, var(--line)); }
.callbtns.compact .btn { padding: 5px 9px; } .callbtns.compact .lbl { display: none; }
.callbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 60; display: flex; align-items: center; gap: 8px; background: var(--text); color: var(--bg); padding: 8px 12px; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.35); min-width: 280px; max-width: 94vw; }
.callbar .btn { color: var(--text); }
.chipbtn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 6px 12px; border-radius: 18px; font-size: 13px; }
.chipbtn.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.callrow .callbtns .btn { padding: 9px 14px; }
.chip.danger { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.chip.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.badge.warn { background: var(--warn); }
.stat.warnbg { border-color: var(--warn); }

.nav .searchbtn { display: flex; align-items: center; gap: 6px; margin: 0 4px 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel2); color: var(--muted); text-align: left; font-size: 13px; }
.nav .searchbtn:hover { color: var(--text); }
.nav kbd { margin-left: auto; font: 11px system-ui; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.nav .sect { display: flex; width: 100%; align-items: center; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 12px 10px 4px; }
.nav .sect .chev { margin-left: auto; }
.tabbar { display: none; }

.palette { align-items: start; }
.palette-input { font-size: 16px; padding: 11px 14px; border-radius: 10px; }
.palette-list { margin-top: 8px; max-height: 52vh; overflow: auto; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.palette-item.on { background: color-mix(in srgb, var(--brand) 14%, transparent); }
.palette-item .ico { width: 28px; text-align: center; font-size: 16px; }

.setup { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.progress { height: 6px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin: 10px 0 6px; }
.progress i { display: block; height: 100%; background: var(--brand); }
.setup .step { padding: 8px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.setup .step.done b { color: var(--muted); text-decoration: line-through; }
.setup .check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 13px; flex: none; margin-top: 1px; color: #fff; }
.setup .step.done .check { background: var(--brand); border-color: var(--brand); }
.menugrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.menuitem { display: grid; gap: 2px; justify-items: center; padding: 12px 4px; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; font-size: 12.5px; }
.menuitem span { font-size: 20px; }

/* ----- phone ----- */
@media (max-width: 760px) {
  html, body { overscroll-behavior: none; }
  body { padding-bottom: 0; }
  .shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .nav { display: none; }
  main { grid-row: 1; }
  .tabbar { display: flex; grid-row: 2; background: var(--panel); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar button { position: relative; flex: 1; border: 0; background: none; color: var(--muted); display: grid; justify-items: center; gap: 0; padding: 6px 2px; font-size: 11px; border-radius: 10px; }
  .tabbar button.on { color: var(--brand); font-weight: 700; }
  .tabbar .ti { font-size: 19px; line-height: 1.2; }
  .tabbar .badge { position: absolute; top: 2px; left: 55%; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; }
  .topbar h1 { font-size: 16px; }
  .content { padding: 12px; }
  .grid.stats { grid-template-columns: repeat(2, 1fr); }
  input, select, textarea { font-size: 16px; } /* stops iOS zooming into fields */
  .btn { min-height: 38px; }
  .modal-bg { align-items: end; padding: 0; }
  .modal { max-width: 100%; width: 100%; border-radius: 18px 18px 0 0; max-height: 88vh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .callbar { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .callbtns .lbl { display: inline; }
  .callrow .callbtns { width: 100%; } .callrow .callbtns .btn { flex: 1; justify-content: center; }
  .wa-top { padding: 6px 10px; } .wa-top .small { display: none; }
  .wa-composer { padding-bottom: 8px; }
  .wa-head { padding: 6px 8px; gap: 8px; }
  .wa-head .seg button { padding: 4px 8px; font-size: 12px; }
  .callbtns.compact .btn { padding: 6px 9px; }
  table { font-size: 13px; }
}
@media (display-mode: standalone) { .wa-top { padding-top: calc(6px + env(safe-area-inset-top)); } }
.btn.call { display: inline-flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; }
@media (max-width: 760px) { .stat { padding: 10px 14px; } .stat .n { font-size: 20px; } }

.permgroup { margin: 12px 0 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.perm { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; cursor: pointer; }
.perm input { margin-top: 3px; }

.qr-list { max-height: 300px; overflow: auto; min-width: 280px; } .qr-list button.on { background: var(--panel2); outline: 1px solid var(--line); }
/* Paste review and call actions stay within narrow phone screens. */
.callrow .callbtns { flex-wrap: wrap; }
.callrow select { max-width: 100%; }
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  .callsheet .row { flex-wrap: wrap; }
}
.stat.okbg { border-color: var(--brand); }
@media print { .nav, .tabbar, .topbar .row, .wa-tabs { display: none !important; } main { overflow: visible !important; } .card { break-inside: avoid; } }

.offbar { position: fixed; top: 0; left: 0; right: 0; z-index: 900; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); background: var(--panel2); border-bottom: 1px solid var(--line); font-size: 13px; }
.offbar.off { background: #92400e; color: #fff; border-color: #92400e; }
.installbar { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 850; max-width: 460px; margin: 0 auto; display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--panel); border: 1px solid var(--brand); border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.28); }
.installbar .ico { font-size: 24px; } .installbar .small { opacity: .75; }
@media (min-width: 900px) { .installbar { left: auto; right: 20px; bottom: 20px; margin: 0; } }
