:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #f1f5f9;
  --brand: #0f766e;
  --brand-2: #115e59;
  --brand-soft: #e6f4f2;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Nastaliq Urdu", sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #0b1f1d; color: #cbd5e1; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 20px; }
.logo .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #cbd5e1; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side .foot { margin-top: auto; padding: 12px; font-size: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side .foot b { color: #fff; display: block; font-size: 13px; margin-bottom: 2px; }
.side .foot button { margin-top: 10px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }

/* ---------- panels ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi { padding: 16px 18px; }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.kpi .val { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.two { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--line-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.lg { padding: 11px 20px; font-size: 15px; }
.btn svg { width: 16px; height: 16px; }
.side .btn { background: transparent; color: #cbd5e1; border-color: rgba(255, 255, 255, .15); width: 100%; }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 118, 110, .25); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--brand); padding: 0; cursor: pointer; }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
label.f { display: block; }
.f > span:first-child { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; min-width: 140px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #f8fafc; }
.t tr.sel td { background: var(--brand-soft) !important; }
.t .chk { width: 36px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 16px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 14px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-paid, .b-sent, .b-delivered, .b-active { background: var(--ok-soft); color: var(--ok); }
.b-unpaid, .b-failed { background: var(--danger-soft); color: var(--danger); }
.b-partial, .b-queued, .b-sending, .b-overdue { background: var(--warn-soft); color: var(--warn); }
.b-cancelled, .b-inactive, .b-none { background: var(--line-2); color: var(--muted); }
.b-info { background: var(--info-soft); color: var(--info); }

#cBulk, #iBulk { position: sticky; bottom: 16px; z-index: 5; }
.bulkbar { margin-top: 14px; background: #0b1f1d; color: #fff; border-radius: 12px; padding: 10px 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); z-index: 5; }
.bulkbar .btn { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .15); }
.bulkbar .btn.primary { background: var(--brand); border-color: var(--brand); }
.bulkbar .btn.danger { color: #fca5a5; }

.progress { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; display: flex; }
.progress > i { display: block; height: 100%; }
.progress .p-ok { background: #22c55e; }
.progress .p-fail { background: #ef4444; }
.progress .p-q { background: #f59e0b; opacity: .35; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 920px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 14px 14px; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }

#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 380px; animation: slide .2s ease-out; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-hero { background: linear-gradient(150deg, #0b1f1d, #0f766e); color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: center; }
.auth-hero h1 { font-size: 34px; line-height: 1.2; margin: 18px 0 14px; }
.auth-hero p { color: #ccfbf1; font-size: 16px; line-height: 1.6; max-width: 460px; }
.auth-hero ul { padding: 0; list-style: none; margin-top: 24px; }
.auth-hero li { padding: 6px 0; color: #e6fffa; }
.auth-hero li::before { content: '✓  '; color: #5eead4; font-weight: 700; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-form .card { width: 100%; max-width: 400px; padding: 28px; }
.tabs { display: flex; gap: 4px; background: var(--line-2); padding: 4px; border-radius: 10px; margin-bottom: 20px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 7px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-hero { display: none; } .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } }

/* ---------- composer / wizard ---------- */
.steps { display: flex; gap: 0; margin-bottom: 18px; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 3px solid var(--line); color: var(--muted); font-weight: 600; }
.step .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--line); color: var(--ink-2); font-size: 12px; }
.step.on { border-color: var(--brand); color: var(--ink); }
.step.on .n { background: var(--brand); color: #fff; }
.step.done .n { background: var(--ok); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px dashed #94a3b8; background: #f8fafc; border-radius: 6px; padding: 3px 8px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.counter { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.counter b { color: var(--ink); }
.phone { background: #e5ddd5; border-radius: 14px; padding: 16px; }
.bubble { background: #fff; border-radius: 10px 10px 10px 2px; padding: 10px 12px; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); white-space: pre-wrap; word-wrap: break-word; margin-bottom: 10px; line-height: 1.45; }
.bubble .to { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.opt { border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: block; background: #fff; }
.opt:hover { border-color: #94a3b8; }
.opt.on { border-color: var(--brand); background: var(--brand-soft); }
.opt b { display: block; margin-bottom: 3px; }
.opt .tag { float: right; }
.callout { border-radius: 10px; padding: 12px 14px; background: var(--info-soft); color: #1e3a8a; line-height: 1.55; }
.callout.warn { background: var(--warn-soft); color: #78350f; }
.callout.ok { background: var(--ok-soft); color: #14532d; }
.callout ol, .callout ul { margin: 6px 0 0; padding-left: 20px; }
.sheet-card { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.sheet-card .hd { background: #fafbfc; padding: 10px 14px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px 14px; }
.map-grid label span { font-size: 11px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 3px; text-transform: uppercase; }
.preview-t { font-size: 12px; }
.preview-t td, .preview-t th { padding: 6px 10px; }
.bars { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding: 10px 4px 0; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .pair i { width: 40%; max-width: 22px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .lab { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.list-row { display: flex; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line-2); }
.list-row:last-child { border-bottom: 0; }
/* ---------- template studio (Settings) ---------- */
.tpl-card { --accent: #0f766e; overflow: hidden; }
.tpl-head { display: flex; gap: 14px; align-items: center; padding: 18px 20px; background: linear-gradient(120deg, #f0fdfa, #fff 60%); border-bottom: 1px solid var(--line); }
.tpl-head-ic { width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(15, 118, 110, .25); }
.tpl-head-ic svg { width: 20px; height: 20px; }
.tpl-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 10px; padding: 16px 20px 0; }
.tpl-tab { display: flex; align-items: center; gap: 10px; text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; cursor: pointer; font: inherit; color: var(--ink); transition: border-color .15s, box-shadow .15s, transform .15s; }
.tpl-tab:hover { border-color: #cbd5e1; transform: translateY(-1px); }
.tpl-tab.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.tpl-tab-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, #fff); }
.tpl-tab.on .tpl-tab-ic { background: var(--accent); color: #fff; }
.tpl-tab-ic svg { width: 17px; height: 17px; }
.tpl-tab-txt { flex: 1; min-width: 0; line-height: 1.25; }
.tpl-tab-txt b { display: block; font-size: 14px; }
.tpl-tab-txt small { color: var(--muted); font-size: 12px; }
.tpl-tab-seg { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--line-2); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.tpl-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; padding: 20px; align-items: start; }
@media (max-width: 980px) { .tpl-body { grid-template-columns: 1fr; } .tpl-tabs { grid-template-columns: 1fr; } }
.tpl-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.tpl-label > span:first-child { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .5px; }
.tpl-textarea { min-height: 150px; font-size: 15px; line-height: 1.6; padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--line); background: #fcfcfd; transition: border-color .15s, box-shadow .15s, background .15s; }
.tpl-textarea:focus { outline: none; background: #fff; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); }
.tpl-meter { margin-top: 10px; }
.tpl-bar { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.tpl-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .2s ease, background .2s; }
.tpl-bar i.warm { background: #f59e0b; }
.tpl-bar i.hot { background: #ef4444; }
.tpl-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.tpl-stats b { color: var(--ink); }
.tpl-pill { background: color-mix(in srgb, var(--accent) 10%, #fff); color: var(--accent); font-weight: 600; padding: 2px 9px; border-radius: 99px; }
.tpl-warn, .tpl-warn b { color: #b45309; }
.tpl-fields { display: flex; flex-wrap: wrap; gap: 8px; }
.tpl-field { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px 10px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; transition: all .15s; }
.tpl-field code { background: var(--line-2); color: var(--muted); font-size: 11px; padding: 1px 6px; border-radius: 6px; transition: all .15s; }
.tpl-field:hover { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, #fff); transform: translateY(-1px); }
.tpl-field:hover code { background: var(--accent); color: #fff; }
.tpl-phone-wrap { position: sticky; top: 20px; }
.tpl-phone { width: 280px; margin: 0 auto; background: #0f172a; border-radius: 38px; padding: 12px; box-shadow: 0 24px 50px rgba(15, 23, 42, .28), inset 0 0 0 2px #334155; position: relative; }
.tpl-notch { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: 90px; height: 22px; background: #0f172a; border-radius: 0 0 14px 14px; z-index: 2; }
.tpl-screen { background: linear-gradient(180deg, #f8fafc, #eef2f7); border-radius: 28px; min-height: 420px; padding: 38px 14px 18px; display: flex; flex-direction: column; }
.tpl-topbar { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid #e2e8f0; }
.tpl-topbar b { display: block; font-size: 13px; }
.tpl-topbar small { color: var(--muted); font-size: 11px; }
.tpl-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.tpl-day { align-self: center; font-size: 11px; color: var(--muted); background: #e2e8f0; padding: 2px 10px; border-radius: 99px; margin: 14px 0 10px; }
.tpl-bubble { align-self: flex-start; max-width: 92%; background: #fff; border-radius: 18px 18px 18px 6px; padding: 10px 13px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 2px rgba(15, 23, 42, .08); animation: pop .2s ease-out; }
.tpl-bubble mark { background: color-mix(in srgb, var(--accent) 14%, #fff); color: inherit; font-weight: 600; border-radius: 4px; padding: 0 2px; }
.tpl-bubble mark.bad { background: #fee2e2; color: var(--danger); }
.tpl-time { font-size: 10px; color: var(--muted); margin: 4px 0 0 6px; }
/* composer (send window) reuses the studio styles */
.modal.wide:has(.cmp) { max-width: 1060px; }
.tpl-card.cmp { box-shadow: none; overflow: visible; }
.tpl-card.cmp .tpl-body { grid-template-columns: minmax(0, 1fr) 290px; }
.tpl-card.cmp .tpl-tabs { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tpl-card.cmp .tpl-textarea { min-height: 130px; }
.tpl-phone.sm { width: 270px; }
.tpl-phone.sm .tpl-screen { min-height: 340px; }
.tpl-topbar b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-nav { margin-top: auto; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); }
.cmp-nav .btn { padding: 2px 10px; border-radius: 99px; }
.cmp-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cmp-kpis > div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; text-align: center; }
.cmp-kpis small { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
.cmp-kpis b { font-size: 17px; font-variant-numeric: tabular-nums; }
.cmp-skip { margin-top: 8px; font-size: 12px; }
.cmp-skip summary { color: #b45309; cursor: pointer; font-weight: 600; }
.cmp-skip > div { max-height: 130px; overflow: auto; margin-top: 6px; line-height: 1.7; }
@media (max-width: 900px) { .tpl-card.cmp .tpl-body { grid-template-columns: 1fr; } }
/* message-type pills on the Bulk SMS page */
.type-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.type-pill { --accent: #0f766e; display: inline-flex; align-items: center; gap: 7px; border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px 6px 9px; font: inherit; font-size: 13px; font-weight: 550; color: var(--ink-2); cursor: pointer; transition: all .15s; }
.type-pill svg { width: 15px; height: 15px; color: var(--accent); }
.type-pill:hover { border-color: var(--accent); }
.type-pill.on { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent); }
.type-pill.on svg { color: #fff; }
@keyframes pop { from { transform: scale(.97); opacity: .6; } }

kbd, code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
