:root{
  --ink:#10241d;--muted:#55675f;--bg:#f3f6fb;--card:#fff;--line:#e3e9f0;--field:#c9d3df;
  --accent:#0e9f62;--accent-d:#0b7f4e;--accent-soft:#e3f7ec;
  --sun:#ffb224;--sun-soft:#fff3d6;--coral:#f0503c;--coral-soft:#ffe6e1;--sky:#2b8ef0;--sky-soft:#e2f0ff;--violet:#7a5af5;--violet-soft:#ece7ff;--teal:#0aa3a3;--teal-soft:#dcf5f4;
  --read:#2b8ef0;--delivered:#0e9f62;--sent:#8fdcb4;--wait:#dfe5ee;--failed:#f0503c;
  --ok-bg:var(--accent-soft);--warn-bg:var(--sun-soft);--warn:#8a5a00;--bad-bg:var(--coral-soft);--bad:#b3261e;
  --shadow:0 1px 2px rgba(16,36,29,.05),0 8px 24px rgba(30,60,110,.07);
}
*{box-sizing:border-box}
[hidden]{display:none!important}
body{margin:0;font-family:Rubik,Heebo,system-ui,sans-serif;color:var(--ink);background:var(--bg);font-size:16px;line-height:1.5}
.loading{padding:32px}
a{color:var(--accent-d)}a:hover{color:var(--ink)}

/* ---------- layout ---------- */
.shell{display:flex;flex-wrap:wrap;min-height:100vh}
nav{flex:1 1 232px;max-width:100%;background:#fff;border-inline-end:1px solid var(--line);padding:20px 14px;display:flex;flex-direction:column;gap:4px}
nav .brand{display:flex;align-items:center;gap:10px;font-size:19px;font-weight:800;padding:4px 10px 18px;letter-spacing:-.01em}
.logo{width:34px;height:34px;border-radius:11px 11px 11px 3px;background:linear-gradient(135deg,#19c37d,#0aa3a3);display:inline-block;position:relative;flex:none}
.logo::after{content:"";position:absolute;inset:9px 8px 11px;border-radius:2px;background:linear-gradient(#fff,#fff) 0 0/100% 3px no-repeat,linear-gradient(#fff,#fff) 0 6px/70% 3px no-repeat,linear-gradient(#fff,#fff) 0 12px/85% 3px no-repeat}
nav a{display:flex;align-items:center;gap:12px;min-height:46px;padding:6px 10px;border-radius:12px;color:var(--ink);text-decoration:none;font-weight:500}
nav a:hover{background:#f3f6fb;color:var(--ink)}
nav a.on{background:var(--ink);color:#fff}
.ic{width:32px;height:32px;border-radius:10px;display:grid;place-items:center;flex:none}
.ic.c1{background:var(--accent-soft);color:var(--accent-d)}.ic.c2{background:var(--sun-soft);color:#a56a00}.ic.c3{background:var(--sky-soft);color:#1767bd}
.ic.c4{background:var(--violet-soft);color:#5a3fd0}.ic.c5{background:var(--teal-soft);color:#087878}.ic.c6{background:var(--coral-soft);color:#c23a28}
nav a.on .ic{background:rgba(255,255,255,.16);color:#fff}
nav .spacer{flex:1}
.who{display:flex;flex-direction:column;padding:10px;font-size:14px;color:var(--muted);overflow-wrap:anywhere}.who strong{color:var(--ink)}
nav a.out{color:var(--muted);min-height:44px}
main{flex:999 1 560px;min-width:0;padding:28px 32px 40px;display:flex;flex-direction:column;gap:20px}
h1{margin:0;font-size:30px;font-weight:800;letter-spacing:-.02em;line-height:1.15}
h2{margin:0;font-size:18px;font-weight:700}
.sub{color:var(--muted);margin-top:4px;font-size:15px}
.head{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:16px}
.card{background:var(--card);border-radius:18px;padding:20px;box-shadow:var(--shadow)}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:14px}
.stat{padding:16px 18px;position:relative;overflow:hidden}
.stat .n{font-size:30px;font-weight:800;margin-top:2px;letter-spacing:-.02em}.stat .l{color:var(--muted);font-size:14px;font-weight:500}
.stat.t1{background:var(--accent-soft)}.stat.t2{background:var(--sky-soft)}.stat.t3{background:var(--sun-soft)}.stat.t4{background:var(--violet-soft)}.stat.t5{background:var(--teal-soft)}.stat.t6{background:var(--coral-soft)}
.stat.t1,.stat.t2,.stat.t3,.stat.t4,.stat.t5,.stat.t6{box-shadow:none}

/* ---------- controls ---------- */
button,.btn{min-height:44px;padding:0 18px;border-radius:12px;font:inherit;font-weight:500;cursor:pointer;border:1px solid var(--field);background:#fff;color:var(--ink)}
button:hover{border-color:var(--ink)}
button.primary{background:linear-gradient(180deg,#14b572,#0b8f58);color:#fff;border-color:transparent;box-shadow:0 6px 16px rgba(14,159,98,.28)}
button.primary:hover{background:linear-gradient(180deg,#0fa565,#097a4b)}
button.big{min-height:50px;padding:0 26px;font-size:17px;border-radius:14px}
button.ghost{border-style:dashed;color:var(--accent-d);border-color:#8fcfb0;background:var(--accent-soft)}
button.danger{color:var(--bad);border-color:var(--bad)}
button:disabled{opacity:.55;cursor:not-allowed}
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,.seg input:focus-visible+span{outline:3px solid #7fb8ff;outline-offset:2px}
label,.lbl{display:block;font-size:14px;color:var(--muted);margin-bottom:6px;font-weight:500}
input,select,textarea{width:100%;min-height:44px;padding:8px 12px;border:1px solid var(--field);border-radius:12px;font:inherit;background:#fff;color:var(--ink)}
input:hover,select:hover,textarea:hover{border-color:#93a3b5}
textarea{min-height:112px;resize:vertical}
input[type=checkbox],input[type=radio]{width:20px;min-height:20px;accent-color:var(--accent)}
.field{margin-bottom:14px}
.row{display:flex;flex-wrap:wrap;gap:12px;align-items:center}
.form{max-width:680px}
.seg{display:flex;flex-wrap:wrap;gap:6px;background:#eef2f8;padding:5px;border-radius:14px}
.seg label{flex:1 1 auto;margin:0;cursor:pointer}
.seg input{position:absolute;opacity:0;width:1px;min-height:1px;height:1px}
.seg span{display:grid;place-items:center;min-height:44px;padding:0 14px;border-radius:10px;color:var(--muted);font-size:15px;font-weight:500;text-align:center}
.seg input:checked+span{background:#fff;color:var(--ink);box-shadow:0 1px 3px rgba(16,36,29,.14)}

/* ---------- tables, pills, messages ---------- */
table{width:100%;border-collapse:collapse;font-size:15px}
.scroll{overflow-x:auto}
th{text-align:start;color:var(--muted);font-weight:500;padding:8px;border-bottom:1px solid var(--line);font-size:14px}
td{padding:11px 8px;border-bottom:1px solid #eef2f7;vertical-align:middle}
tbody tr:last-child td{border-bottom:0}
.pill{display:inline-block;padding:3px 11px;border-radius:999px;font-size:13px;font-weight:500;background:#e9edf3;color:#3b4a57;white-space:nowrap}
.pill.ok{background:var(--accent-soft);color:var(--accent-d)}.pill.warn{background:var(--sun-soft);color:var(--warn)}.pill.bad{background:var(--coral-soft);color:var(--bad)}
.msg{padding:12px 16px;border-radius:12px;background:var(--accent-soft);color:#0a5f3b}
.msg.err{background:var(--coral-soft);color:var(--bad)}.msg.warn{background:var(--sun-soft);color:var(--warn)}
form .msg{background:var(--sky-soft);color:#17406e;font-size:14px}
.login{max-width:420px;margin:9vh auto;padding:0 16px}
.qr{display:flex;flex-direction:column;align-items:center;gap:12px;padding:16px}
.qr img{width:280px;height:280px;max-width:100%}
.preview{max-width:240px;max-height:240px;border-radius:12px;display:block;margin-top:8px}
.empty{color:var(--muted);padding:16px 0}
.bar{height:8px;border-radius:999px;background:var(--wait);overflow:hidden;min-width:120px}.bar i{display:block;height:100%;background:var(--accent)}

/* ---------- new campaign: form + phone ---------- */
.split{display:flex;flex-wrap:wrap;gap:20px;align-items:flex-start}
.split>.card.form{flex:1 1 440px;max-width:700px;padding:22px 24px}
.side{flex:1 1 280px;max-width:340px;display:flex;flex-direction:column;gap:14px;position:sticky;top:20px}
.phone{background:#10241d;border-radius:30px;padding:9px;box-shadow:0 18px 40px rgba(16,36,29,.25)}
.phone-top{display:flex;align-items:center;gap:10px;background:#0b7f4e;color:#fff;padding:11px 14px;border-radius:22px 22px 0 0}
.avatar{width:34px;height:34px;border-radius:50%;background:linear-gradient(135deg,#ffd166,#ff8c42);flex:none}
.phone-name{font-weight:500}.phone-sub{font-size:12px;color:#c9efdc}
.phone-body{background:#ece5dd;background-image:radial-gradient(rgba(16,36,29,.05) 1.5px,transparent 1.5px);background-size:18px 18px;min-height:240px;padding:14px 10px;border-radius:0 0 22px 22px;display:flex;align-items:flex-start}
.bubble{background:#d9fdd3;color:#111b21;border-radius:12px 0 12px 12px;padding:6px;max-width:100%;box-shadow:0 1px 1px rgba(0,0,0,.12)}
.bubble img,.bubble video{display:block;width:100%;max-height:220px;object-fit:cover;border-radius:9px;margin-bottom:4px}
.bubble-file{background:#c6eec0;border-radius:8px;padding:12px;margin-bottom:4px;font-size:14px;word-break:break-all}
.bubble-text{white-space:pre-wrap;word-break:break-word;padding:2px 6px;font-size:15px;line-height:1.45}
.bubble-time{font-size:11px;color:#54656f;text-align:end;padding:0 6px}
.sidecard{padding:14px 18px}
.facts{margin:0;display:grid;grid-template-columns:auto 1fr;gap:6px 16px;font-size:15px}
.facts dt{color:var(--muted)}.facts dd{margin:0;font-weight:500}
@media (max-width:900px){.side{position:static;max-width:none}}

/* ---------- campaigns list ---------- */
.today{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:14px}
.line-card{background:linear-gradient(120deg,#0e9f62 0%,#0aa3a3 60%,#2b8ef0 130%);color:#fff;border-radius:22px;padding:18px 22px;box-shadow:0 12px 28px rgba(10,163,163,.25)}
.line-card.off{background:linear-gradient(120deg,#6b7a89,#8894a3);box-shadow:none}
.line-card a{color:#fff;font-weight:500}
.line-head{display:flex;justify-content:space-between;align-items:center;gap:16px;margin-bottom:12px}
.line-name{font-size:17px;font-weight:700}
.line-phone{color:rgba(255,255,255,.8);font-size:14px}
.line-count{display:flex;align-items:baseline;gap:8px}
.line-count .num{font-size:40px;font-weight:800;line-height:1;letter-spacing:-.02em}
.line-count .of{color:rgba(255,255,255,.85);font-size:14px}
.dots{display:flex;flex-wrap:wrap;gap:5px}
.dots i{width:10px;height:10px;border-radius:50%;background:rgba(255,255,255,.28);display:block}
.dots i.on{background:#fff;box-shadow:0 0 0 2px rgba(255,255,255,.25)}
.meter{height:10px;border-radius:999px;background:rgba(255,255,255,.28);overflow:hidden}.meter i{display:block;height:100%;background:#fff}
.line-note{margin-top:12px;color:rgba(255,255,255,.92);font-size:14px}
.camps{display:flex;flex-direction:column;gap:10px}
.camp{display:grid;grid-template-columns:minmax(200px,1.1fr) minmax(240px,1.6fr) auto;gap:8px 24px;align-items:center;background:var(--card);border-radius:16px;padding:14px 20px;color:inherit;text-decoration:none;box-shadow:var(--shadow);border-inline-start:6px solid var(--wait)}
.camp:hover{color:inherit;transform:translateY(-1px);box-shadow:0 2px 4px rgba(16,36,29,.06),0 14px 30px rgba(30,60,110,.12)}
.camp.s-sending{border-inline-start-color:var(--sun)}.camp.s-finished{border-inline-start-color:var(--accent)}.camp.s-scheduled{border-inline-start-color:var(--violet)}.camp.s-paused{border-inline-start-color:#93a3b5}
.camp h2{font-size:17px;font-weight:700;margin:0}
.camp-meta{color:var(--muted);font-size:13px;margin-top:2px}
.journey{display:flex;height:12px;border-radius:999px;overflow:hidden;background:var(--wait);gap:2px}
.journey i{display:block;min-width:6px;flex-basis:0}
.journey .read,.sw.read{background:var(--read)}.journey .delivered,.sw.delivered{background:var(--delivered)}.journey .sent,.sw.sent{background:var(--sent)}.journey .wait,.sw.wait{background:#c3cddb}.journey .failed,.sw.failed{background:var(--failed)}
.journey .wait.live{background:repeating-linear-gradient(-45deg,#ffd27a 0 8px,#ffe7b3 8px 16px);background-size:23px 100%;animation:queue 1.2s linear infinite}
@keyframes queue{to{background-position:23px 0}}
@media (prefers-reduced-motion:reduce){.journey .wait.live{animation:none}.camp:hover{transform:none}}
.journey-empty{color:var(--muted);font-size:14px}
.legend{display:flex;flex-wrap:wrap;gap:4px 14px;margin-top:6px;font-size:13px;color:var(--muted)}
.leg{display:inline-flex;align-items:center;gap:5px}
.sw{width:9px;height:9px;border-radius:3px;display:inline-block}
@media (max-width:820px){.camp{grid-template-columns:1fr}}
.first{background:var(--card);border-radius:22px;padding:40px 28px;text-align:center;display:flex;flex-direction:column;align-items:center;gap:10px;box-shadow:var(--shadow)}
.first h2{font-size:26px;font-weight:800;margin:8px 0 0}.first p{max-width:46ch;color:var(--muted);margin:0 0 10px}
.first-bubble{font-size:16px;padding:8px 10px}
.ticks{vertical-align:-1px;color:#8696a0}.ticks.read{color:#53bdeb}
.two{display:flex;flex-wrap:wrap;gap:0 14px}.two>.field{flex:1 1 220px}

/* ---------- assistant ---------- */
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
.ai-fab{position:fixed;inset-block-end:20px;inset-inline-end:20px;min-height:52px;padding:0 20px 0 18px;border-radius:999px;border:0;color:#fff;font-weight:700;font-size:16px;display:flex;align-items:center;gap:10px;background:linear-gradient(120deg,#7a5af5,#2b8ef0);box-shadow:0 10px 26px rgba(90,80,230,.4);z-index:20}
.ai-fab:hover{border:0;filter:brightness(1.06)}
.ai-spark{width:18px;height:18px;background:#fff;clip-path:polygon(50% 0,62% 38%,100% 50%,62% 62%,50% 100%,38% 62%,0 50%,38% 38%)}
.ai-box{position:fixed;inset-block-end:84px;inset-inline-end:20px;width:min(380px,calc(100vw - 32px));height:min(540px,calc(100vh - 120px));background:#fff;border-radius:22px;box-shadow:0 24px 60px rgba(16,36,29,.28);display:flex;flex-direction:column;overflow:hidden;z-index:20}
.ai-box header{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:14px 16px;color:#fff;background:linear-gradient(120deg,#7a5af5,#2b8ef0)}
.ai-box header div{display:flex;flex-direction:column}.ai-box header span{font-size:13px;opacity:.9}
.ai-box header button{min-height:44px;min-width:44px;padding:0;border:0;background:rgba(255,255,255,.18);color:#fff;border-radius:12px}
.ai-log{flex:1;overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:10px;background:#f6f7fc}
.ai-msg{max-width:88%;padding:10px 13px;border-radius:16px;white-space:pre-wrap;word-break:break-word;font-size:15px;line-height:1.5}
.ai-msg.assistant{background:#fff;align-self:flex-start;border-start-start-radius:4px;box-shadow:0 1px 2px rgba(16,36,29,.08)}
.ai-msg.user{background:#7a5af5;color:#fff;align-self:flex-end;border-end-end-radius:4px}
.ai-msg.wait{color:var(--muted)}
#ai-form{display:flex;gap:8px;padding:10px;border-top:1px solid var(--line);align-items:flex-end}
#ai-form textarea{min-height:44px;max-height:120px;resize:none}

.ic.c7{background:#e8ecf3;color:#33475b}
.code{background:#10241d;color:#d9fdd3;border-radius:12px;padding:12px 14px;font-family:ui-monospace,Consolas,monospace;font-size:13.5px;line-height:1.6;overflow-x:auto;white-space:pre;text-align:left;margin:0}
.ic.c8{background:#fff0c2;color:#8a5a00}

/* ---------- languages ---------- */
html[dir=rtl] .ph,html[dir=rtl] .line-phone{text-align:right}
html[dir=ltr] .ph,html[dir=ltr] .line-phone{text-align:left}
html[dir=ltr] .bubble{border-radius:0 12px 12px 12px}
select.lang{min-height:44px;margin:4px 0 8px;font-size:14px;background:#f3f6fb;border-color:transparent}
