:root {
    --wa-green: #25d366;
    --wa-green-dark: #128c7e;
    --wa-teal: #075e54;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #14532d;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --input-color: #0f172a;
    --label-color: #334155;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --text-secondary: #475569;
    --border: #e2e8f0;
    --hover-bg: #f8fafc;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius: 1rem;
    --radius-sm: 0.625rem;
    --link-color: #0f766e;
    --dash-accent: #00b386;
    --dash-chart-muted: #94a3b8;
    --dash-grid: rgba(148, 163, 184, 0.2);
    --dash-tick: #64748b;
    --dash-panel: #ffffff;
    --dash-panel-border: #e2e8f0;
    --dash-kpi-icon: #0f766e;
    --bs-body-bg: var(--body-bg);
    --bs-body-color: var(--text-primary);
    --bs-secondary-color: var(--text-muted);
    --bs-border-color: var(--border);
    --bs-tertiary-bg: var(--hover-bg);
}

html[data-theme="dark"] {
    --sidebar-bg: #0a0a0a;
    --sidebar-hover: #1a1a1a;
    --sidebar-active: #12352c;
    --body-bg: #0a0a0a;
    --card-bg: #161616;
    --input-bg: #1c1c1c;
    --input-color: #f1f5f9;
    --label-color: #cbd5e1;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --text-secondary: #cbd5e1;
    --border: #2a2a2a;
    --hover-bg: #1f1f1f;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
    --link-color: #00ffc2;
    --dash-accent: #00ffc2;
    --dash-chart-muted: #4b5563;
    --dash-grid: rgba(148, 163, 184, 0.12);
    --dash-tick: #94a3b8;
    --dash-panel: #161616;
    --dash-panel-border: #242424;
    --dash-kpi-icon: #00ffc2;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body.app-body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Sidebar */
.app-sidebar {
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, #020617 100%);
    min-height: 100vh;
    width: 260px;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    transition: width 0.25s ease;
    position: relative;
    z-index: 1050;
    overflow-y: auto;
}

.sidebar-top {
    padding: 0.75rem 0.5rem 0.25rem;
}

.sidebar-toggle {
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sidebar-toggle:hover {
    color: #fff;
    background: var(--sidebar-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem 0.75rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    min-width: 0;
}

.sidebar-top .app-brand {
    padding: 0.25rem 0.5rem;
}

.app-brand-text {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease, max-width 0.25s ease;
}

.app-sidebar .nav-link .nav-label {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease, max-width 0.25s ease;
}

/* Collapsed sidebar — icons only */
body.sidebar-collapsed .app-sidebar {
    width: 76px;
}

body.sidebar-collapsed .app-brand-text,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-stats,
body.sidebar-collapsed .sidebar-user .name,
body.sidebar-collapsed .sidebar-user .role {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    display: none;
}

body.sidebar-collapsed .sidebar-top {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
}

body.sidebar-collapsed .sidebar-top .app-brand {
    justify-content: center;
    padding: 0.25rem;
}

body.sidebar-collapsed .app-sidebar .nav-link {
    justify-content: center;
    padding: 0.65rem;
    margin: 0.15rem 0.35rem;
}

body.sidebar-collapsed .app-sidebar .nav-link.active {
    padding-left: calc(0.65rem - 3px);
}

body.sidebar-collapsed .sidebar-user {
    margin: 0.5rem 0.35rem 0;
    padding: 0.65rem;
    text-align: center;
}

body.sidebar-collapsed .sidebar-logout-btn {
    width: auto;
    padding: 0.45rem 0.55rem;
}

body.sidebar-collapsed .sidebar-logout-btn .bi {
    margin: 0 !important;
}

.app-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
}

a.app-brand-link {
    text-decoration: none;
    color: #fff;
}

a.app-brand-link .app-brand-text {
    color: #fff;
}

a.app-brand-link:hover,
a.app-brand-link:focus-visible {
    color: #fff;
    text-decoration: none;
}

a.app-brand-link:hover .app-brand-icon,
a.app-brand-link:focus-visible .app-brand-icon {
    filter: brightness(1.06);
}

.app-sidebar .nav-link {
    color: #94a3b8;
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    margin: 0.15rem 0.5rem;
    font-size: 0.925rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: all 0.2s ease;
}

.app-sidebar .nav-link i { font-size: 1.1rem; width: 1.25rem; }

.app-sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: #f8fafc;
}

.app-sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(37, 211, 102, 0.2), transparent);
    color: #fff;
    border-left: 3px solid var(--wa-green);
    padding-left: calc(0.85rem - 3px);
}

.sidebar-user {
    margin: 1rem 0.75rem 0;
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user .name { color: #f1f5f9; font-weight: 600; font-size: 0.9rem; }
.sidebar-user .role { color: #64748b; font-size: 0.75rem; }

.sidebar-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0 1rem 1rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.app-sidebar .sidebar-stat-item,
.app-offcanvas .sidebar-stat-item {
    text-align: center;
    padding: 0.65rem 0.35rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.app-sidebar .sidebar-stat-number,
.app-offcanvas .sidebar-stat-number {
    color: #25d366;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
}

.app-sidebar .sidebar-stat-label,
.app-offcanvas .sidebar-stat-label {
    color: #f1f5f9;
    font-size: 0.72rem;
    font-weight: 500;
    margin-top: 0.25rem;
    line-height: 1.2;
}

.app-offcanvas .sidebar-stats {
    padding: 0.75rem 0 0;
    margin-top: 0.75rem;
    border-bottom: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Top bar mobile */
.app-topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    min-height: 3.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-topbar-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 0;
    line-height: 1;
    font-size: 1.1rem;
    text-decoration: none;
    flex-shrink: 0;
}

.app-topbar-btn:hover,
.app-topbar-btn:focus-visible {
    color: var(--dash-accent);
    border-color: var(--dash-accent);
}

.app-topbar .app-topbar-brand {
    width: 36px;
    height: 36px;
    font-size: 1.05rem;
    border-radius: 10px;
    box-shadow: none;
}

.app-main {
    flex: 1;
    min-width: 0;
    padding: 1.25rem;
}

@media (min-width: 768px) {
    .app-main { padding: 1.75rem 2rem; }
}

/* Cards */
.stat-card, .card-modern {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-modern .card-header,
.stat-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-modern .card-body,
.stat-card .card-body { padding: 1.25rem; }

/* Stat tiles */
.stat-tile {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
}

.stat-tile-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
}

.stat-tile-icon.primary { background: #dbeafe; color: #2563eb; }
.stat-tile-icon.info { background: #e0f2fe; color: #0284c7; }
.stat-tile-icon.success { background: #dcfce7; color: #16a34a; }
.stat-tile-icon.warning { background: #fef3c7; color: #d97706; }
.stat-tile-icon.danger { background: #fee2e2; color: #dc2626; }

.stat-tile h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.03em;
}

.stat-tile small { color: var(--text-muted); font-weight: 500; }

/* Page header */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h1, .page-header h2 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-size: clamp(1.35rem, 2.5vw, 1.75rem);
}

.dashboard-unread-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    vertical-align: middle;
    transition: background 0.15s ease, color 0.15s ease;
}

.dashboard-unread-link i {
    font-size: 0.8rem;
}

.dashboard-date-filter {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
}

.dashboard-date-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.dashboard-period-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 600;
}

.dashboard-unread-link:hover {
    background: #fee2e2;
    color: #b91c1c;
}

/* Buttons */
.btn-wa {
    background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.1rem;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.3);
}

.btn-wa:hover {
    background: linear-gradient(135deg, #2ee66d, var(--wa-green));
    color: #fff;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
}

/* Outline action buttons — toolbar, back, cancel, export, etc. */
.btn-outline-secondary,
.btn-outline-primary,
.btn-outline-success,
.btn-outline-danger {
    font-weight: 600;
    border-width: 1.5px;
    border-radius: var(--radius-sm);
    transition:
        color 0.2s ease,
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
}

.btn-outline-secondary {
    color: var(--text-secondary);
    background: var(--card-bg);
    border-color: var(--border);
    box-shadow: var(--shadow);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    color: var(--wa-teal);
    background: color-mix(in srgb, var(--wa-green) 12%, var(--card-bg));
    border-color: var(--wa-green);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.18);
    transform: translateY(-1px);
}

.btn-outline-secondary:active {
    color: var(--wa-teal);
    background: #dcfce7;
    border-color: var(--wa-green-dark);
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(37, 211, 102, 0.15);
}

.btn-outline-primary {
    color: #0369a1;
    background: #fff;
    border-color: #7dd3fc;
    box-shadow: 0 1px 2px rgba(14, 116, 144, 0.08);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    color: #0c4a6e;
    background: #f0f9ff;
    border-color: #0ea5e9;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
    transform: translateY(-1px);
}

.btn-outline-success {
    color: #15803d;
    background: #fff;
    border-color: #86efac;
    box-shadow: 0 1px 2px rgba(21, 128, 61, 0.08);
}

.btn-outline-success:hover,
.btn-outline-success:focus {
    color: #14532d;
    background: #f0fdf4;
    border-color: var(--wa-green);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.2);
    transform: translateY(-1px);
}

.btn-outline-danger {
    color: #b91c1c;
    background: #fff;
    border-color: #fca5a5;
    box-shadow: 0 1px 2px rgba(185, 28, 28, 0.08);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
    color: #991b1b;
    background: #fef2f2;
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.18);
    transform: translateY(-1px);
}

/* Toggle groups (e.g. template preview Android/iOS) */
.btn-outline-secondary.active,
.btn-check:checked + .btn-outline-secondary {
    color: #fff;
    background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
    border-color: var(--wa-green-dark);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

/* Sidebar logout — keep dark theme, do not apply light toolbar hover */
.app-sidebar .btn-outline-light,
.offcanvas.app-offcanvas .btn-outline-light {
    font-weight: 500;
    border-width: 1px;
    box-shadow: none;
    transform: none;
}

.app-sidebar .btn-outline-light:hover,
.offcanvas.app-offcanvas .btn-outline-light:hover {
    transform: none;
}

/* Tables — compact modern data grid */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: transparent;
    --bs-table-hover-bg: color-mix(in srgb, var(--text-muted) 10%, transparent);
    --bs-table-hover-color: var(--text-primary);
    font-size: 0.8125rem;
    line-height: 1.45;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.table thead th {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    padding: 0.65rem 0.85rem;
    background: color-mix(in srgb, var(--text-muted) 8%, var(--card-bg));
}

.table > :not(caption) > * > * {
    background-color: transparent;
    color: inherit;
    border-bottom-color: var(--border);
    box-shadow: none;
}

.table tbody td {
    padding: 0.6rem 0.85rem;
    vertical-align: middle;
    color: var(--text-primary);
    font-weight: 500;
    border-bottom-color: var(--border);
}

.table-hover tbody tr:hover {
    background: color-mix(in srgb, var(--text-muted) 10%, transparent);
    color: var(--text-primary);
}

.table-responsive-card {
    border-radius: var(--radius);
    overflow: hidden;
}

.table-responsive-card .table thead th:first-child,
.table-responsive-card .table tbody td:first-child {
    padding-left: 1.1rem;
}

.table-responsive-card .table thead th:last-child,
.table-responsive-card .table tbody td:last-child {
    padding-right: 1.1rem;
}

/* Primary column in grids */
.table .col-primary,
.table .grid-primary {
    font-weight: 500;
    color: #0f172a;
}

.table .grid-muted {
    color: #64748b;
    font-size: 0.75rem;
}

.table .grid-link {
    color: #2563eb;
    font-weight: 500;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.table .grid-link:hover {
    color: #1d4ed8;
}

.table .grid-preview {
    max-width: 220px;
    color: #475569;
    font-size: 0.8125rem;
}

.table .badge {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.28em 0.55em;
}

/* Badges */
.badge-status {
    font-weight: 600;
    padding: 0.28em 0.55em;
    border-radius: 6px;
    font-size: 0.6875rem;
    text-transform: capitalize;
    letter-spacing: 0.02em;
}

.badge-running { background: #dbeafe; color: #1d4ed8; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-paused { background: #fef3c7; color: #b45309; }
.badge-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-scheduled { background: #e0e7ff; color: #4338ca; }

/* Alerts */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    box-shadow: var(--shadow);
}

/* Forms */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    padding: 0.6rem 0.85rem;
    background-color: var(--input-bg);
    color: var(--input-color);
}

.form-control:focus, .form-select:focus {
    border-color: var(--wa-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
    background-color: var(--input-bg);
    color: var(--input-color);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.85;
}

.form-label { font-weight: 600; font-size: 0.875rem; color: var(--label-color); }

.form-text,
.text-muted {
    color: var(--text-muted) !important;
}

.form-check-input {
    background-color: var(--input-bg);
    border-color: var(--border);
}

.input-group-text {
    background-color: var(--hover-bg);
    border-color: var(--border);
    color: var(--text-secondary);
}

/* Auth pages */
html:has(.auth-page),
body.auth-page {
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: hidden;
}

.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #0f172a 0%, #14532d 50%, #0f172a 100%);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: min(600px, 100vw);
    height: min(600px, 100vw);
    background: radial-gradient(circle, rgba(37, 211, 102, 0.15) 0%, transparent 70%);
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.auth-shell {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.auth-card {
    width: 100%;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 1.25rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    padding: 2rem;
    position: relative;
    box-sizing: border-box;
}

.auth-card-wide {
    max-width: 720px;
    padding: 1.5rem 1.75rem;
}

.auth-shell:has(.auth-card-wide) {
    max-width: 720px;
}

.auth-signup-form .form-label {
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
}

.auth-signup-form .form-text {
    margin-top: 0.15rem;
    font-size: 0.75rem;
}

.auth-card-wide .auth-logo {
    margin-bottom: 1rem;
}

.auth-card-wide .auth-logo .icon {
    width: 48px;
    height: 48px;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    border-radius: 14px;
}

.auth-password-toggle {
    cursor: pointer;
    border-left: 0;
    color: #64748b;
}

.auth-password-toggle:hover {
    color: #334155;
    background: #f1f5f9 !important;
}

.auth-page .input-group .form-control {
    min-width: 0;
}

@media (max-width: 575.98px) {
    .auth-page {
        padding: 0.75rem;
        align-items: center;
    }

    .auth-card {
        padding: 1.5rem 1.25rem;
        border-radius: 1rem;
    }

    .auth-shell {
        max-width: 100%;
    }
}

.auth-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-logo .icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 0.75rem;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: #fff;
}

/* Inbox — WhatsApp Web-style workspace */
.page-inbox .app-main--inbox {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 1.5rem);
}

.page-inbox .alert {
    margin: 0 0 0.75rem;
}

.inbox-workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    height: calc(100vh - 2.5rem);
    max-height: calc(100vh - 2.5rem);
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.inbox-list-panel {
    width: 380px;
    max-width: 42%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: #fff;
}

.inbox-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem 0.75rem;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
    border-bottom: 1px solid var(--border);
}

.inbox-list-heading {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.inbox-list-heading .bi-inbox {
    color: var(--wa-green-dark);
}

.inbox-unread-pill {
    display: inline-flex;
    align-items: center;
    margin-left: 0.5rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 0.7rem;
    font-weight: 700;
}

.inbox-icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #64748b;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.inbox-icon-btn:hover {
    background: #f1f5f9;
    color: var(--wa-teal);
}

.inbox-list-toolbar {
    padding: 0.65rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.inbox-search-wrap {
    position: relative;
}

.inbox-search-wrap .bi-search {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.inbox-search-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.55rem 2.35rem 0.55rem 2.35rem;
    font-size: 0.875rem;
    background: #f8fafc;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.inbox-search-clear {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #94a3b8;
    padding: 0;
    line-height: 1;
    font-size: 1.05rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.inbox-search-clear:hover {
    color: #64748b;
}

.inbox-search-clear:focus {
    outline: none;
    color: var(--wa-teal);
}

.inbox-search-input:focus {
    outline: none;
    border-color: var(--wa-green);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.inbox-filter-form .inbox-status-filter {
    width: 100%;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

.inbox-segmented {
    display: flex;
    gap: 0.35rem;
    padding: 0.5rem 0.85rem;
    border-bottom: 1px solid var(--border);
}

.inbox-segment {
    flex: 1;
    text-align: center;
    padding: 0.4rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    background: #f1f5f9;
    transition: background 0.2s, color 0.2s;
}

.inbox-segment:hover {
    background: #e2e8f0;
    color: #334155;
}

.inbox-segment.active {
    background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.35);
}

.inbox-conversation-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.inbox-empty-list,
.inbox-thread-empty {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: #94a3b8;
}

.inbox-empty-list .bi,
.inbox-thread-empty .bi {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.inbox-conv-item {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.inbox-conv-item:hover {
    background: #f8fafc;
}

.inbox-conv-item.active {
    background: #ecfdf5;
    box-shadow: inset 3px 0 0 var(--wa-green);
}

.inbox-conv-item.unread {
    background: #fffbeb;
}

.inbox-conv-item.unread.active {
    background: #ecfdf5;
}

.inbox-conv-body {
    min-width: 0;
    width: 100%;
}

.inbox-conv-top,
.inbox-conv-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.inbox-conv-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-conv-time {
    font-size: 0.72rem;
    color: #94a3b8;
    flex-shrink: 0;
}

.inbox-conv-preview {
    font-size: 0.8125rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.inbox-preview-tick {
    font-size: 0.75rem;
    margin-right: 0.15rem;
    color: #94a3b8;
}

.inbox-tick-read {
    color: #3b82f6 !important;
}

.inbox-conv-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #25d366;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.inbox-conv-status {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.inbox-conv-groups {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-chat-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #e5ddd5 url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4cdc4' fill-opacity='0.35'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.inbox-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    color: #64748b;
}

.inbox-chat-empty-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
    color: #fff;
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.35);
}

.inbox-chat-empty h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 0.5rem;
}

.inbox-chat-empty-badge {
    margin-top: 1rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: #fee2e2;
    color: #b91c1c;
    font-weight: 600;
    font-size: 0.8125rem;
}

.inbox-chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.1rem;
    background: #f0f2f5;
    border-bottom: 1px solid #d1d7db;
    flex-shrink: 0;
}

.inbox-back-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #334155;
    text-decoration: none;
    background: #fff;
    border: 1px solid #d1d7db;
}

.inbox-chat-name {
    font-weight: 700;
    font-size: 1rem;
    color: #111b21;
}

.inbox-chat-meta {
    font-size: 0.75rem;
    color: #667781;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.inbox-chat-thread {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    overscroll-behavior: contain;
}

.inbox-chat-panel.is-loading {
    opacity: 0.65;
    pointer-events: none;
}

.inbox-msg-row {
    display: flex;
    margin-bottom: 0.35rem;
}

.inbox-msg-row--in {
    justify-content: flex-start;
}

.inbox-msg-row--out {
    justify-content: flex-end;
}

.inbox-chat-composer {
    padding: 0.75rem 1rem 0.85rem;
    background: #f0f2f5;
    border-top: 1px solid #d1d7db;
    flex-shrink: 0;
}

.inbox-chat-composer--readonly {
    text-align: center;
}

.inbox-composer-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.35rem 0.35rem 1rem;
    border: 1px solid #d1d7db;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.inbox-composer-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.9375rem;
    background: transparent;
    min-width: 0;
}

.inbox-composer-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s;
}

.inbox-composer-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.inbox-composer-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.7rem;
    color: #667781;
    text-align: center;
}

/* Chat bubbles */
.chat-bubble {
    max-width: min(75%, 520px);
    padding: 0.45rem 0.65rem 0.35rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    line-height: 1.45;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.08);
    position: relative;
}

.chat-in {
    background: #fff;
    color: #111b21;
    border-bottom-left-radius: 0.15rem;
}

.chat-out {
    background: #d9fdd3;
    color: #111b21;
    border-bottom-right-radius: 0.15rem;
}

.chat-bubble-body {
    word-break: break-word;
}

.chat-bubble-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    margin-top: 0.2rem;
    flex-wrap: wrap;
}

.chat-bubble-time {
    font-size: 0.68rem;
    color: #667781;
}

.chat-bubble-tick {
    font-size: 0.8rem;
    color: #8696a0;
}

.chat-bubble-tick.inbox-tick-read {
    color: #53bdeb;
}

.chat-source-tag {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #94a3b8;
    margin-right: auto;
}

.chat-bubble-error {
    margin-top: 0.35rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.35rem;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 0.75rem;
}

.chat-template-image img {
    max-height: 180px;
    width: 100%;
    object-fit: cover;
    border-radius: 0.35rem;
    margin-bottom: 0.35rem;
}

.chat-reaction {
    opacity: 0.9;
    font-size: 1.25rem;
}

.chat-thread {
    max-height: 450px;
    overflow-y: auto;
    background: #f8fafc;
}

.contact-chat-thread {
    max-height: 520px;
}

@media (max-width: 767.98px) {
    .page-inbox .app-main--inbox {
        padding: 0;
        min-height: 0;
        height: calc(100vh - 3.5rem);
        height: calc(100dvh - 3.5rem);
        height: calc(100svh - 3.5rem);
        max-height: calc(100vh - 3.5rem);
        max-height: calc(100dvh - 3.5rem);
        max-height: calc(100svh - 3.5rem);
    }

    .page-inbox .alert {
        margin: 0.5rem 0.5rem 0;
        flex-shrink: 0;
    }

    .inbox-workspace {
        height: 100%;
        max-height: 100%;
        min-height: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .inbox-list-panel {
        width: 100%;
        max-width: 100%;
    }

    .inbox-workspace--chat-open .inbox-list-panel {
        display: none;
    }

    .inbox-workspace:not(.inbox-workspace--chat-open) .inbox-chat-panel {
        display: none;
    }

    .inbox-workspace--chat-open .inbox-chat-panel {
        display: flex;
        width: 100%;
        min-height: 0;
    }

    .inbox-chat-header {
        padding: 0.65rem 0.85rem;
        gap: 0.6rem;
    }

    .inbox-chat-name {
        font-size: 0.95rem;
        line-height: 1.25;
    }

    .inbox-chat-meta {
        gap: 0.2rem 0.5rem;
    }

    .inbox-chat-groups {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .inbox-chat-composer {
        padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    }
}

/* Legacy inbox table (unused) */
.inbox-row-unread {
    background: #fff7ed !important;
    box-shadow: inset 4px 0 0 #f97316;
}

.inbox-row-unread:hover {
    background: #ffedd5 !important;
}

.inbox-row-unread .inbox-contact-name {
    font-weight: 600;
    color: #0f172a;
}

.inbox-contact-name {
    font-weight: 500;
    font-size: 0.8125rem;
    color: #1e293b;
}

.inbox-unread-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ef4444;
    margin-right: 0.45rem;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}

.inbox-contact-cell {
    display: flex;
    align-items: center;
}

.image-library-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #fff;
}

.image-library-preview {
    background: #f8fafc;
    aspect-ratio: 16 / 10;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-library-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.image-library-meta .image-url-field {
    font-size: 0.72rem;
}

.campaign-meta-rows {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.campaign-meta-row {
    display: grid;
    gap: 1rem 2rem;
    align-items: baseline;
}

.campaign-meta-row--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.campaign-meta-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    min-width: 0;
}

.campaign-meta-label {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.campaign-meta-value {
    color: var(--text-secondary);
    min-width: 0;
    word-break: break-word;
}

@media (max-width: 991px) {
    .campaign-meta-row--3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .campaign-meta-row--3 {
        grid-template-columns: 1fr;
    }
}

.campaign-statistics {
    overflow: hidden;
    background: var(--card-bg);
    color: var(--text-primary);
}

.campaign-statistics-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-primary);
}

.campaign-statistics-header h5 {
    color: var(--text-primary);
}

.campaign-stat-note {
    background: var(--hover-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.65rem;
    color: var(--text-muted);
}

.campaign-statistics-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0;
    background: var(--card-bg);
}

.campaign-stat-card {
    padding: 1rem 1.1rem;
    border-right: 1px solid var(--border);
    min-height: 140px;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
}

.campaign-stat-card:last-child {
    border-right: none;
}

.campaign-stat-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.35rem;
}

.campaign-stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.campaign-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.35rem;
    line-height: 1.2;
}

.campaign-stat-processing {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.campaign-stat-link {
    margin-top: auto;
    padding-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--dash-accent, var(--wa-green, #25D366));
    text-decoration: none;
}

.campaign-stat-link:hover {
    text-decoration: underline;
    color: var(--dash-accent, var(--wa-green, #25D366));
}

.campaign-stat-refresh {
    text-decoration: none;
    font-size: 0.875rem;
    color: var(--dash-accent, var(--wa-green)) !important;
}

html[data-theme="dark"] .campaign-meta-label {
    color: #f8fafc !important;
}
html[data-theme="dark"] .campaign-meta-value {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .campaign-statistics,
html[data-theme="dark"] .campaign-statistics-header,
html[data-theme="dark"] .campaign-statistics-grid,
html[data-theme="dark"] .campaign-stat-card {
    background: var(--card-bg) !important;
    color: var(--text-primary) !important;
}
html[data-theme="dark"] .campaign-statistics-header h5 {
    color: #f8fafc !important;
}
html[data-theme="dark"] .campaign-stat-label,
html[data-theme="dark"] .campaign-stat-processing,
html[data-theme="dark"] .campaign-stat-note {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .campaign-stat-value {
    color: #ffffff !important;
}
html[data-theme="dark"] .campaign-stat-link,
html[data-theme="dark"] .campaign-stat-refresh {
    color: #00ffc2 !important;
}
html[data-theme="dark"] .campaign-stat-info {
    color: #94a3b8 !important;
}

@media (max-width: 1199px) {
    .campaign-statistics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .campaign-stat-card:nth-child(3) {
        border-right: none;
    }

    .campaign-stat-card:nth-child(n+4) {
        border-top: 1px solid var(--border);
    }
}

@media (max-width: 767px) {
    .campaign-statistics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .campaign-stat-card:nth-child(2n) {
        border-right: none;
    }

    .campaign-stat-card:nth-child(n+3) {
        border-top: 1px solid var(--border);
    }
}

.chat-source {
    text-transform: capitalize;
    font-weight: 600;
}

.chat-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.chat-reaction {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.9rem;
}

.chat-reaction-emoji {
    font-size: 1.75rem;
    line-height: 1;
}

.chat-reaction-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.inbox-status-filter {
    min-width: 9.5rem;
    width: auto;
    font-size: 0.8125rem;
}

/* DataTables — compact controls */
.dataTables_wrapper {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding-left: 1.1rem;
    padding-right: 1.1rem;
    margin: 0;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding-top: 0.75rem;
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 0.35rem 0.65rem;
    font-size: 0.8125rem;
    min-height: 2rem;
    background: var(--input-bg);
    color: var(--input-color);
}

.dataTables_wrapper .dataTables_length select {
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    padding: 0.2rem 1.75rem 0.2rem 0.5rem;
    min-height: 2rem;
    background: var(--input-bg);
    color: var(--input-color);
    border-color: var(--border);
}

.dataTables_wrapper .dataTables_info {
    font-size: 0.75rem;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    font-size: 0.8125rem !important;
    padding: 0.25rem 0.65rem !important;
    border-radius: 6px !important;
}

.dataTables_wrapper table.dataTable {
    margin-top: 0.5rem !important;
    margin-bottom: 0 !important;
}

/* App confirm modal */
.app-confirm-modal .modal-content {
    border-radius: 1rem;
    overflow: hidden;
}

.app-confirm-modal-header {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 55%, #075e54 100%);
    padding: 1.35rem 1rem 1.1rem;
    text-align: center;
}

.app-confirm-modal-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    border: 2px solid rgba(255, 255, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.35rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.app-confirm-modal-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 0.45rem 0.75rem;
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.12), rgba(18, 140, 126, 0.08));
    border: 1px solid rgba(37, 211, 102, 0.25);
    border-radius: var(--radius-sm);
    word-break: break-word;
}

.app-confirm-modal .modal-footer .btn-light {
    border: 1px solid var(--border);
    font-weight: 500;
}

/* Error pages */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Installer steps */
.install-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.install-step {
    flex: 1;
    min-width: 60px;
    text-align: center;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background: #f1f5f9;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.install-step.active {
    background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
    color: #fff;
}

.install-step.done { background: #dcfce7; color: #15803d; }

/* Offcanvas mobile sidebar */
@media (min-width: 768px) {
    .offcanvas-backdrop {
        display: none !important;
    }
}

.offcanvas.app-offcanvas {
    background: var(--sidebar-bg);
    color: #fff;
    width: 280px;
}

.offcanvas.app-offcanvas .nav-link { color: #94a3b8; }
.offcanvas.app-offcanvas .nav-link.active { color: #fff; }

.offcanvas.app-offcanvas .offcanvas-body {
    min-height: 0;
}

.offcanvas.app-offcanvas .sidebar-user {
    flex-shrink: 0;
    margin-left: 0;
    margin-right: 0;
}

.offcanvas.app-offcanvas .sidebar-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.log-viewer {
    max-height: 500px;
    overflow: auto;
    padding: 1rem 1.25rem;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.8125rem;
    line-height: 1.5;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* WhatsApp template preview (campaign form) */
.template-preview-card {
    overflow: visible;
}

.template-preview-body {
    padding: 1rem 1.25rem 1.25rem;
}

.wa-preview-phone {
    background: linear-gradient(180deg, #e5ddd5 0%, #d9cfc7 100%);
    border-radius: var(--radius);
    padding: 1rem;
    max-height: min(72vh, 640px);
    overflow-x: hidden;
    overflow-y: auto;
    color: #111b21;
}

.wa-preview-bubble {
    background: #fff;
    color: #111b21;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    overflow: visible;
    max-width: 100%;
}

.wa-preview-header-img img {
    width: 100%;
    display: block;
    max-height: 220px;
    object-fit: contain;
    background: #f8fafc;
}

.wa-preview-header-img.wa-preview-placeholder {
    background: #f1f5f9;
    color: #94a3b8;
    text-align: center;
    padding: 2rem;
    font-size: 0.875rem;
}

.wa-preview-header-text {
    padding: 0.75rem 1rem 0;
    font-weight: 700;
    font-size: 0.9375rem;
    line-height: 1.45;
    color: #111b21;
}

.wa-preview-body {
    padding: 0.65rem 1rem 1rem;
    font-size: 0.875rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: #111b21;
}

.wa-preview-body mark,
.wa-preview-header-text mark {
    background: #dcfce7;
    color: #166534;
    padding: 0 0.2rem;
    border-radius: 3px;
}

.wa-preview-body mark.wa-var-empty,
.wa-preview-header-text mark.wa-var-empty {
    background: #fef3c7;
    color: #92400e;
}

.wa-preview-footer {
    padding: 0 1rem 0.85rem;
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.45;
}

.wa-preview-buttons {
    border-top: 1px solid #e2e8f0;
}

.wa-preview-btn {
    text-align: center;
    padding: 0.65rem;
    color: #0ea5e9;
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 1px solid #e2e8f0;
}

.wa-preview-btn:last-child {
    border-bottom: none;
}

/* Developer API panel (Settings page) */
.dev-api-panel {
    background: #f8fafc;
}

.dev-api-hero {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.dev-api-key-card {
    background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.dev-api-key-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.dev-api-key-input {
    font-size: 0.95rem !important;
    color: #0f172a;
    word-break: break-all;
}

.dev-api-key-watermark {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 5rem;
    color: rgba(148, 163, 184, 0.15);
    pointer-events: none;
}

.dev-api-body {
    min-height: 420px;
}

.dev-api-sidebar {
    background: #eef2f7;
    border-right: 1px solid #e2e8f0;
}

.dev-api-sidebar-inner {
    padding: 1rem 0;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
}

.dev-api-nav-group + .dev-api-nav-group {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #dde4ed;
}

.dev-api-nav-heading {
    padding: 0.5rem 1.25rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
}

.dev-api-nav-link {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 0.55rem 1.25rem;
    font-size: 0.875rem;
    color: #334155;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.dev-api-nav-link:hover {
    background: rgba(255, 255, 255, 0.6);
    color: #0f172a;
}

.dev-api-nav-link.active {
    background: #fff;
    color: #2563eb;
    border-left-color: #2563eb;
    font-weight: 600;
}

.dev-api-content {
    background: #f8fafc;
    padding: 1.25rem 1.5rem 1.5rem;
}

.dev-api-endpoint-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.dev-api-url-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #f5f0e8;
    border: 1px solid #e8dfd0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.dev-api-url-box code {
    flex: 1;
    font-size: 0.8125rem;
    color: #334155;
    word-break: break-all;
    background: transparent;
}

.dev-api-params {
    border-top: 1px solid #f1f5f9;
    padding-top: 0.5rem;
}

.dev-api-param-row {
    display: flex;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.dev-api-param-row:last-child {
    border-bottom: none;
}

.dev-api-param-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #eff6ff;
    color: #2563eb;
    font-size: 0.8125rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dev-api-param-body {
    flex: 1;
    min-width: 0;
}

@media (max-width: 991.98px) {
    .dev-api-sidebar {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .dev-api-sidebar-inner {
        position: static;
        max-height: none;
    }

    .dev-api-nav-group {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.25rem;
        padding: 0 0.75rem 0.5rem;
    }

    .dev-api-nav-heading {
        width: 100%;
        padding-left: 0.5rem;
    }

    .dev-api-nav-link {
        width: auto;
        border-left: none;
        border-radius: 999px;
        padding: 0.35rem 0.75rem;
        background: #fff;
        border: 1px solid #e2e8f0;
    }

    .dev-api-nav-link.active {
        border-color: #2563eb;
        background: #eff6ff;
    }
}

/* Template create wizard */
.tpl-create-topbar {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.tpl-wizard-accordion .accordion-item {
    border: 1px solid #e2e8f0;
    border-radius: 12px !important;
    margin-bottom: 1rem;
    overflow: hidden;
}

.tpl-wizard-accordion .accordion-button {
    font-weight: 600;
    background: #f8fafc;
    box-shadow: none;
}

.tpl-wizard-accordion .accordion-button:not(.collapsed) {
    background: #fff;
    color: #0f172a;
}

.tpl-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #dcfce7;
    color: #15803d;
    font-size: 0.8125rem;
    font-weight: 700;
    margin-right: 0.65rem;
}

.tpl-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tpl-pill {
    margin: 0;
    cursor: pointer;
}

.tpl-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tpl-pill span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.tpl-pill input:checked + span {
    background: #ecfdf5;
    border-color: #22c55e;
    color: #15803d;
}

.tpl-pill-check {
    display: none;
}

.tpl-pill input:checked + span .tpl-pill-check {
    display: inline;
}

.tpl-pill-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.tpl-type-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.tpl-type-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    margin: 0;
    transition: border-color 0.15s, background 0.15s;
}

.tpl-type-card:hover {
    border-color: #86efac;
    background: #f8fafc;
}

.tpl-type-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tpl-type-card input:checked ~ .tpl-type-radio {
    display: none;
}

.tpl-type-card input:checked ~ .tpl-type-radio-on {
    display: block;
}

.tpl-type-card input:checked + .tpl-type-body {
    color: #0f172a;
}

.tpl-type-card:has(input:checked) {
    border-color: #22c55e;
    background: #f0fdf4;
}

.tpl-type-radio-on {
    display: none;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.tpl-type-radio {
    font-size: 1.1rem;
    color: #cbd5e1;
    flex-shrink: 0;
}

.tpl-type-body {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.tpl-type-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    flex-shrink: 0;
}

.tpl-type-card-disabled {
    cursor: not-allowed;
    background: #f8fafc;
}

.wa-preview-chat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    background: #075e54;
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 12px 12px 0 0;
}

.wa-preview-business-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tpl-create-preview .wa-preview-phone {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.tpl-create-preview .wa-preview-bubble {
    border-radius: 0 0 8px 8px;
}

.wa-preview-ios {
    border-radius: 28px !important;
    border: 3px solid #1e293b !important;
}

.tpl-var-samples {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem 1.15rem;
}

.tpl-var-section-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.tpl-var-sample-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.tpl-var-sample-row:last-child {
    margin-bottom: 0;
}

.tpl-var-tag {
    flex-shrink: 0;
    min-width: 52px;
    padding: 0.4rem 0.55rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-family: ui-monospace, monospace;
    color: #334155;
    text-align: center;
}

.tpl-var-sample-row .form-control {
    min-width: 0;
}

@media (max-width: 991.98px) {
    .tpl-create-preview.sticky-top {
        position: static !important;
    }

    .tpl-create-topbar .btn-wa#tpl-submit-btn {
        width: 100%;
    }
}

/* Theme toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0;
}
.theme-toggle:hover {
    border-color: var(--dash-accent);
    color: var(--dash-accent);
}
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }

.app-main-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

@media (max-width: 767.98px) {
    .app-main-toolbar {
        display: none !important;
    }
}

/* ==========================================================================
   Global dark mode — applies across every authenticated page
   ========================================================================== */
html[data-theme="dark"] body.app-body {
    background: var(--body-bg);
    color: var(--text-primary);
}

html[data-theme="dark"] .app-main,
html[data-theme="dark"] .app-main h1,
html[data-theme="dark"] .app-main h2,
html[data-theme="dark"] .app-main h3,
html[data-theme="dark"] .app-main h4,
html[data-theme="dark"] .app-main h5,
html[data-theme="dark"] .app-main h6,
html[data-theme="dark"] .page-header h1,
html[data-theme="dark"] .page-header h2 {
    color: var(--text-primary);
}

html[data-theme="dark"] .app-main a:not(.btn):not(.nav-link):not(.page-link):not(.dash-action-btn):not(.inbox-conv-item):not(.inbox-segment):not(.inbox-icon-btn):not(.inbox-back-btn) {
    color: var(--link-color);
}
html[data-theme="dark"] .app-main a:not(.btn):not(.nav-link):not(.page-link):not(.inbox-conv-item):not(.inbox-segment):hover {
    color: #5affe0;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .card-modern,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .stat-tile,
html[data-theme="dark"] .dashboard-date-filter,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .accordion-item,
html[data-theme="dark"] .accordion-button {
    background: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .accordion-button:not(.collapsed) {
    background: var(--hover-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] textarea.form-control {
    background-color: var(--input-bg) !important;
    color: var(--input-color) !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-select:disabled,
html[data-theme="dark"] .form-control[readonly] {
    background-color: #141414 !important;
    color: #94a3b8 !important;
}

html[data-theme="dark"] .input-group-text {
    background-color: #222 !important;
    color: #e2e8f0 !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] .form-label,
html[data-theme="dark"] label {
    color: var(--label-color) !important;
}

html[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: #f1f5f9;
    --bs-table-border-color: #2a2a2a;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
    --bs-table-hover-color: #ffffff;
    color: #f1f5f9;
}
html[data-theme="dark"] .table thead th {
    background: #1a1a1a !important;
    color: #94a3b8 !important;
    border-bottom-color: #2a2a2a !important;
}
html[data-theme="dark"] .table tbody td,
html[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: transparent !important;
    color: #f1f5f9 !important;
    border-bottom-color: #2a2a2a !important;
}
html[data-theme="dark"] .table a:not(.btn) {
    color: #f8fafc !important;
}
html[data-theme="dark"] .table a:not(.btn):hover {
    color: var(--dash-accent) !important;
}

html[data-theme="dark"] .btn-outline-secondary {
    color: #e2e8f0 !important;
    background: #1c1c1c !important;
    border-color: #3f3f46 !important;
}
html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-theme="dark"] .btn-outline-secondary:focus {
    color: #04150f !important;
    background: var(--dash-accent) !important;
    border-color: var(--dash-accent) !important;
}
html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-success {
    color: #86efac !important;
    border-color: #166534 !important;
    background: transparent !important;
}
html[data-theme="dark"] .btn-outline-danger {
    color: #fca5a5 !important;
    border-color: #7f1d1d !important;
    background: transparent !important;
}
html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(1);
}

html[data-theme="dark"] .alert-success {
    background: #052e1f !important;
    border: 1px solid #14532d !important;
    color: #bbf7d0 !important;
}
html[data-theme="dark"] .alert-danger {
    background: #450a0a !important;
    border: 1px solid #7f1d1d !important;
    color: #fecaca !important;
}
html[data-theme="dark"] .alert-warning {
    background: #422006 !important;
    border: 1px solid #854d0e !important;
    color: #fde68a !important;
}
html[data-theme="dark"] .alert-info {
    background: #082f49 !important;
    border: 1px solid #075985 !important;
    color: #bae6fd !important;
}
html[data-theme="dark"] .alert-secondary {
    background: #1f2937 !important;
    border: 1px solid #374151 !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] .badge-draft {
    background: #334155 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .badge-completed,
html[data-theme="dark"] .bg-success {
    background: #14532d !important;
    color: #bbf7d0 !important;
}
html[data-theme="dark"] .badge-running,
html[data-theme="dark"] .bg-primary {
    background: #1e3a8a !important;
    color: #bfdbfe !important;
}
html[data-theme="dark"] .badge-paused,
html[data-theme="dark"] .bg-warning {
    background: #78350f !important;
    color: #fde68a !important;
}
html[data-theme="dark"] .badge-cancelled,
html[data-theme="dark"] .bg-danger {
    background: #7f1d1d !important;
    color: #fecaca !important;
}
html[data-theme="dark"] .badge-scheduled,
html[data-theme="dark"] .bg-info {
    background: #312e81 !important;
    color: #c7d2fe !important;
}
html[data-theme="dark"] .bg-secondary {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .nav-tabs {
    border-bottom-color: var(--border);
}
html[data-theme="dark"] .nav-tabs .nav-link {
    color: var(--text-muted);
}
html[data-theme="dark"] .nav-tabs .nav-link.active {
    background: var(--card-bg);
    color: var(--text-primary);
    border-color: var(--border) var(--border) var(--card-bg);
}
html[data-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background: var(--hover-bg);
    color: #fff;
}
html[data-theme="dark"] .dropdown-divider {
    border-top-color: var(--border);
}

html[data-theme="dark"] .pagination .page-link {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text-primary);
}
html[data-theme="dark"] .pagination .page-item.active .page-link {
    background: var(--wa-green-dark);
    border-color: var(--wa-green-dark);
    color: #fff;
}
html[data-theme="dark"] .pagination .page-item.disabled .page-link {
    background: #141414;
    color: #64748b;
}

html[data-theme="dark"] .dataTables_wrapper,
html[data-theme="dark"] .dataTables_wrapper .dataTables_info,
html[data-theme="dark"] .dataTables_wrapper label {
    color: var(--text-muted) !important;
}
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--text-primary) !important;
    background: var(--card-bg) !important;
    border: 1px solid var(--border) !important;
}
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current,
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--wa-green-dark) !important;
    border-color: var(--wa-green-dark) !important;
    color: #fff !important;
}

html[data-theme="dark"] .app-topbar {
    background: var(--card-bg);
    border-bottom-color: var(--border);
    color: var(--text-primary);
}

html[data-theme="dark"] .page-inbox .app-main--inbox {
    background: var(--body-bg);
    color: var(--text-primary);
}

html[data-theme="dark"] .inbox-workspace {
    background: #111b21;
    border-color: #2a3942;
}

html[data-theme="dark"] .inbox-list-panel {
    background: #111b21;
    border-right-color: #2a3942;
}

html[data-theme="dark"] .inbox-list-header {
    background: #202c33;
    border-bottom-color: #2a3942;
}

html[data-theme="dark"] .inbox-list-heading,
html[data-theme="dark"] .inbox-conv-name,
html[data-theme="dark"] .inbox-chat-name,
html[data-theme="dark"] .inbox-chat-empty h2 {
    color: #e9edef !important;
}

html[data-theme="dark"] .inbox-icon-btn {
    color: #aebac1;
}
html[data-theme="dark"] .inbox-icon-btn:hover {
    background: #2a3942;
    color: #e9edef;
}

html[data-theme="dark"] .inbox-list-toolbar,
html[data-theme="dark"] .inbox-segmented {
    border-bottom-color: #2a3942;
}

html[data-theme="dark"] .inbox-search-input {
    background: #202c33 !important;
    border-color: #2a3942 !important;
    color: #e9edef !important;
}
html[data-theme="dark"] .inbox-search-input:focus {
    background: #111b21 !important;
    border-color: var(--wa-green) !important;
    color: #e9edef !important;
}
html[data-theme="dark"] .inbox-search-input::placeholder {
    color: #8696a0 !important;
}
html[data-theme="dark"] .inbox-search-wrap .bi-search,
html[data-theme="dark"] .inbox-search-clear {
    color: #8696a0;
}

html[data-theme="dark"] .inbox-status-filter {
    background: #202c33 !important;
    border-color: #2a3942 !important;
    color: #e9edef !important;
}

html[data-theme="dark"] .inbox-segment {
    background: #202c33;
    color: #aebac1;
}
html[data-theme="dark"] .inbox-segment:hover {
    background: #2a3942;
    color: #e9edef;
}
html[data-theme="dark"] .inbox-segment.active {
    background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
    color: #fff;
}

html[data-theme="dark"] .inbox-conv-item {
    border-bottom-color: #2a3942;
    color: #e9edef;
    background: transparent;
}
html[data-theme="dark"] .inbox-conv-item:hover {
    background: #202c33;
}
html[data-theme="dark"] .inbox-conv-item.active,
html[data-theme="dark"] .inbox-conv-item.unread.active {
    background: #2a3942;
}
html[data-theme="dark"] .inbox-conv-item.unread {
    background: #1a2730;
}

html[data-theme="dark"] .inbox-conv-preview,
html[data-theme="dark"] .inbox-conv-time,
html[data-theme="dark"] .inbox-conv-groups,
html[data-theme="dark"] .inbox-chat-meta,
html[data-theme="dark"] .inbox-empty-list,
html[data-theme="dark"] .inbox-thread-empty,
html[data-theme="dark"] .inbox-chat-empty,
html[data-theme="dark"] .inbox-composer-hint {
    color: #8696a0 !important;
}

html[data-theme="dark"] .inbox-chat-panel {
    background-color: #0b141a;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23182229' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

html[data-theme="dark"] .inbox-chat-header,
html[data-theme="dark"] .inbox-chat-composer {
    background: #202c33;
    border-color: #2a3942;
}

html[data-theme="dark"] .inbox-back-btn {
    background: #111b21;
    border-color: #2a3942;
    color: #e9edef;
}

html[data-theme="dark"] .inbox-composer-inner {
    background: #2a3942;
    border-color: #3b4a54;
}
html[data-theme="dark"] .inbox-composer-input {
    color: #e9edef;
    background: transparent;
}
html[data-theme="dark"] .inbox-composer-input::placeholder {
    color: #8696a0;
}

html[data-theme="dark"] .chat-in {
    background: #202c33;
    color: #e9edef;
}
html[data-theme="dark"] .chat-out {
    background: #005c4b;
    color: #e9edef;
}
html[data-theme="dark"] .chat-bubble-body,
html[data-theme="dark"] .chat-in,
html[data-theme="dark"] .chat-out {
    color: #e9edef !important;
}
html[data-theme="dark"] .chat-bubble-time,
html[data-theme="dark"] .chat-source-tag {
    color: #8696a0 !important;
}
html[data-theme="dark"] .chat-bubble-tick {
    color: #8696a0;
}
html[data-theme="dark"] .chat-bubble-error {
    background: #3f1d1d;
    color: #fca5a5;
}

html[data-theme="dark"] .inbox-unread-pill,
html[data-theme="dark"] .inbox-chat-empty-badge {
    background: #3f1d1d;
    color: #fca5a5;
}

html[data-theme="dark"] .chat-reaction-label {
    color: #8696a0;
}

html[data-theme="dark"] code,
html[data-theme="dark"] pre,
html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .bg-white {
    background-color: #1c1c1c !important;
    color: #e2e8f0 !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] .text-dark {
    color: #f1f5f9 !important;
}
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-start,
html[data-theme="dark"] .border-end {
    border-color: var(--border) !important;
}
html[data-theme="dark"] .border-success {
    border-color: #22c55e !important;
}
html[data-theme="dark"] .border-primary {
    border-color: #3b82f6 !important;
}
html[data-theme="dark"] .border-danger {
    border-color: #ef4444 !important;
}
html[data-theme="dark"] .border-warning {
    border-color: #eab308 !important;
}
html[data-theme="dark"] .border-info {
    border-color: #38bdf8 !important;
}

html[data-theme="dark"] .progress {
    background-color: #2a2a2a;
}
html[data-theme="dark"] hr {
    border-color: var(--border);
    opacity: 1;
}

html[data-theme="dark"] .stat-tile-icon.primary { background: #1e3a8a; color: #93c5fd; }
html[data-theme="dark"] .stat-tile-icon.info { background: #0c4a6e; color: #7dd3fc; }
html[data-theme="dark"] .stat-tile-icon.success { background: #14532d; color: #86efac; }
html[data-theme="dark"] .stat-tile-icon.warning { background: #78350f; color: #fcd34d; }
html[data-theme="dark"] .stat-tile-icon.danger { background: #7f1d1d; color: #fca5a5; }

html[data-theme="dark"] .btn-outline-secondary:active,
html[data-theme="dark"] .btn-check:checked + .btn-outline-secondary {
    color: #04150f !important;
    background: var(--dash-accent) !important;
    border-color: var(--dash-accent) !important;
}

/* Placeholders & helper copy — keep readable on dark surfaces */
html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .form-select::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}
html[data-theme="dark"] .form-text,
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] small.text-muted,
html[data-theme="dark"] .small.text-muted {
    color: #94a3b8 !important;
}

/* Light alert boxes (e.g. Template Variables helper) */
html[data-theme="dark"] .alert-light {
    background: #1c1c1c !important;
    color: #e2e8f0 !important;
    border-color: #3f3f46 !important;
}
html[data-theme="dark"] .alert-light strong {
    color: #f8fafc !important;
}
html[data-theme="dark"] .alert-light .text-muted {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .alert-light code {
    background: #0a0a0a !important;
    color: #86efac !important;
    border: 1px solid #333 !important;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}
html[data-theme="dark"] .alert-light .btn-outline-success {
    color: #86efac !important;
    border-color: #22c55e !important;
    background: #052e16 !important;
}
html[data-theme="dark"] .alert-light .btn-outline-success:hover {
    color: #04150f !important;
    background: #4ade80 !important;
    border-color: #4ade80 !important;
}

/* Settings page + Developer API panel */
html[data-theme="dark"] .dev-api-panel {
    background: var(--card-bg) !important;
}
html[data-theme="dark"] .dev-api-hero {
    background: var(--hover-bg);
    border-bottom-color: var(--border);
    color: var(--text-primary);
}
html[data-theme="dark"] .dev-api-hero h2 {
    color: var(--text-primary);
}
html[data-theme="dark"] .dev-api-key-card {
    background: #1c1c1c;
    border-color: var(--border);
    box-shadow: none;
}
html[data-theme="dark"] .dev-api-key-input,
html[data-theme="dark"] .dev-api-key-input.form-control,
html[data-theme="dark"] .dev-api-key-input.form-control[readonly] {
    color: #f1f5f9 !important;
    background: transparent !important;
}
html[data-theme="dark"] .dev-api-key-watermark {
    color: rgba(148, 163, 184, 0.12);
}
html[data-theme="dark"] .dev-api-sidebar {
    background: #121212;
    border-right-color: var(--border);
}
html[data-theme="dark"] .dev-api-nav-group + .dev-api-nav-group {
    border-top-color: var(--border);
}
html[data-theme="dark"] .dev-api-nav-heading {
    color: #94a3b8;
}
html[data-theme="dark"] .dev-api-nav-link {
    color: #cbd5e1;
    background: transparent;
}
html[data-theme="dark"] .dev-api-nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
}
html[data-theme="dark"] .dev-api-nav-link.active {
    background: #1c1c1c;
    color: #00ffc2;
    border-left-color: #00ffc2;
}
html[data-theme="dark"] .dev-api-body {
    border-top-color: var(--border);
}
html[data-theme="dark"] .dev-api-content {
    background: #141414;
    color: var(--text-primary);
}
html[data-theme="dark"] .dev-api-endpoint-card {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text-primary);
    box-shadow: none;
}
html[data-theme="dark"] .dev-api-endpoint-card h3 {
    color: var(--text-primary);
}
html[data-theme="dark"] .dev-api-endpoint-card .text-primary {
    color: #7dd3fc !important;
}
html[data-theme="dark"] .dev-api-url-box {
    background: #0f0f0f;
    border-color: #2a2a2a;
}
html[data-theme="dark"] .dev-api-url-box code {
    background: transparent !important;
    color: #86efac !important;
}
html[data-theme="dark"] .dev-api-copy-url,
html[data-theme="dark"] .dev-api-copy-url.btn-light {
    filter: none;
    background: #1c1c1c !important;
    border: 1px solid var(--border) !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .dev-api-params,
html[data-theme="dark"] .dev-api-param-row {
    border-color: var(--border);
}
html[data-theme="dark"] .dev-api-param-num {
    background: #12352c;
    color: #00ffc2;
}
html[data-theme="dark"] .dev-api-panel code,
html[data-theme="dark"] .card-modern code {
    background: #0a0a0a !important;
    color: #86efac !important;
    border: 1px solid #333;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}
html[data-theme="dark"] .card-modern pre,
html[data-theme="dark"] .alert pre {
    background: #0f0f0f !important;
    color: #e2e8f0 !important;
    border: 1px solid var(--border);
}
html[data-theme="dark"] .alert-warning {
    background: #422006 !important;
    border-color: #854d0e !important;
    color: #fde68a !important;
}
html[data-theme="dark"] .alert-warning code {
    background: #1c1408 !important;
    color: #fde68a !important;
    border-color: #854d0e !important;
}
html[data-theme="dark"] .text-success {
    color: #4ade80 !important;
}

@media (max-width: 991.98px) {
    html[data-theme="dark"] .dev-api-sidebar {
        border-bottom-color: var(--border);
    }
    html[data-theme="dark"] .dev-api-nav-link {
        background: #1c1c1c;
        border-color: var(--border);
        color: #cbd5e1;
    }
    html[data-theme="dark"] .dev-api-nav-link.active {
        background: #12352c;
        border-color: #00ffc2;
        color: #00ffc2;
    }
}

/* WhatsApp preview must stay light bubble + dark text in both themes */
html[data-theme="dark"] .wa-preview-phone {
    background: linear-gradient(180deg, #e5ddd5 0%, #d9cfc7 100%) !important;
    color: #111b21 !important;
}
html[data-theme="dark"] .wa-preview-bubble,
html[data-theme="dark"] .wa-preview-bubble * {
    color: #111b21 !important;
}
html[data-theme="dark"] .wa-preview-bubble {
    background: #ffffff !important;
}
html[data-theme="dark"] .wa-preview-header-text,
html[data-theme="dark"] .wa-preview-body {
    color: #111b21 !important;
}
html[data-theme="dark"] .wa-preview-footer {
    color: #54656f !important;
}
html[data-theme="dark"] .wa-preview-btn {
    color: #027eb5 !important;
    border-bottom-color: #e2e8f0 !important;
}
html[data-theme="dark"] .wa-preview-buttons {
    border-top-color: #e2e8f0 !important;
}
html[data-theme="dark"] .wa-preview-body mark,
html[data-theme="dark"] .wa-preview-header-text mark {
    background: #dcfce7 !important;
    color: #14532d !important;
}
html[data-theme="dark"] .wa-preview-body mark.wa-var-empty,
html[data-theme="dark"] .wa-preview-header-text mark.wa-var-empty {
    background: #fef3c7 !important;
    color: #92400e !important;
}
html[data-theme="dark"] .wa-preview-meta .badge.bg-light,
html[data-theme="dark"] .template-preview-card .badge.bg-light {
    background: #334155 !important;
    color: #f1f5f9 !important;
}
html[data-theme="dark"] .btn-secondary {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #f8fafc !important;
}

/* Dashboard Pro */
.app-main--dashboard {
    padding-top: 1rem;
}

.dash-pro-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.dash-pro-title {
    font-size: clamp(1.35rem, 2.4vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0 0 0.25rem;
    color: var(--text-primary);
}
.dash-pro-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.dash-pro-unread {
    color: var(--dash-accent);
    font-weight: 600;
    text-decoration: none;
}
.dash-pro-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}
.dash-pro-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--dash-panel);
    color: var(--text-muted);
}
.dash-pro-pill.is-live {
    color: var(--dash-accent);
    border-color: color-mix(in srgb, var(--dash-accent) 35%, transparent);
    background: color-mix(in srgb, var(--dash-accent) 10%, transparent);
}
.dash-pro-pill.is-off {
    color: #f59e0b;
}
.dash-pro-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent);
}
.dash-pro-user {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}
.dash-pro-cta {
    background: #fff;
    color: #0f172a;
    border: none;
    font-weight: 700;
    border-radius: 999px;
    padding: 0.45rem 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
html[data-theme="dark"] .dash-pro-cta {
    background: #f8fafc;
    color: #0a0a0a;
}
.dash-pro-cta:hover {
    filter: brightness(0.95);
    color: inherit;
}
.dash-pro-filter {
    background: var(--dash-panel);
    border: 1px solid var(--dash-panel-border);
    border-radius: 1rem;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}
.dash-pro-filter .form-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}
.dash-pro-apply {
    background: var(--dash-accent);
    color: #04150f;
    border: none;
    font-weight: 700;
}
.dash-pro-apply:hover {
    filter: brightness(1.05);
    color: #04150f;
}

.dash-kpi {
    background: var(--dash-panel);
    border: 1px solid var(--dash-panel-border);
    border-radius: 1rem;
    padding: 1rem 1.1rem;
    height: 100%;
    box-shadow: var(--shadow);
}
.dash-kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.55rem;
}
.dash-kpi-top i {
    color: var(--dash-kpi-icon);
    font-size: 1.1rem;
}
.dash-kpi-value {
    font-size: clamp(1.6rem, 3vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
    color: var(--text-primary);
}
.dash-kpi-meta {
    margin-top: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
}
.dash-kpi-meta.positive { color: var(--dash-accent); }
.dash-kpi-meta.negative { color: #f87171; }

.dash-panel {
    background: var(--dash-panel);
    border: 1px solid var(--dash-panel-border);
    border-radius: 1rem;
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow);
}
.dash-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}
.dash-panel-head h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.dash-legend {
    display: flex;
    gap: 0.85rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}
.dash-legend .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.3rem;
}
.dash-legend .dot.sent { background: var(--dash-accent); }
.dash-legend .dot.read { background: var(--dash-chart-muted); }
.dash-chart-wrap {
    height: 260px;
    position: relative;
}

.dash-reach-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.dash-reach-label {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
}
.dash-reach-label strong {
    color: var(--text-primary);
    font-weight: 700;
}
.dash-reach-label span {
    color: var(--text-muted);
    white-space: nowrap;
}
.dash-reach-bar,
.dash-usage-bar {
    height: 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 22%, transparent);
    overflow: hidden;
}
.dash-reach-bar span,
.dash-usage-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--dash-accent);
}
.dash-usage-label {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--dash-accent);
    margin-bottom: 0.4rem;
}
.dash-usage-label span:last-child {
    color: var(--text-muted);
    font-weight: 600;
}

.dash-table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--dash-panel-border);
    color: var(--text-primary);
}
.dash-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted) !important;
    font-weight: 700;
    border-bottom-width: 1px;
    background: color-mix(in srgb, var(--text-muted) 8%, var(--dash-panel)) !important;
}
.dash-table tbody td {
    color: var(--text-primary) !important;
    font-weight: 600;
    background: transparent !important;
}
.dash-table tbody td.dash-num {
    color: var(--text-primary) !important;
}
.dash-campaign-link {
    color: var(--text-primary) !important;
    font-weight: 700;
    text-decoration: none;
}
.dash-campaign-link:hover {
    color: var(--dash-accent) !important;
}
.dash-open-rate {
    color: var(--dash-accent) !important;
    font-weight: 700;
}
html[data-theme="dark"] .dash-table thead th {
    background: #1c1c1c !important;
    color: #94a3b8 !important;
}
html[data-theme="dark"] .dash-table tbody td {
    color: #f1f5f9 !important;
}
html[data-theme="dark"] .dash-open-rate {
    color: #00ffc2 !important;
}
html[data-theme="dark"] .dash-campaign-link {
    color: #ffffff !important;
}
.dash-action-btn {
    display: inline-flex;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-primary);
    text-decoration: none;
    background: color-mix(in srgb, var(--text-muted) 12%, transparent);
}
.dash-action-btn:hover {
    color: var(--dash-accent);
    border-color: var(--dash-accent);
}
html[data-theme="dark"] .dash-action-btn {
    color: #e2e8f0;
    border-color: #3f3f46;
    background: #222;
}
.small-pill {
    font-size: 0.72rem;
    padding: 0.25rem 0.6rem;
}
