:root {
    --wa: #25D366;
    --wa-teal: #128C7E;
    --wa-dark: #075E54;
    --wa-soft: #e7f8ee;
    --bg: #f3f5f4;
    --card: #fff;
    --line: #e3e8e6;
    --ink: #1d2b28;
    --muted: #6c7b77;
    --radius: 14px;
}

html, body { background: var(--bg); }
body { font-family: "Tajawal", "Segoe UI", Tahoma, system-ui, sans-serif; color: var(--ink); font-size: 15px; }
[dir="ltr"] body { font-family: "Segoe UI", system-ui, -apple-system, "Tajawal", sans-serif; }
.min-w-0 { min-width: 0; }
.tiny { font-size: 11.5px; }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 228px; flex: 0 0 228px; background: #fff; border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 4px 8px 20px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--wa), var(--wa-teal)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 20px; box-shadow: 0 4px 12px rgba(18, 140, 126, .3); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 16px; }
.brand-text small { color: var(--muted); font-size: 12px; letter-spacing: .3px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: #40504c; text-decoration: none; font-weight: 500; }
.side-nav a:hover { background: #f1f5f3; color: var(--ink); }
.side-nav a.active { background: var(--wa-soft); color: var(--wa-dark); font-weight: 700; }
.side-nav svg, .lang-btn svg, .icon-btn svg, .ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.lang-btn { display: flex; align-items: center; gap: 8px; width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 12px; color: #40504c; }
.lang-btn:hover { background: #f1f5f3; }
.content { flex: 1; min-width: 0; padding: 26px 30px 40px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; font-weight: 800; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

.card-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card-box-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-box-head h2 { font-size: 16px; font-weight: 700; margin: 0; }
.card-box-head a { color: var(--wa-teal); text-decoration: none; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

/* ── Controls ── */
.btn-wa { background: var(--wa-teal); border-color: var(--wa-teal); color: #fff; font-weight: 600; }
.btn-wa:hover, .btn-wa:focus, .btn-wa:active { background: var(--wa-dark) !important; border-color: var(--wa-dark) !important; color: #fff !important; }
.btn-wa:disabled { background: #9dbdb8; border-color: #9dbdb8; }
.btn-wa-soft { background: var(--wa-soft); color: var(--wa-dark); border: 1px solid #cdeedb; font-weight: 600; }
.btn-wa-soft:hover { background: #d6f3e2; color: var(--wa-dark); }
.bg-wa { background: var(--wa) !important; }
.btn .ico { width: 18px; height: 18px; vertical-align: -4px; margin-inline-end: 4px; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--wa); box-shadow: 0 0 0 .2rem rgba(37, 211, 102, .18); }
.form-check-input:checked { background-color: var(--wa-teal); border-color: var(--wa-teal); }
.link-success { color: var(--wa-teal) !important; }
.table { --bs-table-bg: transparent; }
.table thead th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: #fafbfb; white-space: nowrap; }
.progress.thin { height: 6px; }
.chip { background: #f1f5f3; border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; }
.star { color: #f5a623; }
.row-muted td { opacity: .6; }

/* ── Dashboard ── */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset-inline-start: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 4px; background: var(--tone); }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat-label { color: #4b5a56; font-size: 13.5px; margin-top: 4px; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tone-slate { --tone: #64748b; } .tone-teal { --tone: var(--wa-teal); } .tone-green { --tone: var(--wa); }
.tone-amber { --tone: #f59e0b; } .tone-red { --tone: #ef4444; } .tone-blue { --tone: #3b82f6; }
.camp-row { display: block; padding: 12px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.card-box-head + .camp-row { border-top: 0; padding-top: 0; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--wa), var(--wa-teal)); border-radius: 6px 6px 2px 2px; }
.bar-num { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.bar-day { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Status badges ── */
.badge-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef1f0; color: #4b5a56; }
.s-New, .s-Draft, .s-Pending { background: #eef1f0; color: #4b5a56; }
.s-Sent, .s-Completed { background: var(--wa-soft); color: #0f7a3d; }
.s-Running, .s-Sending { background: #dff3f0; color: var(--wa-dark); }
.s-Replied { background: #e0ecff; color: #1d4ed8; }
.s-Interested { background: #dcfce7; color: #15803d; }
.s-NotInterested, .s-Failed, .s-Stopped { background: #fde8e8; color: #b91c1c; }
.s-Paused, .s-Skipped { background: #fef3c7; color: #92400e; }
select.status-select { border-radius: 999px; font-weight: 600; font-size: 12.5px; min-width: 125px; border-color: transparent; }

/* ── Lead finder / leads ── */
.usage-num { font-size: 30px; font-weight: 800; margin: 10px 0 8px; }
.bulk-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 10px; }
.icon-btn { border: 1px solid var(--line); background: #fff; width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; color: #4b5a56; padding: 0; vertical-align: middle; }
.icon-btn:hover { background: #f1f5f3; }
.icon-btn.wa { color: var(--wa-teal); }
.icon-btn.danger:hover { color: #dc2626; border-color: #fecaca; background: #fff5f5; }
.icon-btn:disabled { opacity: .4; }
.icon-btn svg { width: 17px; height: 17px; }

/* ── Overlay & toasts ── */
.busy { position: fixed; inset: 0; background: rgba(243, 245, 244, .78); backdrop-filter: blur(2px); display: none; place-items: center; z-index: 2000; }
.busy.show { display: grid; }
.busy-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 28px; display: flex; align-items: center; gap: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .08); max-width: 90vw; }
#toasts { position: fixed; top: 16px; inset-inline-end: 16px; z-index: 2100; display: flex; flex-direction: column; gap: 8px; }
#toasts .alert { margin: 0; box-shadow: 0 6px 20px rgba(0, 0, 0, .08); min-width: 220px; }

/* ── WhatsApp page ── */
.wa-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.wa-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.wa-pill.on { background: var(--wa-soft); color: #0f7a3d; }
.wa-pill.off { background: #fde8e8; color: #b91c1c; }
.wa-pill.wait { background: #fef3c7; color: #92400e; }
.qr-box { text-align: center; margin-top: 14px; }
.qr-box img { background: #fff; padding: 14px; border: 1px solid var(--line); border-radius: 12px; width: 100%; max-width: 264px; }
.qr-box p { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.camp-list { max-height: 420px; overflow: auto; }
.camp-list .list-group-item { border-color: var(--line); }
.camp-list .list-group-item.active { background: var(--wa-soft); color: var(--ink); border-color: var(--line); box-shadow: inset 3px 0 0 var(--wa-teal); }
[dir="rtl"] .camp-list .list-group-item.active { box-shadow: inset -3px 0 0 var(--wa-teal); }
.controls { display: flex; gap: 6px; flex-wrap: wrap; }
.ctl { border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 800; letter-spacing: .5px; font-size: 13px; color: #fff; }
.ctl-start { background: var(--wa-teal); } .ctl-pause { background: #f59e0b; } .ctl-resume { background: #0ea5e9; } .ctl-stop { background: #ef4444; }
.ctl:disabled { background: #dde3e1; color: #8b9894; }
.counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.counters div { background: #f7f9f8; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.counters b { display: block; font-size: 20px; line-height: 1.15; }
.counters span { font-size: 12px; color: var(--muted); }
.live-line { font-size: 14px; color: var(--wa-dark); font-weight: 600; min-height: 21px; }
.nav-tabs { border-bottom-color: var(--line); }
.nav-tabs .nav-link { color: #4b5a56; font-weight: 600; }
.nav-tabs .nav-link.active { color: var(--wa-dark); border-color: var(--line) var(--line) #fff; }
.tabs-body { border-top: 0; border-start-start-radius: 0; border-start-end-radius: 0; }
.msg-pills .nav-link { padding: 5px 12px; font-size: 13.5px; color: #4b5a56; border-radius: 8px; background: #f1f5f3; }
.msg-pills .nav-link.active { background: var(--wa-teal); color: #fff; }
.msg-area { font-size: 15px; line-height: 1.7; min-height: 250px; }
.var-chip { border: 1px dashed #a7d9c4; background: var(--wa-soft); color: var(--wa-dark); border-radius: 8px; padding: 2px 9px; font-size: 13px; font-family: Consolas, monospace; }
.wa-preview { background: #efe7dd; border-radius: 12px; padding: 14px; min-height: 140px; }
.wa-bubble { background: #d9fdd3; border-radius: 10px; padding: 8px 11px; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); font-size: 14px; }
.log-wrap { max-height: 520px; overflow: auto; }
.log-table td { font-size: 13.5px; }
.log-table .err { font-size: 11.5px; color: #b91c1c; max-width: 280px; white-space: normal; }
.log-table .warn { font-size: 11.5px; color: #92400e; max-width: 280px; white-space: normal; }
.btn-x { border: 0; background: transparent; color: #9aa6a3; font-size: 20px; line-height: 1; padding: 0 6px; }
.btn-x:hover { color: #dc2626; }
.filter-pills .btn { font-size: 12.5px; padding: 3px 10px; }
.filter-pills .btn.active { background: var(--wa-teal); color: #fff; border-color: var(--wa-teal) !important; }
.setting-group { border: 1px solid var(--line); border-radius: 12px; padding: 14px; height: 100%; }
.setting-group h3 { font-size: 14px; font-weight: 700; margin: 0 0 10px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }

/* ── Small screens: the sidebar becomes a top bar ── */
@media (max-width: 991.98px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; z-index: 1000; flex-direction: row; align-items: center; padding: 8px 10px; gap: 8px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
    .brand { padding: 0; }
    .brand-text { display: none; }
    .side-nav { flex-direction: row; overflow-x: auto; flex: 1; }
    .side-nav a { padding: 8px 10px; white-space: nowrap; font-size: 13.5px; gap: 6px; }
    .side-foot { margin: 0; }
    .lang-btn { padding: 7px; }
    .lang-btn span { display: none; }
    .content { padding: 16px; }
}
@media (max-width: 575.98px) {
    .side-nav a span { display: none; }
    .page-head h1 { font-size: 21px; }
}
