/* =========================================================
   Message Box — design system
   Brand: logo blue + logo orange, WhatsApp green for "send"
   ========================================================= */
:root {
    --mb-primary: #2E3BD1;
    --mb-primary-600: #2531B4;
    --mb-primary-700: #1E2799;
    --mb-primary-50: #EEF0FF;
    --mb-navy: #10165C;
    --mb-navy-2: #1A2280;
    --mb-accent: #F5761F;
    --mb-accent-600: #E0620C;
    --mb-accent-50: #FFF2E8;
    --mb-wa: #25D366;
    --mb-wa-dark: #128C7E;
    --mb-wa-50: #E7F9EF;
    --mb-danger: #E5484D;
    --mb-danger-50: #FDECEC;
    --mb-warning: #F5A524;

    --st-sent: #8592A6;
    --st-delivered: #2E3BD1;
    --st-read: #1FAF5A;
    --st-failed: #E5484D;
    --st-queued: #B3BCCB;

    --bg: #F4F6FB;
    --surface: #FFFFFF;
    --surface-2: #F8F9FD;
    --border: #E4E7F0;
    --text: #151A33;
    --text-2: #4A5270;
    --muted: #7C849E;
    --shadow-sm: 0 1px 2px rgba(16, 22, 92, .06), 0 1px 3px rgba(16, 22, 92, .05);
    --shadow: 0 8px 24px rgba(16, 22, 92, .08);
    --shadow-lg: 0 18px 50px rgba(16, 22, 92, .16);
    --radius: 16px;
    --radius-sm: 10px;
    --sidebar-w: 268px;
    --topbar-h: 68px;
    --bottom-h: 64px;
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
    --bg: #0C1024;
    --surface: #141A36;
    --surface-2: #1A2142;
    --border: #262E55;
    --text: #E8EBF7;
    --text-2: #B5BCD6;
    --muted: #8189A8;
    --mb-primary-50: #1C2459;
    --mb-accent-50: #3A2414;
    --mb-wa-50: #10301F;
    --mb-danger-50: #3A1517;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
    --st-delivered: #6F7BFF;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.mb-app {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: var(--mb-primary); text-decoration: none; }
[data-theme="dark"] a:not(.btn) { color: #8E98FF; }
::selection { background: var(--mb-accent); color: #fff; }

/* ---------------- Sidebar ---------------- */
.mb-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--mb-navy) 0%, #0B1046 100%);
    color: #C9CEF2; display: flex; flex-direction: column; z-index: 1040;
    transition: transform .28s ease;
}
.mb-brand {
    display: flex; align-items: center; gap: 12px; padding: 18px 20px 16px;
    color: #fff !important; border-bottom: 1px solid rgba(255,255,255,.08);
}
.mb-brand-logo {
    width: 48px; height: 48px; border-radius: 14px; background: #fff; flex-shrink: 0;
    display: grid; place-items: center; overflow: hidden; box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.mb-brand-logo img { width: 42px; height: 42px; object-fit: contain; }
.mb-brand-text { font-size: 19px; font-weight: 500; line-height: 1.1; letter-spacing: -.01em; }
.mb-brand-text b { font-weight: 800; color: var(--mb-accent); }
.mb-brand-text small { display: block; font-size: 11px; color: #8F96D6; font-weight: 500; letter-spacing: .04em; margin-top: 3px; text-transform: uppercase; }

.mb-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.mb-nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: #6E76BD; font-weight: 700; padding: 12px 12px 4px; }
.mb-nav-link {
    display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin: 1px 0;
    border-radius: 11px; color: #C9CEF2 !important; font-weight: 500; font-size: 14.5px;
    transition: background .15s, color .15s; position: relative;
}
.mb-nav-link i { width: 20px; text-align: center; font-size: 15px; opacity: .85; }
.mb-nav-link:hover { background: rgba(255,255,255,.07); color: #fff !important; }
.mb-nav-link.active { background: linear-gradient(90deg, rgba(245,118,31,.22), rgba(245,118,31,.06)); color: #fff !important; font-weight: 600; }
.mb-nav-link.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--mb-accent); }
.mb-nav-link.active i { color: var(--mb-accent); opacity: 1; }

.mb-sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.mb-credit-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06); margin-bottom: 6px; }
.mb-credit-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--mb-accent); color: #fff; }
.mb-credit-label { font-size: 12px; color: #8F96D6; }
.mb-credit-value { font-size: 18px; font-weight: 800; color: #fff; line-height: 1.1; }
.mb-logout:hover { background: rgba(229,72,77,.18) !important; }

.mb-backdrop { display: none; }

/* ---------------- Main / topbar ---------------- */
.mb-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.mb-topbar {
    position: sticky; top: 0; z-index: 1020; height: var(--topbar-h);
    display: flex; align-items: center; gap: 14px; padding: 0 28px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}
.mb-topbar-logo img { height: 38px; width: 38px; object-fit: contain; border-radius: 10px; background: #fff; padding: 2px; }
.mb-topbar-title { min-width: 0; flex: 1; }
.mb-topbar-title h1 { font-size: 20px; font-weight: 800; margin: 0; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.mb-topbar-title p { margin: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-topbar-right { display: flex; align-items: center; gap: 10px; }
.mb-icon-btn {
    width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-2); display: grid; place-items: center; cursor: pointer; transition: .15s;
}
.mb-icon-btn:hover { border-color: var(--mb-primary); color: var(--mb-primary); }
.mb-chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 600; }
.mb-chip-credits { background: var(--mb-accent-50); color: var(--mb-accent-600) !important; border: 1px solid rgba(245,118,31,.25); }
.mb-chip-credits b { font-weight: 800; }
.mb-avatar-btn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--text); padding: 4px; border-radius: 999px; }
.mb-avatar {
    width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
    background: linear-gradient(135deg, var(--mb-primary), var(--mb-navy-2)); color: #fff; font-weight: 700; font-size: 14px;
}
.mb-avatar-name { font-weight: 600; font-size: 14px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-dropdown { border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; background: var(--surface); min-width: 230px; }
.mb-dropdown .dropdown-item { border-radius: 9px; padding: 9px 12px; color: var(--text); font-weight: 500; }
.mb-dropdown .dropdown-item:hover { background: var(--surface-2); }

.mb-content { padding: 26px 28px 40px; flex: 1; width: 100%; max-width: 1440px; }
.mb-page-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin: -6px 0 18px; }
.mb-footer { display: flex; justify-content: space-between; gap: 10px; padding: 18px 28px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); }

/* ---------------- Bottom nav (mobile) ---------------- */
.mb-bottom-nav { display: none; }

/* ---------------- Cards ---------------- */
.mb-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 22px; position: relative;
}
.mb-card + .mb-card { margin-top: 20px; }
.mb-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.mb-card-title { font-size: 16.5px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 10px; color: var(--text); }
.mb-card-title .mb-step {
    width: 28px; height: 28px; border-radius: 50%; background: var(--mb-primary); color: #fff;
    display: inline-grid; place-items: center; font-size: 13px; font-weight: 800;
}
.mb-card-sub { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; }

/* Hero banner */
.mb-hero {
    position: relative; overflow: hidden; border-radius: 20px; padding: 26px 28px; color: #fff;
    background: radial-gradient(circle at 92% 10%, rgba(245,118,31,.55), transparent 42%),
                linear-gradient(120deg, var(--mb-navy) 0%, var(--mb-primary-700) 55%, var(--mb-primary) 100%);
    box-shadow: var(--shadow);
}
.mb-hero h2 { font-size: 24px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.02em; }
.mb-hero p { margin: 0; color: rgba(255,255,255,.82); }
.mb-hero .mb-hero-art {
    position: absolute; right: 34px; top: 50%; width: 118px; height: 118px; place-items: center;
    background: #fff; border-radius: 30px; transform: translateY(-50%) rotate(-6deg);
    box-shadow: 0 18px 40px rgba(0,0,0,.35), 0 0 0 8px rgba(255,255,255,.1);
}
.mb-hero .mb-hero-art img { width: 98px; height: 98px; object-fit: contain; }
.mb-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* Stat tiles */
.mb-stat { display: flex; gap: 14px; align-items: center; padding: 18px; }
.mb-stat-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 19px; flex-shrink: 0; }
.mb-stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.mb-stat-value { font-size: 26px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; color: var(--text); }
.mb-stat-foot { font-size: 12.5px; color: var(--muted); }
.tone-primary { background: var(--mb-primary-50); color: var(--mb-primary); }
.tone-accent  { background: var(--mb-accent-50); color: var(--mb-accent); }
.tone-wa      { background: var(--mb-wa-50); color: var(--mb-wa-dark); }
.tone-danger  { background: var(--mb-danger-50); color: var(--mb-danger); }
.tone-muted   { background: var(--surface-2); color: var(--text-2); }
[data-theme="dark"] .tone-wa { color: var(--mb-wa); }

/* ---------------- Buttons ---------------- */
.btn { font-weight: 600; border-radius: 12px; padding: 9px 16px; font-size: 14.5px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-lg { padding: 13px 22px; font-size: 16px; border-radius: 14px; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn-primary { background: var(--mb-primary); border-color: var(--mb-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--mb-primary-700); border-color: var(--mb-primary-700); }
.btn-accent { background: var(--mb-accent); border: 1px solid var(--mb-accent); color: #fff; }
.btn-accent:hover, .btn-accent:focus { background: var(--mb-accent-600); border-color: var(--mb-accent-600); color: #fff; }
.btn-wa { background: linear-gradient(135deg, var(--mb-wa), var(--mb-wa-dark)); border: 0; color: #fff; box-shadow: 0 8px 20px rgba(37,211,102,.32); }
.btn-wa:hover, .btn-wa:focus { color: #fff; filter: brightness(1.05); transform: translateY(-1px); }
.btn-soft { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-soft:hover { border-color: var(--mb-primary); color: var(--mb-primary); background: var(--surface); }
.btn-light-glass { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.28); }
.btn-light-glass:hover { background: rgba(255,255,255,.24); color: #fff; }
.btn-outline-danger { border-radius: 12px; }

/* ---------------- Forms ---------------- */
.form-label { font-weight: 600; font-size: 13.5px; color: var(--text-2); margin-bottom: 6px; }
.form-control, .form-select {
    border-radius: 12px; border: 1.5px solid var(--border); padding: 10px 14px; font-size: 15px;
    background-color: var(--surface); color: var(--text);
}
.form-control::placeholder { color: var(--muted); opacity: .8; }
.form-control:focus, .form-select:focus { border-color: var(--mb-primary); box-shadow: 0 0 0 4px rgba(46,59,209,.13); background-color: var(--surface); color: var(--text); }
.form-select-lg, .form-control-lg { padding: 12px 16px; font-size: 16px; }
.form-check-input:checked { background-color: var(--mb-primary); border-color: var(--mb-primary); }
.form-check-input { cursor: pointer; }
.form-text { color: var(--muted); }
textarea.form-control { line-height: 1.5; }
.mb-input-icon { position: relative; }
.mb-input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.mb-input-icon > .form-control { padding-left: 40px; }

/* ---------------- Tabs (segmented) ---------------- */
.mb-tabs { display: flex; gap: 6px; padding: 5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; overflow-x: auto; scrollbar-width: none; }
.mb-tabs::-webkit-scrollbar { display: none; }
.mb-tab { flex: 1 0 auto; min-width: 0; border: 0; background: transparent; padding: 9px 14px; border-radius: 10px; font-weight: 600; color: var(--text-2); font-size: 14px; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.mb-tab .mb-count { background: var(--border); color: var(--text-2); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.mb-tab.active { background: var(--surface); color: var(--mb-primary); box-shadow: var(--shadow-sm); }
.mb-tab.active .mb-count { background: var(--mb-primary); color: #fff; }
.mb-tab-pane { display: none; padding-top: 16px; }
.mb-tab-pane.active { display: block; animation: mbFade .2s ease; }
@keyframes mbFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- Badges ---------------- */
.mb-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.mb-badge i { font-size: 11px; }
.mb-badge-secondary { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.mb-badge-info { background: var(--mb-primary-50); color: var(--mb-primary); }
.mb-badge-sent { background: rgba(133,146,166,.15); color: #5B6679; }
.mb-badge-delivered { background: var(--mb-primary-50); color: var(--st-delivered); }
.mb-badge-read { background: var(--mb-wa-50); color: var(--st-read); }
.mb-badge-failed, .mb-badge-danger { background: var(--mb-danger-50); color: var(--mb-danger); }
.mb-badge-success { background: var(--mb-wa-50); color: var(--st-read); }
.mb-badge-warning { background: var(--mb-accent-50); color: var(--mb-accent-600); }
[data-theme="dark"] .mb-badge-sent { color: #AEB8CA; }
.mb-badge-info .fa-paper-plane, .mb-badge-info .fa-spinner { animation: mbPulse 1.4s ease-in-out infinite; }
@keyframes mbPulse { 50% { opacity: .35; } }

/* ---------------- Alerts ---------------- */
.mb-alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; margin-bottom: 18px; font-weight: 500; border: 1px solid transparent; }
.mb-alert > i { margin-top: 3px; }
.mb-alert > div { flex: 1; }
.mb-alert-success { background: var(--mb-wa-50); color: #12693A; border-color: rgba(37,211,102,.3); }
.mb-alert-danger { background: var(--mb-danger-50); color: #A1272B; border-color: rgba(229,72,77,.3); }
.mb-alert-info { background: var(--mb-primary-50); color: var(--mb-primary-700); border-color: rgba(46,59,209,.2); }
.mb-alert-warning { background: var(--mb-accent-50); color: #9A4A0E; border-color: rgba(245,118,31,.3); }
[data-theme="dark"] .mb-alert-success { color: #7BE3A6; }
[data-theme="dark"] .mb-alert-danger { color: #FF9B9E; }
[data-theme="dark"] .mb-alert-info { color: #AEB5FF; }
[data-theme="dark"] .mb-alert-warning { color: #FFB880; }
.mb-alert-close { border: 0; background: transparent; font-size: 22px; line-height: 1; color: inherit; opacity: .6; padding: 0 4px; }

/* ---------------- Tables / lists ---------------- */
.mb-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14.5px; }
.mb-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.mb-table th:first-child { border-top-left-radius: 10px; }
.mb-table th:last-child { border-top-right-radius: 10px; }
.mb-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
.mb-table tbody tr { transition: background .12s; }
.mb-table tbody tr:hover { background: var(--surface-2); }
.mb-table tr.is-clickable { cursor: pointer; }

.mb-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mb-person .mb-avatar { width: 38px; height: 38px; font-size: 13px; }
.mb-person-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-person-sub { font-size: 12.5px; color: var(--muted); }
.avatar-wa { background: linear-gradient(135deg, var(--mb-wa), var(--mb-wa-dark)) !important; }
.avatar-accent { background: linear-gradient(135deg, #FF9A4D, var(--mb-accent-600)) !important; }

.mb-empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.mb-empty .mb-empty-icon { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 14px; display: grid; place-items: center; font-size: 28px; background: var(--mb-primary-50); color: var(--mb-primary); }
.mb-empty h5 { color: var(--text); font-weight: 700; }

/* ---------------- Progress / funnel ---------------- */
.mb-progress { height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; display: flex; }
.mb-progress > span { display: block; height: 100%; transition: width .5s ease; }
.mb-progress-thin { height: 6px; }
.seg-read { background: var(--st-read); }
.seg-delivered { background: var(--st-delivered); }
.seg-sent { background: var(--st-sent); }
.seg-failed { background: var(--st-failed); }
.seg-queued { background: var(--st-queued); }
.mb-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-2); margin-top: 10px; }
.mb-legend span { display: inline-flex; align-items: center; gap: 6px; }
.mb-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.mb-funnel { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.mb-funnel-step { padding: 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); position: relative; overflow: hidden; }
.mb-funnel-step::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--c, var(--mb-primary)); }
.mb-funnel-step .lbl { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 6px; }
.mb-funnel-step .lbl i { color: var(--c); }
.mb-funnel-step .val { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; color: var(--text); }
.mb-funnel-step .rate { font-size: 13px; color: var(--text-2); font-weight: 600; }

/* ---------------- Recipient picker ---------------- */
.mb-pick-list { max-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.mb-pick-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; margin: 0; }
.mb-pick-item:last-child { border-bottom: 0; }
.mb-pick-item:hover { background: var(--surface-2); }
.mb-pick-item input { flex-shrink: 0; width: 18px; height: 18px; margin: 0; }
.mb-pick-item.is-checked { background: var(--mb-primary-50); }
.mb-group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.mb-group-card { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1.5px solid var(--border); border-radius: 14px; cursor: pointer; background: var(--surface); transition: .15s; margin: 0; }
.mb-group-card:hover { border-color: var(--mb-primary); }
.mb-group-card.is-checked { border-color: var(--mb-primary); background: var(--mb-primary-50); box-shadow: 0 0 0 3px rgba(46,59,209,.1); }
.mb-group-card input { display: none; }
.mb-group-dot { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; flex-shrink: 0; font-size: 16px; }
.mb-group-card .chk { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; color: transparent; font-size: 11px; flex-shrink: 0; }
.mb-group-card.is-checked .chk { background: var(--mb-primary); border-color: var(--mb-primary); color: #fff; }

.mb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mb-num-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text); }
.mb-num-chip button { border: 0; background: transparent; color: var(--muted); width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.mb-num-chip button:hover { background: var(--mb-danger-50); color: var(--mb-danger); }
.mb-num-chip.bad { background: var(--mb-danger-50); color: var(--mb-danger); border-color: rgba(229,72,77,.3); }

/* Summary bar (sticky on mobile) */
.mb-summary { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.mb-summary .big { font-size: 30px; font-weight: 800; color: var(--mb-primary); line-height: 1; }
[data-theme="dark"] .mb-summary .big { color: #8E98FF; }
.mb-sticky-side { position: sticky; top: calc(var(--topbar-h) + 18px); }

/* Drop zone */
.mb-drop { border: 2px dashed var(--border); border-radius: 14px; padding: 24px; text-align: center; cursor: pointer; transition: .15s; background: var(--surface-2); }
.mb-drop:hover, .mb-drop.dragover { border-color: var(--mb-wa); background: var(--mb-wa-50); }
.mb-drop .di { font-size: 34px; color: var(--mb-wa-dark); }
.mb-drop img { max-height: 140px; border-radius: 10px; }

/* WhatsApp phone preview */
.wa-phone { border-radius: 26px; overflow: hidden; border: 8px solid #1B1F2E; background: #1B1F2E; box-shadow: var(--shadow); max-width: 360px; margin: 0 auto; }
.wa-phone-head { background: #075E54; color: #fff; display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.wa-phone-head img { width: 32px; height: 32px; border-radius: 50%; background: #fff; object-fit: contain; }
.wa-phone-head b { font-size: 14px; display: block; line-height: 1.1; }
.wa-phone-head small { font-size: 11px; opacity: .8; }
.wa-phone-body {
    background-color: #EFE7DD; min-height: 280px; padding: 16px 12px;
    background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 14px 14px;
}
.wa-bubble { background: #fff; border-radius: 4px 12px 12px 12px; padding: 6px; max-width: 92%; box-shadow: 0 1px 1px rgba(0,0,0,.12); color: #111B21; font-size: 14px; }
.wa-bubble .wa-media { border-radius: 8px; background: #D8DEE6; height: 150px; display: grid; place-items: center; color: #7B8794; font-size: 30px; overflow: hidden; margin-bottom: 4px; }
.wa-bubble .wa-media img { width: 100%; height: 100%; object-fit: cover; }
.wa-bubble .wa-media.doc { height: 64px; font-size: 14px; display: flex; gap: 10px; justify-content: flex-start; padding: 0 12px; }
.wa-bubble .wa-head-text { font-weight: 700; padding: 4px 6px 0; }
.wa-bubble .wa-text { white-space: pre-wrap; padding: 4px 6px; word-wrap: break-word; }
.wa-bubble .wa-text:empty::before { content: 'Choose a template to see the preview'; color: #8A96A3; }
.wa-bubble .wa-foot { color: #8A96A3; font-size: 12.5px; padding: 0 6px; }
.wa-bubble .wa-time { text-align: right; font-size: 11px; color: #8A96A3; padding: 0 4px; }
.wa-bubble .wa-time i { color: #53BDEB; }
.wa-btns { max-width: 92%; }
.wa-btns div { background: #fff; color: #00A5F4; text-align: center; padding: 8px; border-radius: 10px; margin-top: 4px; font-weight: 600; font-size: 14px; box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.wa-var { background: #FFF2C6; border-radius: 4px; padding: 0 3px; }

/* Sending overlay */
.mb-overlay { position: fixed; inset: 0; background: rgba(9, 12, 40, .72); backdrop-filter: blur(4px); z-index: 2000; display: none; align-items: center; justify-content: center; padding: 16px; }
.mb-overlay.show { display: flex; }
.mb-overlay-box { background: var(--surface); border-radius: 22px; padding: 30px; width: 100%; max-width: 420px; text-align: center; box-shadow: var(--shadow-lg); }
.mb-overlay-icon { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center; font-size: 36px; color: #fff; background: linear-gradient(135deg, var(--mb-wa), var(--mb-wa-dark)); animation: mbBeat 1.3s infinite; }
@keyframes mbBeat { 50% { transform: scale(1.08); box-shadow: 0 0 0 14px rgba(37,211,102,.12); } }

/* Live dot */
.mb-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--st-read); }
.mb-live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: mbPulse 1.2s infinite; }

/* Utility */
.text-muted { color: var(--muted) !important; }
.fw-800 { font-weight: 800; }
.gap-10 { gap: 10px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.min-w-0 { min-width: 0; }
.cursor-pointer { cursor: pointer; }
.mb-divider { height: 1px; background: var(--border); margin: 18px 0; }
[data-theme="dark"] .table, [data-theme="dark"] .modal-content { color: var(--text); }
.modal-content { border-radius: 20px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-lg); }
.modal-header, .modal-footer { border-color: var(--border); }
[data-theme="dark"] .btn-close { filter: invert(1); }
.swal2-popup { border-radius: 20px !important; font-family: var(--font) !important; }
.swal2-confirm { border-radius: 12px !important; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 991.98px) {
    .mb-sidebar { transform: translateX(-102%); box-shadow: var(--shadow-lg); width: min(86vw, 300px); }
    body.drawer-open .mb-sidebar { transform: none; }
    body.drawer-open .mb-backdrop { display: block; position: fixed; inset: 0; background: rgba(9,12,40,.5); z-index: 1035; }
    body.drawer-open { overflow: hidden; }
    .mb-main { margin-left: 0; }
    .mb-topbar { padding: 0 14px; gap: 10px; height: 62px; }
    .mb-topbar-title h1 { font-size: 17px; }
    .mb-topbar-title p { display: none; }
    .mb-content { padding: 18px 16px calc(var(--bottom-h) + 30px); }
    .mb-footer { padding: 14px 16px calc(var(--bottom-h) + 20px); justify-content: center; }
    .mb-sticky-side { position: static; }
    .mb-funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mb-funnel-step:first-child { grid-column: span 2; }

    .mb-bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
        height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 20px rgba(16,22,92,.06);
    }
    .mb-bottom-nav > a, .mb-bottom-nav > button {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        color: var(--muted) !important; font-size: 11px; font-weight: 600; border: 0; background: transparent;
    }
    .mb-bottom-nav i { font-size: 18px; }
    .mb-bottom-nav .active { color: var(--mb-primary) !important; }
    [data-theme="dark"] .mb-bottom-nav .active { color: #8E98FF !important; }
    .mb-bottom-nav .mb-fab i {
        width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; margin-top: -26px; font-size: 19px;
        background: linear-gradient(135deg, #FF9A4D, var(--mb-accent-600)); color: #fff; box-shadow: 0 8px 20px rgba(245,118,31,.45);
    }
    .mb-bottom-nav .mb-fab { color: var(--mb-accent-600) !important; }
}
@media (max-width: 575.98px) {
    body.mb-app { font-size: 14.5px; }
    .mb-card { padding: 16px; border-radius: 14px; }
    .mb-hero { padding: 20px; border-radius: 16px; }
    .mb-hero h2 { font-size: 20px; }
    .mb-hero .mb-hero-art { display: none !important; }
    .mb-hero-actions .btn { flex: 1 1 auto; }
    .mb-stat { padding: 14px; gap: 12px; }
    .mb-stat-icon { width: 42px; height: 42px; font-size: 16px; }
    .mb-stat-value { font-size: 22px; }
    .mb-chip-credits { padding: 6px 10px; }
    .mb-topbar-right { gap: 6px; }
    .mb-icon-btn { width: 38px; height: 38px; }
    .mb-funnel-step .val { font-size: 22px; }
    .mb-page-actions { justify-content: stretch; }
    .mb-page-actions > * { flex: 1 1 auto; }

    /* Tables become stacked cards */
    .mb-table-stack thead { display: none; }
    .mb-table-stack, .mb-table-stack tbody, .mb-table-stack tr, .mb-table-stack td { display: block; width: 100%; }
    .mb-table-stack tr { border: 1px solid var(--border); border-radius: 14px; margin-bottom: 10px; padding: 8px 4px; background: var(--surface); }
    .mb-table-stack td { border: 0; padding: 6px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .mb-table-stack td[data-label]::before { content: attr(data-label); font-weight: 600; color: var(--muted); font-size: 12.5px; text-align: left; }
    .mb-table-stack td.td-main { text-align: left; display: block; }
    .mb-table-stack td.td-main::before { display: none; }
}

/* =========================================================
   Legacy pages (still using sidebar.php) — blend them in
   ========================================================= */
html.mb-legacy-html body { background: var(--bg) !important; color: var(--text); font-family: var(--font) !important; margin: 0; font-size: 15px; }
html.mb-legacy-html body::before { display: none !important; }
html.mb-legacy-html body > .navbar:not(.mb-keep) { display: none !important; }
html.mb-legacy-html body > br { display: none; }
html.mb-legacy-html body .main-content, html.mb-legacy-html body > .container, html.mb-legacy-html body > .container-fluid, html.mb-legacy-html body > main { padding-top: 0 !important; margin-top: 0 !important; }
html.mb-legacy-html body .glass-card, html.mb-legacy-html body .app-card, html.mb-legacy-html body .card {
    background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--radius) !important;
    box-shadow: var(--shadow-sm) !important; backdrop-filter: none !important; animation: none !important; color: var(--text);
}
html.mb-legacy-html body .glass-card { padding: 26px; }
html.mb-legacy-html body h1 { background: none !important; -webkit-text-fill-color: currentColor !important; color: var(--text) !important; font-size: 26px; font-weight: 800; }
html.mb-legacy-html body .text-white { color: var(--text) !important; }
html.mb-legacy-html body .btn-gradient { background: var(--mb-primary) !important; box-shadow: none !important; border-radius: 12px !important; color: #fff; padding: 10px 20px; transform: none !important; }
html.mb-legacy-html body .footer, html.mb-legacy-html body .whatsapp-btn { display: none !important; }
html.mb-legacy-html body .app-head { background: linear-gradient(120deg, var(--mb-navy), var(--mb-primary)) !important; }
html.mb-legacy-html body .form-control:focus, html.mb-legacy-html body .form-select:focus { transform: none !important; }
html.mb-legacy-html body .mb-legacy-wrap { margin-left: var(--sidebar-w); padding: 24px 28px 40px; }
@media (min-width: 992px) {
    html.mb-legacy-html body { padding-left: var(--sidebar-w); }
}
@media (max-width: 991.98px) {
    html.mb-legacy-html body { padding-top: 62px; padding-bottom: calc(var(--bottom-h) + 20px); }
    html.mb-legacy-html body .mb-legacy-top { position: fixed; top: 0; left: 0; right: 0; }
}
.mb-legacy-top { display: none; }
@media (max-width: 991.98px) {
    .mb-legacy-top { display: flex; z-index: 1020; }
}
.mb-send-btn { margin-left: auto; }
@media (max-width: 575.98px) { .mb-send-btn { width: 100%; margin-left: 0; } }

@media (max-width: 575.98px) {
    .mb-tab { padding: 8px 8px; font-size: 13px; gap: 6px; }
    .mb-tab .mb-count { padding: 1px 6px; }
}
@media (max-width: 575.98px) { .table-responsive[style*="max-height"] { max-height: none !important; } }

/* =========================================================
   Pagination
   ========================================================= */
.mb-pager-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 16px; }
.mb-pager-bar:empty, .mb-pager-bar[hidden] { display: none; }
.mb-pager-info { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mb-pager-info b { color: var(--text); font-weight: 700; }
.mb-pager-info select { width: auto; padding: 4px 28px 4px 10px; font-size: 13px; border-radius: 9px; background-position: right 8px center; }
.mb-pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mb-pg {
    min-width: 36px; height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-2) !important; font-weight: 600; font-size: 14px;
    display: inline-grid; place-items: center; cursor: pointer; transition: .15s; text-decoration: none !important; user-select: none;
}
.mb-pg:hover { border-color: var(--mb-primary); color: var(--mb-primary) !important; }
.mb-pg.active { background: var(--mb-primary); border-color: var(--mb-primary); color: #fff !important; box-shadow: 0 4px 12px rgba(46,59,209,.28); }
.mb-pg.disabled { opacity: .4; pointer-events: none; }
.mb-pg.gap { border-color: transparent; background: transparent; pointer-events: none; min-width: 14px; padding: 0; }
.mb-pager-sm { gap: 4px; }
.mb-pager-sm .mb-pg { min-width: 32px; height: 32px; padding: 0 8px; font-size: 13px; border-radius: 9px; }
@media (max-width: 575.98px) {
    .mb-pager-bar { justify-content: center; }
    .mb-pager-info { width: 100%; justify-content: center; }
}

/* segmented tabs used as links */
.mb-tabs a.mb-tab { color: var(--text-2) !important; text-decoration: none; }
.mb-tabs a.mb-tab.active { color: var(--mb-primary) !important; }
[data-theme="dark"] .mb-tabs a.mb-tab.active { color: #8E98FF !important; }

/* =========================================================
   Chats
   ========================================================= */
:root {
    --chat-wall: #EDF0F8;
    --chat-dot: rgba(46, 59, 209, .07);
    --chat-in: #FFFFFF;
    --chat-day: rgba(255, 255, 255, .94);
}
[data-theme="dark"] {
    --chat-wall: #0E1330;
    --chat-dot: rgba(255, 255, 255, .045);
    --chat-in: #1C2448;
    --chat-day: rgba(28, 36, 72, .94);
}
body.mb-chat-page .mb-footer { display: none; }
body.mb-chat-page .mb-content { padding-bottom: 22px; }

.mb-chat {
    display: grid; grid-template-columns: 360px minmax(0, 1fr);
    height: calc(100vh - var(--topbar-h) - 48px); height: calc(100dvh - var(--topbar-h) - 48px); min-height: 480px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}

/* list */
.mb-chat-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--surface); }
.mb-chat-list-head { padding: 14px 14px 12px; border-bottom: 1px solid var(--border); }
.mb-chat-list-head .mb-tab { padding: 7px 10px; font-size: 13.5px; }
.mb-chat-list-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; scrollbar-width: thin; }
.mb-chat-list-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--border); background: var(--surface-2); }
.mb-conv { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; color: var(--text) !important; position: relative; transition: background .12s; text-decoration: none; }
.mb-conv + .mb-conv { margin-top: 1px; }
.mb-conv:hover { background: var(--surface-2); }
.mb-conv.active { background: var(--mb-primary-50); }
.mb-conv.active::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--mb-primary); }
.mb-conv .mb-avatar { width: 46px; height: 46px; font-size: 15px; }
.mb-conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mb-conv-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mb-conv-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-conv-time { flex-shrink: 0; font-size: 11.5px; color: var(--muted); }
.mb-conv-preview { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-conv-preview i { font-size: 11.5px; }
.mb-tick.is-read { color: #34B7F1; }
.mb-conv-badge { flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--mb-accent); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.mb-conv.is-unread .mb-conv-name { font-weight: 800; }
.mb-conv.is-unread .mb-conv-time { color: var(--mb-accent-600); font-weight: 700; }
.mb-conv.is-unread .mb-conv-preview { color: var(--text-2); font-weight: 600; }

/* thread */
.mb-chat-thread {
    position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0;
    background-color: var(--chat-wall);
    background-image: radial-gradient(var(--chat-dot) 1px, transparent 1px); background-size: 18px 18px;
}
.mb-chat-head { display: flex; align-items: center; gap: 12px; padding: 11px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.mb-chat-head .mb-avatar { width: 42px; height: 42px; }
.mb-chat-head-name { font-weight: 700; font-size: 15.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-chat-head-sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.mb-chat-back { display: none; }
.mb-chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 6% 12px; }
.mb-chat-older { margin: 2px 0 6px; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 600; box-shadow: var(--shadow-sm); }
.mb-chat-older:hover { color: var(--mb-primary); border-color: var(--mb-primary); }
.mb-chat-day { position: sticky; top: 0; z-index: 1; text-align: center; margin: 12px 0 8px; pointer-events: none; }
.mb-chat-day span { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--chat-day); color: var(--text-2); font-size: 12px; font-weight: 700; box-shadow: var(--shadow-sm); }
.mb-msg { display: flex; margin: 3px 0; }
.mb-msg.out { justify-content: flex-end; }
.mb-bubble {
    position: relative; max-width: min(72%, 560px); padding: 7px 10px 5px; border-radius: 14px;
    font-size: 14.5px; line-height: 1.45; overflow-wrap: anywhere; box-shadow: 0 1px 1.5px rgba(16, 22, 92, .1);
}
.mb-msg.in .mb-bubble { background: var(--chat-in); color: var(--text); border-top-left-radius: 4px; }
.mb-msg.out .mb-bubble { background: linear-gradient(135deg, var(--mb-primary), var(--mb-primary-700)); color: #fff; border-top-right-radius: 4px; }
.mb-msg.out .mb-bubble a { color: #fff !important; text-decoration: underline; }
.mb-msg-text { display: inline; }
.mb-msg-meta { float: right; display: inline-flex; align-items: center; gap: 4px; margin: 6px 0 -2px 12px; font-size: 11px; line-height: 1.2; color: var(--muted); white-space: nowrap; }
.mb-msg.out .mb-msg-meta { color: rgba(255, 255, 255, .75); }
.mb-msg-meta .is-read { color: #7DF0B4; }
.mb-msg-meta .is-failed { color: #FFB4B6; }
.mb-msg.in .mb-msg-meta .is-failed { color: var(--mb-danger); }
.mb-msg-media { display: block; margin: -3px -6px 5px; border-radius: 10px; overflow: hidden; max-width: 300px; }
.mb-msg-media img, video.mb-msg-media { display: block; width: 100%; max-height: 320px; object-fit: cover; }
.mb-msg-file { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; padding: 8px 10px; border-radius: 10px; background: rgba(127, 127, 127, .14); color: inherit !important; font-size: 13.5px; font-weight: 600; text-decoration: none !important; text-transform: capitalize; }
.mb-bubble audio { display: block; max-width: 260px; }
.mb-chat-jump { position: absolute; right: 22px; bottom: 84px; z-index: 2; border: 0; border-radius: 999px; padding: 8px 14px; background: var(--mb-accent); color: #fff; font-weight: 700; font-size: 13px; box-shadow: var(--shadow); }
.mb-chat-note { display: flex; gap: 10px; align-items: flex-start; margin: 0 14px; padding: 9px 12px; border: 1px solid rgba(245, 118, 31, .25); border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--mb-accent-50); color: #9A4A0E; font-size: 13px; font-weight: 500; }
.mb-chat-note > i { margin-top: 3px; }
[data-theme="dark"] .mb-chat-note { color: #FFB880; }
.mb-chat-compose { display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px; background: var(--surface); border-top: 1px solid var(--border); }
.mb-chat-compose textarea { resize: none; max-height: 140px; padding: 11px 18px; border-radius: 24px; background-color: var(--surface-2); line-height: 1.4; }
.mb-chat-send { flex-shrink: 0; width: 46px; height: 46px; border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 17px; background: linear-gradient(135deg, var(--mb-wa), var(--mb-wa-dark)); box-shadow: 0 6px 16px rgba(37, 211, 102, .35); transition: transform .15s; }
.mb-chat-send:hover { transform: scale(1.06); }
.mb-chat-welcome { margin: auto; max-width: 430px; padding: 30px 20px; text-align: center; color: var(--muted); }
.mb-chat-welcome-icon { width: 96px; height: 96px; margin: 0 auto 20px; border-radius: 30px; display: grid; place-items: center; font-size: 48px; color: #fff; background: linear-gradient(135deg, var(--mb-wa), var(--mb-wa-dark)); box-shadow: 0 16px 36px rgba(37, 211, 102, .35); transform: rotate(-6deg); }
.mb-chat-welcome h4 { color: var(--text); font-weight: 800; }

@media (max-width: 1199.98px) {
    .mb-chat { grid-template-columns: 320px minmax(0, 1fr); }
    .mb-chat-body { padding: 14px 18px 10px; }
}
@media (max-width: 991.98px) {
    body.mb-chat-page .mb-content { padding: 0; }
    .mb-chat {
        display: block; min-height: 0; border: 0; border-radius: 0; box-shadow: none;
        height: calc(100vh - 62px - var(--bottom-h)); height: calc(100dvh - 62px - var(--bottom-h) - env(safe-area-inset-bottom));
    }
    .mb-chat-list, .mb-chat-thread { height: 100%; }
    .mb-chat-list { border-right: 0; }
    .mb-chat.has-thread .mb-chat-list, .mb-chat:not(.has-thread) .mb-chat-thread { display: none; }
    .mb-chat-back { display: grid; }
    .mb-chat-head { padding: 9px 12px; gap: 10px; }
    .mb-chat-body { padding: 10px 12px; }
    .mb-bubble { max-width: 86%; }
    .mb-chat-jump { right: 14px; bottom: 78px; }
    .mb-chat-compose { padding: 10px; }
}

/* =========================================================
   Legacy pages — consistent spacing, top bar, tables, cards
   ========================================================= */
html.mb-legacy-html a { text-decoration: none; }
html.mb-legacy-html body .main-content,
html.mb-legacy-html body > .container,
html.mb-legacy-html body > .container-fluid,
html.mb-legacy-html body > main { padding: 26px 28px 40px !important; max-width: 1440px; width: 100%; margin: 0 !important; }
html.mb-legacy-html body .glass-card { display: flow-root; height: auto !important; overflow: visible !important; }
html.mb-legacy-html body h1 { font-size: 24px !important; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
html.mb-legacy-html body .text-center > h1 { justify-content: center; }
html.mb-legacy-html body h1 i { color: var(--mb-primary); }
html.mb-legacy-html body h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
html.mb-legacy-html body .text-center.mb-5 { margin-bottom: 1.5rem !important; }
html.mb-legacy-html body .text-muted.fs-5 { font-size: 15px !important; }
html.mb-legacy-html body .form-label.fs-5, html.mb-legacy-html body label.fs-5 { font-size: 13.5px !important; }
html.mb-legacy-html body .card-body.p-5 { padding: 22px !important; }
html.mb-legacy-html body .shadow-lg { box-shadow: var(--shadow-sm) !important; }
html.mb-legacy-html body .rounded-pill.btn { border-radius: 12px !important; padding: 9px 18px !important; }
html.mb-legacy-html body .btn.px-5.py-3 { padding: 10px 22px !important; }
html.mb-legacy-html body .btn-gradient:hover { background: var(--mb-primary-700) !important; color: #fff; }
html.mb-legacy-html body .btn-outline-primary { color: var(--mb-primary); border-color: var(--mb-primary); }
html.mb-legacy-html body .btn-outline-primary:hover { background: var(--mb-primary); color: #fff; }
html.mb-legacy-html body .btn-success { background: var(--mb-wa-dark); border-color: var(--mb-wa-dark); }
/* coloured row-action buttons → soft tinted, like the new pages */
html.mb-legacy-html body .table .btn-warning, html.mb-legacy-html body .table .btn-info,
html.mb-legacy-html body .table .btn-danger, html.mb-legacy-html body .table .btn-success {
    border: 0; font-weight: 600; padding: 6px 11px; font-size: 13px; border-radius: 9px;
}
html.mb-legacy-html body .table .btn-warning { background: var(--mb-accent-50); color: var(--mb-accent-600); }
html.mb-legacy-html body .table .btn-info { background: var(--mb-primary-50); color: var(--mb-primary); }
html.mb-legacy-html body .table .btn-danger { background: var(--mb-danger-50); color: var(--mb-danger); }
html.mb-legacy-html body .table .btn-success { background: var(--mb-wa-50); color: var(--st-read); }
html.mb-legacy-html body .table .btn:hover { filter: brightness(.96); transform: translateY(-1px); }

/* bootstrap tables → mb-table look */
html.mb-legacy-html body .table {
    --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-hover-bg: var(--surface-2); --bs-table-hover-color: var(--text);
    --bs-table-striped-bg: var(--surface-2); --bs-table-striped-color: var(--text); --bs-table-border-color: var(--border);
    background: var(--surface) !important; box-shadow: none !important; border-collapse: separate; border-spacing: 0;
    border: 1px solid var(--border); border-radius: 14px; overflow: hidden; font-size: 14.5px; margin-bottom: 0;
}
html.mb-legacy-html body .table.table-bordered > :not(caption) > * > * { border-width: 0 0 1px 0; }
html.mb-legacy-html body .table > thead th {
    background: var(--surface-2) !important; color: var(--muted) !important; font-size: 12px; text-transform: uppercase;
    letter-spacing: .06em; font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
html.mb-legacy-html body .table > tbody td { padding: 12px 14px; vertical-align: middle; border-color: var(--border); }
html.mb-legacy-html body .table > tbody > tr:last-child > td { border-bottom: 0; }

/* legacy alerts / badges */
html.mb-legacy-html body .alert { border-radius: 14px; font-weight: 500; }
html.mb-legacy-html body .alert-success { background: var(--mb-wa-50); color: #12693A; border-color: rgba(37,211,102,.3); }
html.mb-legacy-html body .alert-danger { background: var(--mb-danger-50); color: #A1272B; border-color: rgba(229,72,77,.3); }
html.mb-legacy-html body .alert-info { background: var(--mb-primary-50); color: var(--mb-primary-700); border-color: rgba(46,59,209,.2); }
html.mb-legacy-html body .alert-warning { background: var(--mb-accent-50); color: #9A4A0E; border-color: rgba(245,118,31,.3); }
html.mb-legacy-html body .badge { border-radius: 999px; font-weight: 700; padding: .45em .8em; }

/* products grid */
html.mb-legacy-html body .product-card {
    position: relative; height: 100%; display: flex; flex-direction: column; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: .18s;
}
html.mb-legacy-html body .product-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
html.mb-legacy-html body .product-card .product-image,
html.mb-legacy-html body .product-card .no-image { height: 200px; width: 100%; object-fit: cover; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-size: 40px; border-bottom: 1px solid var(--border); }
html.mb-legacy-html body .product-card .p-4 { padding: 16px !important; flex: 1; display: flex; flex-direction: column; }
html.mb-legacy-html body .product-card .p-4 > .d-flex { margin-top: auto !important; padding-top: 12px; }
html.mb-legacy-html body .product-card .stock-badge,
html.mb-legacy-html body .product-card .price-badge { position: absolute; top: 12px; z-index: 1; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; box-shadow: var(--shadow-sm); }
html.mb-legacy-html body .product-card .stock-badge { left: 12px; background: var(--mb-wa-50); color: var(--st-read); }
html.mb-legacy-html body .product-card .stock-badge.bg-danger { background: var(--mb-danger-50) !important; color: var(--mb-danger); }
html.mb-legacy-html body .product-card .price-badge { right: 12px; background: var(--mb-accent); color: #fff; }
html.mb-legacy-html body .row.g-5 { --bs-gutter-x: 1.25rem; --bs-gutter-y: 1.25rem; }

/* dark mode for legacy bootstrap bits */
html.mb-legacy-html[data-theme="dark"] body .bg-white, html.mb-legacy-html[data-theme="dark"] body .bg-light,
html.mb-legacy-html[data-theme="dark"] body .card, html.mb-legacy-html[data-theme="dark"] body .list-group-item { background: var(--surface) !important; color: var(--text); border-color: var(--border) !important; }
html.mb-legacy-html[data-theme="dark"] body .text-dark { color: var(--text) !important; }

/* top bar on every legacy page (desktop too) */
html.mb-legacy-html .mb-legacy-top { display: flex; position: sticky; top: 0; z-index: 1020; }
@media (max-width: 991.98px) {
    html.mb-legacy-html .mb-legacy-top { position: fixed; }
    html.mb-legacy-html body .main-content, html.mb-legacy-html body > .container,
    html.mb-legacy-html body > .container-fluid, html.mb-legacy-html body > main { padding: 18px 16px 30px !important; }
    html.mb-legacy-html body .glass-card { padding: 18px; }
}
@media (max-width: 575.98px) {
    html.mb-legacy-html body h1 { font-size: 20px !important; }
    html.mb-legacy-html body .table { font-size: 13.5px; }
}

/* hidden rows (filters / pagination) must stay hidden, even in stacked-card mode */
tr[hidden], .mb-table-stack tr[hidden] { display: none !important; }

/* legacy h1 rules must not restyle the top-bar title */
html.mb-legacy-html body .mb-topbar-title h1 { display: block; font-size: 20px !important; margin: 0; color: var(--text) !important; }
@media (max-width: 991.98px) { html.mb-legacy-html body .mb-topbar-title h1 { font-size: 17px !important; } }

/* bright bootstrap badges → soft tints */
html.mb-legacy-html body .badge.bg-primary { background: var(--mb-primary-50) !important; color: var(--mb-primary) !important; }
html.mb-legacy-html body .badge.bg-info { background: var(--mb-wa-50) !important; color: var(--st-read) !important; }
html.mb-legacy-html body .badge.bg-success { background: var(--mb-wa-50) !important; color: var(--st-read) !important; }
html.mb-legacy-html body .badge.bg-warning { background: var(--mb-accent-50) !important; color: var(--mb-accent-600) !important; }
html.mb-legacy-html body .badge.bg-danger { background: var(--mb-danger-50) !important; color: var(--mb-danger) !important; }
html.mb-legacy-html body .badge.bg-secondary { background: var(--surface-2) !important; color: var(--muted) !important; }
