/* Channels: Numbers, Templates, Alerts and Integrations (channels.js). */

/* Shared bits */
.ch-id { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 0; }
.ch-id code { font-size: .82rem; }
.ch-id small { color: var(--muted); }
.ch-sub { margin: 0 0 6px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.ch-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ch-chip { padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--control-bg); color: var(--ink); font: 600 .74rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.ch-chip:hover { border-color: var(--brand-200); background: var(--hover-bg); }
.ch-fieldset { display: grid; gap: 14px; min-width: 0; margin: 0; padding: 0; border: 0; }
.ch-suffix { display: flex; align-items: center; gap: 6px; }
.ch-suffix input { flex: 1; }
.ch-var { padding: 0 3px; border-radius: 4px; background: var(--tone-good-bg); color: var(--tone-good); }
.ch-var--missing { background: var(--tone-warn-bg); color: var(--tone-warn); }
.ch-ph { color: var(--muted); font-style: italic; }
.ch-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; padding: 0; border: 0; }
.ch-checks legend { margin-bottom: 8px; font-size: .88rem; font-weight: 650; }
.ch-checks .mz-error { flex-basis: 100%; }
.ch-pv-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.ch-pv-tools .eyebrow { margin: 0; }
.ch-pv-tools .mz-seg span { display: inline-flex; align-items: center; gap: 6px; }
.ch-pv-tools .mz-seg .lucide { width: 14px; height: 14px; }
.ch-pv-stage { display: grid; justify-items: center; padding: 22px 14px; border-radius: 18px; background: repeating-linear-gradient(45deg, rgba(119, 39, 143, .04) 0 10px, transparent 10px 20px), var(--surface-2); }
.ch-pv-stage--small { padding: 14px; transform-origin: top center; }

/* Email preview */
.ch-mail { width: 100%; max-width: 620px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: #1f1a24; box-shadow: 0 10px 30px rgba(45, 13, 54, .12); transition: max-width .25s ease; }
.ch-mail--mobile { max-width: 340px; }
.ch-mail__chrome { display: flex; gap: 6px; padding: 9px 12px; background: #f3eff5; }
.ch-mail__chrome span { width: 9px; height: 9px; border-radius: 50%; background: #d6ccdb; }
.ch-mail__head { padding: 14px 18px 10px; border-bottom: 1px solid #eee7f0; }
.ch-mail__subject { margin: 0 0 10px; font-size: 1.05rem; font-weight: 750; color: #1f1a24; }
.ch-mail__from { display: flex; align-items: center; gap: 10px; margin: 0; font-size: .82rem; color: #4f4757; }
.ch-mail__from small { color: #7a7181; }
.ch-mail__body { padding: 16px 18px; font-size: .9rem; line-height: 1.65; overflow-wrap: anywhere; }
.ch-mail__foot { margin: 0; padding: 10px 18px 14px; border-top: 1px solid #eee7f0; font-size: .72rem; color: #8a8191; }
.ch-mail .ch-var { background: #e3f5ef; color: #0b5f4f; }
.ch-mail .ch-var--missing { background: #fff1d6; color: #7a4a00; }
.ch-phone__avatar { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--brand-500); color: #fff; font-weight: 800; font-size: .8rem; }

/* Phone frame: WhatsApp and SMS */
.ch-phone { width: 300px; max-width: 100%; overflow: hidden; border: 8px solid #17111b; border-radius: 34px; background: #efe7de; box-shadow: 0 18px 40px rgba(20, 8, 26, .3); }
.ch-phone__bar { display: flex; align-items: center; gap: 8px; padding: 12px 10px; background: #075e54; color: #fff; }
.ch-phone__bar .lucide { width: 18px; height: 18px; }
.ch-phone__bar strong { display: block; font-size: .86rem; }
.ch-phone__bar small { display: flex; align-items: center; gap: 3px; font-size: .68rem; opacity: .85; }
.ch-phone__bar small .lucide { width: 11px; height: 11px; }
.ch-wa { display: grid; gap: 4px; min-height: 280px; align-content: start; padding: 14px 10px 18px; background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .35) 0 2px, transparent 3px) 0 0 / 22px 22px, #efe7de; }
.ch-wa__bubble { position: relative; justify-self: start; max-width: 92%; padding: 8px 10px 18px; border-radius: 0 10px 10px 10px; background: #fff; color: #111b21; font-size: .84rem; line-height: 1.45; box-shadow: 0 1px 1px rgba(0, 0, 0, .12); overflow-wrap: anywhere; }
.ch-wa__bubble p { margin: 0 0 4px; color: #111b21 !important; }
.ch-wa__header { font-weight: 750; }
.ch-wa__footer { font-size: .74rem; color: #667781 !important; }
.ch-wa__time { position: absolute; right: 8px; bottom: 4px; font-size: .66rem; color: #667781; }
.ch-wa__btn { display: flex; align-items: center; justify-content: center; gap: 6px; justify-self: start; width: 92%; padding: 8px; border-radius: 10px; background: #fff; color: #027eb5; font-size: .82rem; font-weight: 650; box-shadow: 0 1px 1px rgba(0, 0, 0, .12); }
.ch-wa__btn .lucide { width: 14px; height: 14px; }
.ch-wa .ch-var, .ch-sms .ch-var { background: #d9fdd3; color: #0b5f4f; }
.ch-phone--sms { background: #fff; }
.ch-phone--sms .ch-phone__bar { background: #f2f2f7; color: #111; border-bottom: 1px solid #e3e3e8; }
.ch-sms { min-height: 240px; padding: 16px 10px; background: #fff; }
.ch-sms__bubble { max-width: 88%; padding: 9px 12px; border-radius: 18px 18px 18px 4px; background: #e9e9eb; color: #111; font-size: .84rem; line-height: 1.45; overflow-wrap: anywhere; }
.ch-sms__meta { margin: 0; padding: 8px 12px 12px; background: #fff; font-size: .7rem; color: #6b6b70; text-align: center; }

/* Templates page */
.ch-tpl-layout { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 18px; align-items: start; }
.ch-tpl-list { display: grid; gap: 8px; max-height: calc(100dvh - 140px); overflow: auto; padding: 2px; }
.ch-tpl-item { display: grid; grid-template-columns: 38px 1fr; gap: 10px; width: 100%; padding: 12px; border: 1.5px solid transparent; border-radius: 16px; background: var(--glass-bg); box-shadow: var(--glass-shadow); color: var(--ink); text-align: left; }
.ch-tpl-item:hover { border-color: var(--brand-200); }
.ch-tpl-item[aria-selected="true"] { border-color: var(--brand-500); }
.ch-tpl-item__icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--tone-live-bg); color: var(--tone-live); }
.ch-tpl-item__icon--whatsapp { background: rgba(37, 211, 102, .16); color: #0b7a3e; }
.ch-tpl-item__icon--sms { background: var(--tone-info-bg); color: var(--tone-info); }
html[data-theme="dark"] .ch-tpl-item__icon--whatsapp { color: #7ff0ae; }
.ch-tpl-item__icon .lucide { width: 18px; height: 18px; }
.ch-tpl-item__main { display: grid; gap: 3px; min-width: 0; }
.ch-tpl-item__main > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ch-tpl-item__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; }
.ch-tpl-item__meta code { font-size: .72rem; }
.ch-used { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 650; color: var(--muted); }
.ch-used .lucide { width: 12px; height: 12px; }
.ch-tpl-preview { display: grid; gap: 14px; }
.main-content .ch-tpl-preview { position: sticky; top: 104px; }
.ch-tpl-preview__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ch-tpl-preview__head h2 { margin: 0; }
.ch-tpl-preview__head .eyebrow { display: flex; align-items: center; gap: 6px; }
.ch-tpl-preview__head .eyebrow .lucide { width: 14px; height: 14px; }
.ch-tpl-facts { display: grid; gap: 6px; }
.ch-tpl-facts p { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin: 0; }
.ch-tpl-facts strong { min-width: 110px; font-size: .84rem; }

/* Template editor */
.ch-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .9fr); gap: 20px; align-items: start; }
.ch-editor__preview { display: grid; gap: 10px; position: sticky; top: 0; }
.ch-btns { display: grid; gap: 8px; }
.ch-btnrow { display: grid; grid-template-columns: 130px 1fr 1fr auto; gap: 6px; align-items: center; }
.ch-btnrow:not(:has([data-bval])) { grid-template-columns: 130px 1fr auto; }
.ch-btnrow select, .ch-btnrow input { min-height: 38px; padding: 7px 10px; border: 1px solid var(--field-border); border-radius: 9px; background: var(--field-bg); color: var(--ink); }
.ch-btnrow .mz-error { grid-column: 1 / -1; }
.ch-btns .btn { justify-self: start; }

/* Alerts */
.ch-alerts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.ch-alert { display: grid; gap: 12px; align-content: start; transition: opacity .2s; }
.ch-alert.is-off { opacity: .66; }
.ch-alert.is-flash { box-shadow: 0 0 0 3px var(--brand-500), var(--glass-shadow); }
.ch-alert > header { display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; }
.ch-alert h2 { margin: 0; font-size: 1.1rem; }
.ch-alert header p { margin: 2px 0 0; font-size: .78rem; color: var(--muted) !important; }
.ch-alert__icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: var(--tone-live-bg); color: var(--tone-live); }
.ch-alert__icon .lucide { width: 20px; height: 20px; }
.ch-flow { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.ch-flow li { position: relative; display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 8px 0 8px 2px; border-top: 1px dashed var(--line); font-size: .9rem; }
.ch-flow__k { font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.ch-sends { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-send { display: inline-flex; align-items: center; gap: 5px; padding: 4px 6px 4px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--control-bg); font-size: .8rem; font-weight: 650; }
.ch-send .lucide { width: 14px; height: 14px; color: var(--link); }
.ch-send.is-warn { border-color: var(--warning); }
.ch-send.is-warn .lucide:last-child { color: var(--tone-warn); }
.ch-send em { color: var(--tone-bad); font-style: normal; font-weight: 600; }
.ch-send__tpl { padding: 1px 7px; border: 0; border-radius: 6px; background: var(--hover-bg); color: var(--link); font-size: .76rem; font-weight: 650; text-decoration: underline dotted; }
.ch-alert footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ch-alert footer .mz-iconbtn { margin-left: auto; }
.ch-alert footer .btn { margin-top: 0 !important; }

/* Alert builder */
.ch-builder { gap: 16px; }
.ch-step { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; }
.ch-step h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .95rem; }
.ch-step h3 span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-500); color: #fff; font-size: .72rem; }
.ch-step > p { margin: 0; }
.ch-nothreshold { align-self: end; margin: 0 0 12px !important; }
.ch-sendlist { display: grid; gap: 6px; }
.ch-sendrow { display: grid; grid-template-columns: minmax(170px, auto) 1fr; gap: 6px 12px; align-items: center; padding: 8px 10px; border-radius: 12px; }
.ch-sendrow.is-on { background: var(--hover-bg); }
.ch-sendrow .mz-check .lucide { width: 15px; height: 15px; color: var(--link); }
.ch-sendrow .mz-check:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.ch-sendrow__tpl { display: flex; gap: 8px; align-items: center; min-width: 0; }
.ch-sendrow__tpl select { flex: 1; min-width: 0; min-height: 38px; padding: 7px 10px; border: 1px solid var(--field-border); border-radius: 9px; background: var(--field-bg); color: var(--ink); }
.ch-sendrow__tpl .btn { margin: 0; }
.ch-sendrow .mz-error { grid-column: 1 / -1; }
.ch-inline-pv { display: grid; gap: 8px; }
.ch-inline-pv:empty { display: none; }
.ch-inline-pv .eyebrow { margin: 0; }

/* Numbers */
.ch-numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.ch-num { display: grid; gap: 12px; align-content: start; }
.ch-num > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ch-num h2 { margin: 0; font-size: 1.1rem; }
.ch-num .eyebrow { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.ch-num .eyebrow .lucide { width: 13px; height: 13px; }
.ch-num__number { margin: 4px 0 0; font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink) !important; }
.ch-num__series { display: flex; align-items: center; gap: 6px; margin: 0; font-size: .84rem; font-weight: 650; }
.ch-num__series .lucide { width: 15px; height: 15px; color: var(--link); }
.ch-num__use { display: grid; gap: 5px; }
.ch-num__uselabel { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.ch-num .mz-kv { grid-template-columns: 80px 1fr; gap: 6px 12px; }
.ch-num footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ch-num footer .btn { margin-top: 0 !important; }
.ch-num footer .mz-iconbtn { margin-left: auto; }
.ch-checklist { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ch-checklist li { display: grid; grid-template-columns: 20px 1fr; gap: 2px 10px; align-items: center; font-size: .9rem; font-weight: 600; }
.ch-checklist li .lucide { width: 18px; height: 18px; color: var(--muted); }
.ch-checklist li[data-state="run"] .lucide { color: var(--link); animation: mz-spin 1s linear infinite; }
.ch-checklist li[data-state="ok"] .lucide { color: var(--tone-good); }
.ch-checklist li[data-state="bad"] .lucide { color: var(--tone-bad); }
.ch-checklist small { grid-column: 2; font-weight: 500; color: var(--muted); }
.ch-checklist li[data-state="bad"] small { color: var(--tone-bad); }

/* Integrations */
.ch-integrations { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.ch-int { display: grid; gap: 10px; align-content: start; }
.ch-int > header { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; }
.ch-int h3 { margin: 0 0 3px; }
.ch-int header p { margin: 0; font-size: .84rem; color: var(--muted) !important; }
.ch-int__logo { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--surface-2); color: var(--link); }
.ch-int--connected .ch-int__logo { background: var(--tone-good-bg); color: var(--tone-good); }
.ch-int--error .ch-int__logo { background: var(--tone-bad-bg); color: var(--tone-bad); }
.ch-int__logo .lucide { width: 22px; height: 22px; }
.ch-int__state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ch-int__state small { color: var(--muted); overflow-wrap: anywhere; }
.ch-int p.small { display: flex; align-items: center; gap: 6px; margin: 0; }
.ch-int p.small .lucide { width: 13px; height: 13px; }
.ch-int footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: auto; }
.ch-int footer .btn { margin-top: 0 !important; }
.ch-int footer small { color: var(--muted); }
.ch-dns { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; font-size: .8rem; font-weight: 650; }
.ch-dns li { display: flex; align-items: center; gap: 4px; }
.ch-dns .lucide { width: 14px; height: 14px; }
.ch-dns .is-ok { color: var(--tone-good); }
.ch-dns .is-bad { color: var(--tone-warn); }
.ch-scopes { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ch-scopes li { display: flex; align-items: center; gap: 8px; }
.ch-scopes .lucide { width: 15px; height: 15px; color: var(--tone-good); }
.ch-hook { display: grid; gap: 12px; }
.ch-hook > header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ch-hook__url { margin: 0 0 6px; overflow-wrap: anywhere; }
.ch-hook footer { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-hook footer .btn { margin-top: 0 !important; }
.ch-hook footer .mz-iconbtn { margin-left: auto; }
.ch-hook .mz-table th { position: static; }

@media (max-width: 1100px) {
  .ch-tpl-layout, .ch-editor { grid-template-columns: 1fr; }
  .main-content .ch-tpl-preview, .ch-editor__preview { position: static; }
  .ch-tpl-list { max-height: none; }
}
@media (max-width: 640px) {
  .ch-sendrow { grid-template-columns: 1fr; }
  .ch-btnrow, .ch-btnrow:not(:has([data-bval])) { grid-template-columns: 1fr auto; }
  .ch-btnrow select { grid-column: 1 / -1; }
  .ch-flow li { grid-template-columns: 1fr; gap: 2px; }
  .ch-pv-stage { padding: 14px 6px; }
}
@media (prefers-reduced-motion: reduce) { .ch-checklist li[data-state="run"] .lucide { animation: none; } .ch-mail { transition: none; } }
