:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --border: #e6e8ef;
  --text: #171a2b;
  --muted: #6b7086;
  --primary: #a30e0e;
  --primary-50: #fbeceb;
  --primary-600: #860b0b;
  --side: #1f1b1c;
  --side-2: #2f292a;
  --side-text: #cfc7c7;
  --wa: #1fa855;
  --wa-50: #e7f8ee;
  --ig: #d6246e;
  --ig-50: #fdecf3;
  --amber: #b7791f;
  --amber-50: #fff7e6;
  --red: #d64545;
  --red-50: #fdeeee;
  --green: #15925a;
  --green-50: #e6f6ee;
  --blue: #2563eb;
  --shadow: 0 1px 2px rgba(16, 18, 40, .06), 0 4px 16px rgba(16, 18, 40, .06);
  --radius: 12px;
  --out: #f6e7e7;
  --bot: #e9f7f0;
  --note: #fff6d8;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
svg { width: 16px; height: 16px; flex-shrink: 0; vertical-align: middle; }
svg.tick { width: 13px; height: 13px; vertical-align: -2px; }
.brand .logo svg { width: 18px; height: 18px; color: #fff; }
.avatar > svg { width: 16px; height: 16px; color: #fff; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.stack > * + * { margin-top: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------- layout ---------- */
#app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 224px; flex-shrink: 0; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 14px 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; color: #fff; font-weight: 700; font-size: 15.5px; }
.brand .logo { width: 38px; height: 38px; border-radius: 50%; background: #fff; display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.brand .logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--side-text); opacity: .8; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav .badge { margin-left: auto; background: #ff4d6d; color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.nav .sep { height: 1px; background: var(--side-2); margin: 8px 6px; }
.side-foot { border-top: 1px solid var(--side-2); padding-top: 10px; margin-top: 8px; }
.side-foot select { width: 100%; background: var(--side-2); border: 0; color: #fff; padding: 8px; border-radius: 8px; margin-bottom: 8px; }
.me-btn { display: flex; align-items: center; gap: 9px; padding: 6px; border-radius: 9px; cursor: pointer; color: #fff; }
.me-btn:hover { background: var(--side-2); }
.me-btn .small { color: var(--side-text); }
main { flex: 1; min-width: 0; overflow-y: auto; }
.page { padding: 24px 28px 40px; max-width: 1280px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.mobile-top { display: none; }

/* ---------- components ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 550; white-space: nowrap; line-height: 1.2; }
.btn:hover { border-color: #cfd2de; background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-50); border-color: #f3c4c4; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.icon { padding: 7px; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
label.f { display: block; font-weight: 550; font-size: 12.5px; margin-bottom: 5px; color: #3a3e55; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], input[type=datetime-local], input[type=time], select, textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); padding: 8px 11px; border-radius: 8px; outline: none; transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
textarea { resize: vertical; min-height: 70px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cdd0db; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(16px); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: #eef0f5; color: #4a4f66; white-space: nowrap; }
.pill.wa { background: var(--wa-50); color: var(--wa); }
.pill.ig { background: var(--ig-50); color: var(--ig); }
.pill.green { background: var(--green-50); color: var(--green); }
.pill.red { background: var(--red-50); color: var(--red); }
.pill.amber { background: var(--amber-50); color: var(--amber); }
.pill.violet { background: var(--primary-50); color: var(--primary); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--primary-50); color: var(--primary-600); font-weight: 550; }
.tag button { border: 0; background: none; cursor: pointer; padding: 0; color: inherit; opacity: .6; font-size: 14px; line-height: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 5px 11px; border-radius: 99px; cursor: pointer; font-size: 12.5px; font-weight: 550; color: var(--muted); }
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: .35; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13.5px; color: #fff; flex-shrink: 0; position: relative; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar .ch { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; border: 2px solid #fff; display: grid; place-items: center; }
.avatar .ch svg { width: 9px; height: 9px; color: #fff; }
.ch-wa { background: var(--wa); }
.ch-ig { background: linear-gradient(135deg, #f58529, #dd2a7b 50%, #8134af); }
.progress { height: 6px; background: #eceef4; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 99px; }
.alert { padding: 11px 14px; border-radius: 10px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.alert.info { background: var(--primary-50); color: #7a1010; }
.alert.warn { background: var(--amber-50); color: #7a5112; }
.alert.err { background: var(--red-50); color: #9b2c2c; }
.alert.ok { background: var(--green-50); color: #0d6a40; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, monospace; font-size: 12.5px; background: var(--surface-2); }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(16, 14, 40, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .18s; }
.modal.wide { max-width: 820px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: pop .2s; font-size: 13.5px; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
.auth-hero { background: radial-gradient(circle at 15% 15%, #6d0b0b 0, transparent 50%), radial-gradient(circle at 85% 90%, #4a3f40 0, transparent 45%), var(--side); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h1 { font-size: 34px; line-height: 1.15; max-width: 420px; }
.auth-hero ul { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; color: var(--side-text); }
.auth-hero li::before { content: '✓'; color: #8ef0b5; margin-right: 10px; font-weight: 700; }
.auth-form { display: grid; place-items: center; padding: 40px 20px; background: var(--surface); }
.auth-form form { width: 100%; max-width: 360px; }

/* ---------- dashboard ---------- */
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chart { width: 100%; height: 220px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.bar-mini { height: 6px; background: var(--primary-50); border-radius: 99px; flex: 1; overflow: hidden; }
.bar-mini > div { height: 100%; background: var(--primary); }
.checklist .step { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.checklist .step:last-child { border: 0; }
.checklist .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.checklist .step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 330px minmax(0, 1fr) 300px; height: 100vh; }
.inbox.no-panel { grid-template-columns: 330px minmax(0, 1fr); }
.conv-col { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.conv-col .head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 2px; background: var(--bg); padding: 3px; border-radius: 9px; margin: 10px 0 8px; }
.tabs button { flex: 1; border: 0; background: none; padding: 6px 2px; white-space: nowrap; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 12px; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs button .n { font-weight: 500; opacity: .7; margin-left: 1px; font-size: 11px; }
.conv-list { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 11px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #f0f1f5; position: relative; }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--primary-50); }
.conv.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.conv .name { font-weight: 600; }
.conv .time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.conv .prev { color: var(--muted); font-size: 13px; margin-top: 2px; }
.conv.unread .name, .conv.unread .prev { color: var(--text); font-weight: 650; }
.conv .unread-n { background: var(--wa); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; min-width: 19px; height: 19px; display: grid; place-items: center; padding: 0 5px; }
.conv .meta { display: flex; gap: 6px; margin-top: 5px; align-items: center; flex-wrap: wrap; }
.chat-col { display: flex; flex-direction: column; min-height: 0; background: #f6f3f3; }
.chat-head { padding: 11px 16px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.chat-head .ctrl { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chat-head select { width: auto; padding: 6px 9px; font-size: 12.5px; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; background-image: radial-gradient(#e6dede 1px, transparent 1px); background-size: 18px 18px; }
.day-sep { align-self: center; background: rgba(255,255,255,.9); color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; margin: 10px 0; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.bubble { max-width: min(72%, 560px); padding: 8px 11px 6px; border-radius: 12px; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.06); position: relative; word-wrap: break-word; line-height: 1.42; }
.bubble .txt { white-space: pre-wrap; }
.bubble.in { align-self: flex-start; border-top-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--out); border-top-right-radius: 4px; }
.bubble.out.bot { background: var(--bot); }
.bubble.out.broadcast { background: #e6f0ff; }
.bubble.out.failed { background: var(--red-50); }
.bubble.note { align-self: flex-end; background: var(--note); border: 1px dashed #e8cf76; }
.bubble .by { font-size: 11px; font-weight: 650; color: var(--primary); margin-bottom: 2px; }
.bubble.bot .by { color: var(--green); }
.bubble.note .by { color: var(--amber); }
.bubble .foot { display: flex; justify-content: flex-end; gap: 4px; align-items: center; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.bubble .tick { width: 15px; height: 15px; }
.bubble .tick.read { color: #2b9cf2; }
.bubble .err { font-size: 11.5px; color: var(--red); margin-top: 3px; white-space: normal; }
.bubble img.media { max-width: 260px; max-height: 300px; border-radius: 8px; display: block; margin-bottom: 4px; cursor: zoom-in; }
.bubble video.media { max-width: 280px; border-radius: 8px; display: block; margin-bottom: 4px; }
.bubble .file { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.04); padding: 8px 10px; border-radius: 8px; margin-bottom: 4px; }
.bubble .opts { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.bubble .opts span { display: block; text-align: center; border-top: 1px solid rgba(0,0,0,.07); padding-top: 5px; color: var(--blue); font-weight: 550; font-size: 13px; }
.bubble.comment { border-left: 3px solid var(--ig); }
.bubble .ctx { font-size: 11px; color: var(--ig); font-weight: 650; margin-bottom: 2px; }
.sys { align-self: center; font-size: 11.5px; color: var(--muted); background: rgba(255,255,255,.85); padding: 3px 10px; border-radius: 99px; margin: 4px 0; }
.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 14px 12px; }
.composer .modes { display: flex; gap: 14px; margin-bottom: 8px; font-size: 12.5px; font-weight: 600; }
.composer .modes button { border: 0; background: none; padding: 2px 0; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.composer .modes button.on { color: var(--text); border-color: var(--primary); }
.composer .modes button.note.on { border-color: var(--amber); }
.composer textarea { min-height: 44px; max-height: 180px; resize: none; border-radius: 10px; }
.composer.note textarea { background: #fffcef; border-color: #eedc9b; }
.composer .bar { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.sr-pop { position: absolute; bottom: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 220px; overflow-y: auto; margin-bottom: 6px; z-index: 5; }
.sr-pop div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f0f1f5; }
.sr-pop div:hover, .sr-pop div.on { background: var(--primary-50); }
.window-banner { background: var(--amber-50); color: #7a5112; padding: 9px 14px; font-size: 12.5px; display: flex; align-items: center; gap: 10px; border-top: 1px solid #f2dfb5; }
.sim-bar { background: #2b2526; color: #eadede; padding: 8px 14px; display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.sim-bar input { background: #3a3233; border-color: #4a4142; color: #fff; padding: 6px 10px; }
.sim-bar .btn { background: #a30e0e; border-color: #a30e0e; color: #fff; }
.side-col { border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; }
.side-col section { padding: 16px; border-bottom: 1px solid var(--border); }
.side-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 78px 1fr; gap: 6px 8px; font-size: 13px; }
.kv .k { color: var(--muted); }
.inline-edit { border: 1px solid transparent; padding: 3px 6px; margin: -3px -6px; border-radius: 6px; width: calc(100% + 12px); background: transparent; }
.inline-edit:hover { border-color: var(--border); }
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; }

/* ---------- flow builder ---------- */
.flow-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.node { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 12px; box-shadow: var(--shadow); }
.node-head { display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.node-head .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.node-head .ico svg { width: 15px; height: 15px; }
.node-body { padding: 14px; }
.node.start { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.node .opt { display: grid; grid-template-columns: 1fr 180px 30px; gap: 8px; margin-bottom: 8px; align-items: center; }
.node .next { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.node .next select { width: auto; flex: 1; max-width: 280px; }
.t-message { background: #a30e0e; } .t-buttons { background: #2563eb; } .t-question { background: #0e9f6e; }
.t-condition { background: #c27803; } .t-tag { background: #9333ea; } .t-handoff { background: #e02424; } .t-end { background: #4b5563; }
.add-step { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px; border: 2px dashed var(--border); border-radius: 12px; justify-content: center; }
.map { font-size: 12.5px; }
.map .m-node { padding: 6px 9px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); margin: 4px 0; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.map .m-node:hover { border-color: var(--primary); }
.map .m-edge { color: var(--muted); padding-left: 14px; font-size: 11.5px; }
.phone { background: #ece5dd; border-radius: 18px; padding: 12px; min-height: 260px; display: flex; flex-direction: column; gap: 6px; }
.phone .b { background: #fff; padding: 7px 10px; border-radius: 9px; max-width: 85%; font-size: 12.5px; white-space: pre-wrap; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.phone .b.me { align-self: flex-end; background: #d9fdd3; }
.phone .btns span { display: block; background: #fff; text-align: center; color: #2563eb; padding: 6px; border-radius: 9px; margin-top: 3px; font-size: 12.5px; font-weight: 550; }

/* ---------- template preview ---------- */
.wa-preview { background: #ece5dd; padding: 14px; border-radius: 12px; }
.wa-preview .b { background: #fff; border-radius: 10px; padding: 9px 11px; font-size: 13px; white-space: pre-wrap; max-width: 320px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.wa-preview .b .hd { font-weight: 700; margin-bottom: 4px; }
.wa-preview .b .ft { color: var(--muted); font-size: 11.5px; margin-top: 6px; }
.wa-preview .btns span { display: block; background: #fff; text-align: center; color: #2563eb; padding: 7px; border-radius: 9px; margin-top: 4px; max-width: 320px; font-weight: 550; font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
  .side-col { display: none; }
  .inbox.show-panel .side-col { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: 320px; z-index: 30; box-shadow: -10px 0 30px rgba(0,0,0,.15); }
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .flow-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  #app { flex-direction: column; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--side); color: #fff; font-weight: 700; }
  .mobile-top button { background: none; border: 0; color: #fff; padding: 4px; }
  main { height: calc(100vh - 50px); }
  .page { padding: 18px 16px 40px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inbox { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 50px); }
  .composer .bar, .sim-bar { flex-wrap: wrap; }
  .sim-bar input { min-width: 0; }
  .composer .bar .btn.ghost { padding: 5px 6px; }
  .inbox .chat-col { display: none; }
  .inbox.chat-open .conv-col { display: none; }
  .inbox.chat-open .chat-col { display: flex; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .node .opt { grid-template-columns: 1fr; }
  .bubble { max-width: 88%; }
  .back-btn { display: inline-flex !important; }
}
.back-btn { display: none !important; }
