:root {
  --navy: #0f172a; --navy-2: #1e293b; --ink: #0b1220;
  --blue: #2563eb; --blue-2: #3b82f6; --sky: #60a5fa; --blue-soft: #eff6ff;
  --bg: #f6f8fc; --card: #fff; --line: #e2e8f0; --muted: #64748b; --text: #0f172a;
  --green: #16a34a; --green-soft: #dcfce7; --red: #dc2626; --red-soft: #fee2e2; --amber: #d97706; --amber-soft: #fef3c7;
  --r: 14px; --shadow: 0 1px 2px rgb(15 23 42 / .05), 0 8px 24px -12px rgb(15 23 42 / .15);
  --ease: cubic-bezier(.22, 1, .36, 1);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font: 500 14px/1.5 'Manrope', system-ui, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: 'Sora', sans-serif; margin: 0; letter-spacing: -.02em; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }

/* boot + spinner */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 99; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner.lg { width: 34px; height: 34px; border-width: 3px; color: var(--blue); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 50%, #eef2f7 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: #fff; padding: 9px 16px; border-radius: 10px; font-weight: 600; cursor: pointer; transition: transform .15s var(--ease), box-shadow .2s, background .2s, border-color .2s; white-space: nowrap; }
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px -8px rgb(15 23 42 / .3); border-color: #cbd5e1; }
.btn:active:not(:disabled) { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--blue-2), var(--blue)); border-color: var(--blue); color: #fff; box-shadow: 0 6px 18px -8px rgb(37 99 235 / .7); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--red); }
.btn.danger:hover:not(:disabled) { background: var(--red-soft); border-color: #fecaca; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.block { width: 100%; padding: 12px; }

/* form */
label.f { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
label.f small { font-weight: 500; color: var(--muted); }
.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; transition: border-color .2s, box-shadow .2s; outline: 0; }
.input:focus { border-color: var(--blue-2); box-shadow: 0 0 0 4px rgb(59 130 246 / .15); }
textarea.input { resize: vertical; min-height: 140px; line-height: 1.55; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 600; }
input[type=checkbox] { accent-color: var(--blue); width: 16px; height: 16px; cursor: pointer; }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; overflow: hidden; background: var(--navy); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; isolation: isolate; }
.login-art::before, .login-art::after { content: ''; position: absolute; border-radius: 50%; filter: blur(70px); z-index: -1; animation: float 14s ease-in-out infinite alternate; }
.login-art::before { width: 520px; height: 520px; background: #2563eb; top: -140px; right: -120px; opacity: .65; }
.login-art::after { width: 420px; height: 420px; background: #0ea5e9; bottom: -160px; left: -100px; opacity: .4; animation-delay: -6s; }
@keyframes float { to { transform: translate(-60px, 50px) scale(1.15); } }
.grid-bg { position: absolute; inset: 0; z-index: -1; background-image: linear-gradient(rgb(255 255 255 / .05) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / .05) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(circle at 30% 40%, #000, transparent 75%); }
.login-art h1 { font-size: clamp(30px, 3.6vw, 48px); line-height: 1.08; font-weight: 800; max-width: 520px; }
.login-art h1 em { font-style: normal; background: linear-gradient(90deg, #93c5fd, #38bdf8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-art p { color: #cbd5e1; max-width: 440px; margin: 16px 0 0; font-size: 15px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { padding: 7px 13px; border: 1px solid rgb(255 255 255 / .18); border-radius: 99px; background: rgb(255 255 255 / .06); backdrop-filter: blur(6px); font-size: 13px; }
.login-form-wrap { display: grid; place-items: center; padding: 32px; background: #fff; }
.login-form { width: min(400px, 100%); display: grid; gap: 18px; animation: rise .6s var(--ease) both; }
.login-form h2 { font-size: 26px; }
.logo { display: flex; align-items: center; gap: 10px; font-family: 'Sora'; font-weight: 700; font-size: 17px; }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; overflow: hidden; box-shadow: 0 6px 16px -6px rgb(37 99 235 / .8); }
.logo-mark img { width: 100%; height: 100%; display: block; }
.alert { padding: 10px 12px; border-radius: 10px; background: var(--red-soft); color: #991b1b; font-weight: 600; font-size: 13px; animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* shell */
.top { position: sticky; top: 0; z-index: 20; background: rgb(255 255 255 / .85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; gap: 28px; }
.tabs { display: flex; gap: 4px; position: relative; flex: 1; }
.tab { position: relative; padding: 8px 14px; border: 0; background: none; font-weight: 700; color: var(--muted); cursor: pointer; border-radius: 9px; transition: color .2s, background .2s; display: flex; gap: 8px; align-items: center; }
.tab:hover { color: var(--text); background: #f1f5f9; }
.tab.on { color: var(--blue); background: var(--blue-soft); }
.tab .dot { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--blue); color: #fff; font-size: 11px; display: grid; place-items: center; animation: pop .3s var(--ease); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.who b { color: var(--text); }
main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; }
.view { animation: rise .45s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { from { transform: scale(0); } }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head h2 { font-size: 24px; }
.head p { margin: 4px 0 0; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.pad { padding: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.stack { display: grid; gap: 16px; }

/* channels */
.channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-bottom: 24px; }
.ch { padding: 16px; cursor: pointer; transition: transform .25s var(--ease), border-color .2s, box-shadow .25s; position: relative; overflow: hidden; animation: rise .45s var(--ease) both; }
.ch:hover { transform: translateY(-3px); border-color: #bfdbfe; }
.ch.on { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgb(59 130 246 / .18), var(--shadow); }
.ch.on::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(var(--sky), var(--blue)); }
.ch h3 { font-size: 16px; }
.ch .num { font-size: 13px; color: var(--muted); }
.ch-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.stat { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.stat b { color: var(--text); font-size: 15px; display: block; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #f1f5f9; color: #475569; }
.badge.ok { background: var(--green-soft); color: #166534; }
.badge.no { background: var(--red-soft); color: #991b1b; }
.badge.blue { background: var(--blue-soft); color: #1d4ed8; }
.badge.warn { background: var(--amber-soft); color: #92400e; }
.badge.pulse::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* table */
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px; border-bottom: 1px solid var(--line); align-items: center; }
.filters .input { width: auto; min-width: 150px; }
.filters .search { flex: 1; min-width: 220px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 11px 16px; background: #f8fafc; border-bottom: 1px solid var(--line); }
td { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr { transition: background .15s; animation: rise .35s var(--ease) both; }
tbody tr:hover { background: #f8fbff; }
tbody tr.sel { background: var(--blue-soft); }
.foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
.pager { display: flex; gap: 4px; align-items: center; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; stroke: #cbd5e1; fill: none; stroke-width: 1.5; margin-bottom: 10px; }

/* templates */
.tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tpl { padding: 16px; display: grid; gap: 12px; transition: transform .25s var(--ease), border-color .2s; animation: rise .45s var(--ease) both; }
.tpl:hover { transform: translateY(-3px); border-color: #bfdbfe; }
.tpl p { margin: 0; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; min-height: 63px; }
.editor { display: grid; grid-template-columns: 1fr 340px; gap: 24px; }
.drop { border: 1.5px dashed #cbd5e1; border-radius: 12px; padding: 16px; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; color: var(--muted); }
.drop:hover, .drop.over { border-color: var(--blue-2); background: var(--blue-soft); color: var(--blue); }
.fmt { display: flex; gap: 6px; }
.fmt button { width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-weight: 800; transition: background .15s; }
.fmt button:hover { background: var(--blue-soft); }

/* WhatsApp preview */
.phone { background: #0b141a; border-radius: 28px; padding: 10px; box-shadow: 0 24px 50px -20px rgb(15 23 42 / .5); position: sticky; top: 86px; }
.phone-screen { border-radius: 20px; overflow: hidden; background: #efe7dd; min-height: 380px; display: flex; flex-direction: column; }
.phone-bar { background: #075e54; color: #fff; padding: 10px 14px; display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 14px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #25d366; display: grid; place-items: center; font-size: 12px; }
.chat { flex: 1; padding: 16px 12px; background-image: radial-gradient(#d9cfc2 1px, transparent 1px); background-size: 14px 14px; display: flex; align-items: flex-start; }
.bubble { max-width: 92%; margin-left: auto; background: #d9fdd3; border-radius: 10px 0 10px 10px; padding: 6px 8px 4px; box-shadow: 0 1px 1px rgb(0 0 0 / .13); font-size: 13.5px; color: #111b21; white-space: pre-wrap; word-break: break-word; animation: pop .35s var(--ease); transform-origin: top right; }
.bubble img, .bubble video { width: 100%; border-radius: 7px; display: block; margin-bottom: 6px; max-height: 220px; object-fit: cover; }
.bubble .doc { display: flex; gap: 8px; align-items: center; background: rgb(0 0 0 / .06); padding: 8px; border-radius: 7px; margin-bottom: 6px; font-size: 12.5px; }
.bubble .time { text-align: right; font-size: 11px; color: #667781; margin-top: 2px; }
.bubble .ph { color: #667781; font-style: italic; }
.bubble code { background: rgb(0 0 0 / .07); padding: 0 3px; border-radius: 3px; }

/* campaigns */
.camps { display: grid; gap: 14px; }
.camp { padding: 18px; display: grid; gap: 14px; animation: rise .45s var(--ease) both; }
.bar { height: 9px; border-radius: 9px; background: #eef2f7; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; transition: width .6s var(--ease); }
.bar .s { background: linear-gradient(90deg, #22c55e, #16a34a); }
.bar .e { background: #ef4444; }
.bar.run .s { background-image: linear-gradient(110deg, #22c55e 30%, #4ade80 50%, #22c55e 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.wizard { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.steps { display: grid; gap: 20px; }
.step-h { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; font-family: 'Sora'; font-weight: 700; }
.step-h span { width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 13px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgb(15 23 42 / .55); backdrop-filter: blur(4px); z-index: 50; display: grid; place-items: center; padding: 20px; animation: fade .2s; overflow: auto; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 18px; width: min(960px, 100%); max-height: 94vh; overflow: auto; animation: rise .35s var(--ease); box-shadow: 0 30px 80px -20px rgb(15 23 42 / .5); }
.modal.sm { width: min(560px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-b { padding: 22px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 100; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 14px 30px -10px rgb(0 0 0 / .5); animation: slideIn .35s var(--ease); max-width: 360px; display: flex; gap: 10px; align-items: center; font-weight: 600; }
.toast.err { background: #991b1b; }
.toast.ok { background: #166534; }
.toast.out { opacity: 0; transform: translateX(30px); transition: .3s; }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; } .login-art { display: none; }
  .editor, .wizard { grid-template-columns: 1fr; } .phone { position: static; }
  .who span { display: none; } .top-in { gap: 10px; padding: 0 12px; } .tab span.lbl { display: none; }
  main { padding: 20px 12px 60px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
