:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #06b6d4;
    --info-light: #cffafe;
    --sidebar: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-text: #94a3b8;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --transition: .2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

/* ========== AUTH PAGES ========== */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.auth-container { width: 100%; max-width: 420px; }

.auth-card {
    background: var(--card);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,.15);
    text-align: center;
}

.auth-logo {
    width: 64px; height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 28px;
}

.auth-card h1 { font-weight: 800; font-size: 28px; margin-bottom: 4px; }
.auth-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.auth-footer { margin-top: 24px; font-size: 14px; color: var(--text-muted); }
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

/* ========== ALERTS ========== */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: 20px; font-size: 14px; text-align: left;
    display: flex; align-items: center; gap: 8px;
}
.alert-error { background: var(--danger-light); color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #6ee7b7; }

/* ========== FORMS ========== */
.form-group { text-align: left; margin-bottom: 20px; }
.form-group label {
    display: block; margin-bottom: 6px;
    font-size: 13px; font-weight: 600; color: var(--text);
}
.form-group label i { width: 16px; color: var(--text-muted); }

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%; padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit;
    transition: var(--transition);
    outline: none; background: var(--card);
    color: var(--text);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--text-muted); }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; font-family: inherit;
    cursor: pointer; border: none; transition: var(--transition);
    text-decoration: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-block { width: 100%; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ========== APP LAYOUT ========== */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 260px; background: var(--sidebar);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100; transition: transform .3s ease;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex; align-items: center; gap: 12px;
    font-size: 22px; font-weight: 800; color: white;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand i {
    font-size: 24px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; color: var(--sidebar-text);
    text-decoration: none; font-size: 14px; font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active {
    background: var(--sidebar-hover); color: white;
    border-left-color: var(--primary);
}
.nav-item i { width: 20px; text-align: center; font-size: 15px; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px;
}
.sidebar-user .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--sidebar-hover);
    display: flex; align-items: center; justify-content: center;
    color: var(--sidebar-text); font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; }
.user-name { color: white; font-size: 13px; font-weight: 600; }
.user-role { color: var(--sidebar-text); font-size: 11px; }

.logout-btn { padding: 10px 20px !important; margin: 0 -20px; width: calc(100% + 40px); }
.logout-btn:hover { color: var(--danger) !important; }

/* Main wrapper */
.main-wrapper {
    flex: 1; margin-left: 260px;
    display: flex; flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    height: 64px; background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 32px; gap: 16px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}
.page-title { font-size: 20px; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.greeting { font-size: 14px; color: var(--text-muted); }
.greeting strong { color: var(--text); }
.menu-toggle {
    display: none; background: none; border: none;
    font-size: 20px; color: var(--text); cursor: pointer;
    padding: 4px;
}

/* Content */
.content-area { padding: 32px; flex: 1; }

/* ========== STATS GRID ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px; margin-bottom: 28px;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid transparent;
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-primary { border-left-color: var(--primary); }
.stat-success { border-left-color: var(--success); }
.stat-cyan { border-left-color: var(--info); }
.stat-warning { border-left-color: var(--warning); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.stat-primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-cyan .stat-icon { background: var(--info-light); color: var(--info); }
.stat-warning .stat-icon { background: var(--warning-light); color: var(--warning); }

.stat-content { display: flex; flex-direction: column; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat-value small { font-size: 16px; font-weight: 600; opacity: .6; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ========== CARDS ========== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}
.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-header h3 i { color: var(--primary); font-size: 14px; }
.card-body { padding: 24px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 24px; margin-bottom: 24px; }

/* ========== API KEY BOX ========== */
.api-key-box {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg); padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}
.api-key-box code { flex: 1; font-size: 13px; word-break: break-all; color: var(--primary); font-weight: 600; }
.api-usage p { margin-bottom: 4px; font-size: 13px; }
.api-usage code { font-size: 12px; background: var(--bg); padding: 2px 6px; border-radius: 4px; color: var(--primary); }
.api-usage details { margin-top: 12px; }
.api-usage summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.code-block {
    background: #1e293b; color: #e2e8f0;
    padding: 16px; border-radius: var(--radius-sm);
    font-size: 13px; overflow-x: auto;
    margin-top: 8px; line-height: 1.6;
}

/* ========== QUICK ACTIONS ========== */
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.action-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 20px; border-radius: var(--radius-sm);
    background: var(--bg); border: 1.5px solid var(--border);
    text-decoration: none; color: var(--text);
    font-size: 14px; font-weight: 600;
    transition: var(--transition); flex: 1; min-width: 140px;
}
.action-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.action-btn i { font-size: 18px; color: var(--primary); }

/* ========== TABLE ========== */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th {
    font-weight: 600; color: var(--text-muted);
    font-size: 12px; text-transform: uppercase;
    letter-spacing: .5px; background: var(--bg);
}
.table tbody tr:hover { background: rgba(99,102,241,.02); }
.table tbody tr:last-child td { border-bottom: none; }

/* ========== BADGES ========== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: #065f46; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-info { background: var(--info-light); color: #0e7490; }

.keyword-badge {
    background: var(--bg); padding: 4px 10px;
    border-radius: 6px; font-size: 13px; font-weight: 600;
    color: var(--primary); border: 1px solid var(--border);
}

/* ========== DEVICES ========== */
.page-actions {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.device-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}
.device-card:hover { box-shadow: var(--shadow-md); }

.device-header {
    padding: 20px; display: flex; align-items: center; gap: 14px;
    border-bottom: 1px solid var(--border);
}
.device-icon {
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--bg); display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: var(--text-muted);
    transition: var(--transition);
}
.device-icon.online { background: var(--success-light); color: var(--success); }
.device-meta { flex: 1; }
.device-meta h4 { font-size: 15px; font-weight: 700; }
.device-key { font-size: 11px; color: var(--text-muted); }

.status-dot {
    width: 10px; height: 10px; border-radius: 50%;
}
.status-connected { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.status-connecting { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,.2); animation: pulse 1.5s infinite; }
.status-disconnected { background: var(--border); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.device-body { padding: 16px 20px; }
.device-detail {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; font-size: 13px;
}
.device-detail .label { color: var(--text-muted); font-weight: 500; }

.device-actions {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px;
}
.inline-form { display: inline; }

/* ========== MODALS ========== */
.modal-overlay {
    display: none; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,23,42,.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal {
    background: var(--card);
    border-radius: 16px;
    width: 100%; max-width: 480px;
    box-shadow: 0 25px 50px rgba(0,0,0,.2);
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-header h3 i { color: var(--primary); }
.modal-close {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); border: none; font-size: 18px;
    cursor: pointer; color: var(--text-muted);
    transition: var(--transition);
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
}

/* QR related */
.qr-image { max-width: 280px; border-radius: 12px; margin: 8px auto; display: block; }
.status-connected { color: var(--success); font-size: 48px; padding: 20px 0; }
.status-connected i { display: block; margin-bottom: 12px; }
.status-connected p { font-size: 16px; font-weight: 600; }
.status-error { color: var(--danger); padding: 20px 0; }
.status-error i { font-size: 48px; display: block; margin-bottom: 12px; }
.status-error p { font-size: 14px; }

/* ========== TOGGLE BUTTON ========== */
.toggle-btn {
    background: none; border: none; cursor: pointer;
    font-size: 24px; color: var(--border);
    transition: var(--transition);
}
.toggle-btn.active { color: var(--success); }
.toggle-btn:hover { opacity: .8; }

.action-group { display: flex; gap: 6px; }

/* ========== FILTER TABS ========== */
.filter-tabs { display: flex; gap: 4px; }
.filter-tab {
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    color: var(--text-muted); text-decoration: none;
    transition: var(--transition);
    display: flex; align-items: center; gap: 6px;
}
.filter-tab:hover { background: var(--card); color: var(--text); }
.filter-tab.active { background: var(--primary); color: white; }

/* ========== PAGINATION ========== */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin-top: 24px;
}
.page-btn {
    padding: 8px 16px; border-radius: var(--radius-sm);
    background: var(--card); border: 1px solid var(--border);
    color: var(--text); text-decoration: none;
    font-size: 13px; font-weight: 600;
    display: flex; align-items: center; gap: 6px;
    transition: var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-info { font-size: 13px; color: var(--text-muted); }

/* ========== EMPTY STATE ========== */
.empty-state {
    grid-column: 1 / -1;
    text-align: center; padding: 60px 20px;
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.empty-state i { font-size: 48px; color: var(--border); margin-bottom: 16px; }
.empty-state h3 { font-size: 20px; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }

/* ========== TOAST ========== */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 14px 24px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; z-index: 300;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,.15);
    animation: toastIn .3s ease, toastOut .3s ease 3.5s forwards;
}
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }

@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(20px); } }

/* ========== SPINNER ========== */
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== UTILITY ========== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-nowrap { white-space: nowrap; }
.font-mono { font-family: 'SF Mono', 'Cascadia Code', Consolas, monospace; }
.msg-preview { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ========== PLAN BANNER ========== */
.plan-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 24px;
    border-radius: var(--radius);
    border: 1.5px solid;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.plan-banner-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.plan-badge-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.plan-name-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.plan-name-text {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -.3px;
}

.plan-status-chip {
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 99px;
    letter-spacing: .3px;
}

.plan-exp-line {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.plan-exp-line i { font-size: 11px; }

.plan-days-chip {
    background: rgba(16,185,129,.12);
    color: var(--success);
    padding: 1px 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 700;
}
.plan-days-urgent {
    background: rgba(239,68,68,.12);
    color: var(--danger);
}

.plan-quota-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.plan-quota-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    min-width: 80px;
}

.plan-quota-pill > i {
    font-size: 14px;
    flex-shrink: 0;
}

.pqp-body {
    display: flex;
    flex-direction: column;
}

.pqp-val {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.2;
}

.pqp-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-top: 1px;
}

@media (max-width: 900px) {
    .plan-banner { flex-direction: column; align-items: flex-start; }
    .plan-quota-row { width: 100%; }
    .plan-quota-pill { flex: 1; min-width: 70px; }
}

/* ========== NAV DIVIDER & SECTION LABEL ========== */
.nav-divider {
    height: 1px;
    background: rgba(255,255,255,.06);
    margin: 8px 16px;
}
.nav-section-label {
    padding: 12px 20px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(148,163,184,.5);
}

/* ========== DEVICE LIST REDESIGN ========== */
.devices-list { display: flex; flex-direction: column; gap: 2px; }

.device-row {
    display: flex; align-items: center; gap: 14px;
    background: var(--card); padding: 14px 18px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: all .2s; flex-wrap: wrap;
}
.device-row:first-child { border-radius: var(--radius) var(--radius) var(--radius-sm) var(--radius-sm); }
.device-row:last-of-type { border-radius: var(--radius-sm) var(--radius-sm) var(--radius) var(--radius); }
.device-row:hover { background: rgba(99,102,241,.02); border-color: rgba(99,102,241,.15); }

/* Status dot */
.dr-status-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.status-connected    { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.status-connecting   { background: var(--warning); animation: pulse 1.5s infinite; }
.status-disconnected { background: var(--border); }

/* Avatar */
.dr-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    overflow: hidden; flex-shrink: 0;
}
.dr-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dr-avatar-fallback {
    width: 100%; height: 100%;
    background: var(--bg); border: 2px solid var(--border);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 16px;
}
.dr-avatar-fallback.connected { background: rgba(16,185,129,.1); color: var(--success); border-color: rgba(16,185,129,.3); }

/* Info */
.dr-info { flex: 1; min-width: 0; }
.dr-name { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dr-profile-name { font-size: 12px; color: var(--text-muted); font-weight: 500; background: var(--bg); padding: 2px 8px; border-radius: 99px; }
.dr-meta {
    display: flex; align-items: center; gap: 10px; margin-top: 4px;
    font-size: 12px; color: var(--text-muted); flex-wrap: wrap;
}
.dr-phone { display: flex; align-items: center; gap: 4px; }
.dr-key   { letter-spacing: .3px; }

/* Feature badges */
.dr-feature-badges { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.dr-badge {
    width: 22px; height: 22px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px;
}
.dr-badge-red    { background: rgba(239,68,68,.12);   color: var(--danger); }
.dr-badge-blue   { background: rgba(6,182,212,.12);   color: var(--info); }
.dr-badge-green  { background: rgba(16,185,129,.12);  color: var(--success); }
.dr-badge-purple { background: rgba(99,102,241,.12);  color: var(--primary); }

/* Status badge */
.dr-status-badge { flex-shrink: 0; text-align: right; }

/* Actions */
.dr-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
.dr-dropdown {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    min-width: 180px; overflow: hidden;
}
.dr-dropdown button {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px; font-size: 13px; font-weight: 500;
    background: none; border: none; width: 100%;
    text-align: left; cursor: pointer; color: var(--text);
    transition: background .15s;
}
.dr-dropdown button:hover { background: var(--bg); }
.dr-dropdown button.text-danger { color: var(--danger); }
.dr-dropdown button.text-warning { color: var(--warning); }
.dr-dropdown button i { width: 14px; text-align: center; }

/* Advanced panel */
.dr-advanced-panel {
    background: rgba(99,102,241,.03);
    border: 1px solid rgba(99,102,241,.15);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
    animation: slideDown .2s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.adv-panel-body { padding: 20px 24px; }
.adv-section-title {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--primary);
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 16px;
}
.adv-toggles-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    margin-bottom: 16px;
}
.adv-toggle-card {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: border-color .15s;
}
.adv-toggle-card:hover { border-color: var(--primary); }
.adv-toggle-info {
    display: flex; align-items: center; gap: 10px;
}
.adv-toggle-info > i { font-size: 16px; flex-shrink: 0; width: 18px; text-align: center; }
.adv-toggle-info strong { display: block; font-size: 13px; font-weight: 700; }
.adv-toggle-info span   { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* Toggle switch */
.adv-toggle-switch { position: relative; flex-shrink: 0; }
.adv-toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.adv-toggle-switch label {
    display: block; width: 40px; height: 22px; border-radius: 99px;
    background: var(--border); cursor: pointer; transition: background .2s;
    position: relative;
}
.adv-toggle-switch label::after {
    content: ''; position: absolute;
    width: 16px; height: 16px; border-radius: 50%;
    background: white; top: 3px; left: 3px;
    transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.adv-toggle-switch input:checked + label { background: var(--success); }
.adv-toggle-switch input:checked + label::after { left: 21px; }

.adv-delay-setting { margin-top: 4px; }
.adv-delay-setting label { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }

.adv-panel-footer {
    padding: 12px 24px; border-top: 1px solid var(--border);
    display: flex; gap: 10px;
}

/* Device info modal */
.device-info-layout { display: flex; flex-direction: column; gap: 20px; }
.device-info-profile { display: flex; align-items: center; gap: 16px; }
.device-info-pic {
    width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
    border: 3px solid var(--border);
}
.device-info-pic-placeholder {
    width: 72px; height: 72px; border-radius: 50%;
    background: var(--bg); border: 3px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 28px; flex-shrink: 0;
}
.device-info-name  { font-size: 18px; font-weight: 800; margin-bottom: 2px; }
.device-info-phone { font-size: 14px; color: var(--text-muted); margin-bottom: 8px; font-family: monospace; }
.device-info-features { display: flex; flex-direction: column; gap: 8px; }
.dif-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; background: var(--bg); border-radius: 6px; font-size: 13px;
}
.dif-row i { width: 16px; color: var(--text-muted); margin-right: 6px; }

/* Check number result */
.check-result {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 14px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600;
}
.check-result.ok  { background: var(--success-light); color: #065f46; }
.check-result.no  { background: var(--danger-light);  color: #991b1b; }
.check-result.err { background: var(--warning-light); color: #92400e; }

/* ========== SETTINGS PAGE ========== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}
.settings-card-full {
    grid-column: 1 / -1;
}

.apikey-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.apikey-display {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    min-width: 0;
}
.apikey-display code {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    word-break: break-all;
    letter-spacing: .5px;
}
.apikey-display code.masked {
    color: var(--text-muted);
    letter-spacing: 2px;
    font-size: 14px;
}
.apikey-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Info Box */
.info-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--primary-light);
    border: 1px solid rgba(99,102,241,.2);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}
.info-box i { color: var(--primary); margin-top: 2px; flex-shrink: 0; }
.warning-box {
    background: var(--warning-light);
    border-color: rgba(245,158,11,.3);
}
.warning-box i { color: var(--warning); }

/* Code Tabs */
.code-tabs { border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.tab-nav {
    display: flex;
    background: var(--bg);
    border-bottom: 1.5px solid var(--border);
    overflow-x: auto;
}
.tab-btn {
    padding: 10px 20px;
    background: none; border: none;
    font-size: 13px; font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1.5px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #1a2234;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.copy-code-btn {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.1);
    color: #94a3b8;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex; align-items: center; gap: 4px;
}
.copy-code-btn:hover { background: rgba(255,255,255,.15); color: white; }

.tab-panel pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 20px;
    font-size: 13px;
    line-height: 1.7;
    overflow-x: auto;
    margin: 0;
    font-family: 'SF Mono', 'Cascadia Code', Consolas, monospace;
}

/* Test Form */
.test-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.test-result {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
}
.test-result.success { background: var(--success-light); color: #065f46; }
.test-result.error   { background: var(--danger-light); color: #991b1b; }

/* ========== SEND PAGE ========== */
.phone-input-wrap {
    display: flex; align-items: center;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    overflow: hidden; transition: var(--transition);
}
.phone-input-wrap:focus-within {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.phone-prefix {
    padding: 11px 12px; background: var(--bg);
    color: var(--text-muted); font-size: 14px; font-weight: 600;
    border-right: 1.5px solid var(--border);
}
.phone-input-wrap input {
    flex: 1; border: none; padding: 11px 14px; outline: none;
    font-size: 14px; background: transparent;
}

.result-success, .result-error {
    display: flex; align-items: center; gap: 8px;
    padding: 14px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600;
}
.result-success { background: var(--success-light); color: #065f46; }
.result-error   { background: var(--danger-light); color: #991b1b; }

.log-item { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.log-item:last-child { border-bottom: none; }
.log-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.log-status {
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; flex-shrink: 0;
}
.log-ok   { background: var(--success-light); color: var(--success); }
.log-fail { background: var(--danger-light);  color: var(--danger); }
.log-to   { font-size: 14px; font-weight: 600; flex: 1; font-family: monospace; }
.log-time { font-size: 12px; color: var(--text-muted); }
.log-msg  { font-size: 13px; color: var(--text-muted); padding-left: 28px;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-err  { font-size: 12px; color: var(--danger); padding-left: 28px; }

/* ========== BROADCAST PAGE ========== */
.progress-bar-wrap {
    background: var(--border); border-radius: 99px;
    height: 6px; overflow: hidden;
}
.progress-bar-wrap.big { height: 10px; }
.progress-bar {
    height: 100%; background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 99px; transition: width .5s ease;
}

.broadcast-detail-layout {
    display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}

.broadcast-stats-row {
    display: flex; gap: 16px; flex-wrap: wrap;
}
.bstat {
    flex: 1; min-width: 70px;
    background: var(--bg); border-radius: var(--radius-sm);
    padding: 12px; text-align: center;
    border: 1px solid var(--border);
}
.bstat-val { display: block; font-size: 24px; font-weight: 800; }
.bstat-label { display: block; font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }
.bstat-success .bstat-val { color: var(--success); }
.bstat-danger  .bstat-val { color: var(--danger); }
.bstat-muted   .bstat-val { color: var(--text-muted); }

.broadcast-msg-preview { margin: 16px 0; }
.broadcast-msg-preview label { display: block; margin-bottom: 8px; }

.broadcast-info-row { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }

/* ========== SCHEDULE PAGE ========== */
/* Header stats bar */
.sched-header-stats {
    display: flex; align-items: center;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 20px;
    overflow: hidden; flex-wrap: wrap;
}
.shs-item {
    flex: 1; min-width: 130px; padding: 16px 20px;
    display: flex; align-items: center; gap: 12px;
}
.shs-item i { font-size: 20px; flex-shrink: 0; }
.shs-val    { display: block; font-size: 24px; font-weight: 900; letter-spacing: -1px; }
.shs-label  { display: block; font-size: 12px; color: var(--text-muted); font-weight: 500; }
.shs-divider { width: 1px; background: var(--border); align-self: stretch; }
.shs-pending .shs-val { color: var(--warning); }

/* Tab switcher */
.sched-tabs {
    display: flex; background: var(--bg);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 3px; gap: 3px;
}
.sched-tab {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 18px; border-radius: 6px;
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    text-decoration: none; transition: all .15s;
    position: relative;
}
.sched-tab:hover { color: var(--text); background: var(--card); }
.sched-tab.active { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(99,102,241,.3); }
.sched-tab-badge {
    background: var(--warning); color: white;
    border-radius: 99px; font-size: 10px; font-weight: 800;
    min-width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 5px;
}
.sched-tab.active .sched-tab-badge { background: rgba(255,255,255,.25); }

/* Countdown chip (single messages table) */
.sched-countdown-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(6,182,212,.1); border: 1px solid rgba(6,182,212,.2);
    border-radius: 99px; padding: 4px 12px;
    font-size: 12px; font-weight: 700; color: var(--info);
    white-space: nowrap;
}

/* Broadcast card grid */
.sched-broadcast-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

.sbc-card {
    background: var(--card); border: 1.5px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    transition: all .2s;
    display: flex; flex-direction: column;
}
.sbc-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,.1); border-color: rgba(99,102,241,.2); }

.sbc-card[data-status="running"] { border-color: rgba(245,158,11,.35); }
.sbc-card[data-status="done"]    { border-color: rgba(16,185,129,.25); }
.sbc-card[data-status="scheduled"] { border-color: rgba(6,182,212,.25); }

.sbc-header { padding: 16px 20px 12px; }
.sbc-title-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 8px; flex-wrap: wrap;
}
.sbc-title   { font-size: 16px; font-weight: 800; }
.sbc-meta    {
    display: flex; flex-wrap: wrap; gap: 12px;
    font-size: 12px; color: var(--text-muted);
}
.sbc-meta span { display: flex; align-items: center; gap: 4px; }

/* Schedule time + countdown row */
.sbc-schedule-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    padding: 10px 20px;
    background: var(--bg); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.sbc-time-box { display: flex; align-items: center; gap: 10px; }
.sbc-time-date { font-size: 14px; font-weight: 700; }
.sbc-time-hour { font-size: 12px; color: var(--text-muted); }
.sbc-countdown-wrap { display: flex; align-items: center; }
.sbc-countdown {
    display: flex; flex-direction: column; align-items: flex-end;
}
.scc-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.scc-text  { font-size: 18px; font-weight: 900; color: var(--info); letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.sbc-running-indicator {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 600; color: var(--warning);
}
.pulse-dot {
    width: 10px; height: 10px; border-radius: 50%; background: var(--warning);
    animation: pulse 1.2s infinite;
}
.sbc-done-time { font-size: 13px; color: var(--success); font-weight: 600; display: flex; align-items: center; gap: 6px; }

/* Progress section */
.sbc-progress-section { padding: 14px 20px; }
.sbc-stats-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.sbc-stat {
    display: flex; flex-direction: column; align-items: center;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 6px; padding: 8px 12px; flex: 1; min-width: 60px;
}
.sbcs-val   { font-size: 18px; font-weight: 800; line-height: 1.1; }
.sbcs-label { font-size: 10px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-top: 2px; }
.sbc-stat-sent    .sbcs-val { color: var(--success); }
.sbc-stat-failed  .sbcs-val { color: var(--danger); }
.sbc-stat-pending .sbcs-val { color: var(--text-muted); }
.sbc-progress-labels {
    display: flex; justify-content: space-between;
    font-size: 12px; color: var(--text-muted); margin-top: 4px;
}
.sbc-eta { color: var(--primary); font-weight: 600; }

/* Message preview */
.sbc-msg-preview {
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px; align-items: flex-start;
    font-size: 13px; color: var(--text-muted);
}
.sbc-msg-preview span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Actions */
.sbc-actions {
    padding: 12px 20px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; align-items: center;
    background: var(--bg); margin-top: auto;
}

/* ========== BROADCAST SCHEDULE + RANDOM DELAY ========== */

/* Delay range UI */
.delay-range-ui {
    background: var(--bg); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px 16px;
    margin-top: 6px;
}
.delay-range-inputs {
    display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.delay-input-group {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.delay-input-label {
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .4px; width: 24px;
}
.delay-input-group input {
    width: 64px; padding: 7px 8px; text-align: center;
    border: 1.5px solid var(--border); border-radius: 6px;
    font-size: 14px; font-weight: 700; background: var(--card);
    color: var(--text); outline: none;
}
.delay-input-group input:focus { border-color: var(--warning); }
.delay-input-suffix { font-size: 12px; color: var(--text-muted); }

.delay-range-track {
    flex: 1; height: 6px; background: var(--border);
    border-radius: 99px; overflow: hidden;
}
.delay-range-fill {
    height: 100%; background: linear-gradient(90deg, var(--success), var(--warning));
    border-radius: 99px; transition: width .3s ease;
    width: 15%;
}

.delay-badge {
    display: inline-flex; align-items: center;
    background: rgba(245,158,11,.12); color: var(--warning);
    border: 1px solid rgba(245,158,11,.25);
    padding: 2px 10px; border-radius: 99px;
    font-size: 12px; font-weight: 700;
    margin-left: 8px; vertical-align: middle;
}

.delay-presets {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.delay-preset-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.delay-preset {
    padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600;
    background: var(--card); border: 1px solid var(--border);
    cursor: pointer; transition: all .15s; color: var(--text-muted);
}
.delay-preset:hover { border-color: var(--warning); color: var(--warning); }
.delay-preset.active, .delay-preset-rec { border-color: var(--warning); color: var(--warning); background: rgba(245,158,11,.08); }

/* Schedule toggle */
.schedule-toggle-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px;
}
.schedule-opt {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); cursor: pointer;
    transition: all .2s; user-select: none;
}
.schedule-opt i {
    font-size: 20px; flex-shrink: 0; color: var(--text-muted);
    width: 24px; text-align: center;
}
.schedule-opt > div { display: flex; flex-direction: column; }
.schedule-opt strong { font-size: 14px; font-weight: 700; }
.schedule-opt span   { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.schedule-opt.active {
    border-color: var(--primary); background: var(--primary-light);
}
.schedule-opt.active i { color: var(--primary); }
.schedule-opt.active strong { color: var(--primary); }

/* Schedule datetime box */
.schedule-datetime-box {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 14px 16px;
    background: rgba(99,102,241,.05); border: 1.5px solid rgba(99,102,241,.2);
    border-radius: var(--radius-sm);
}
.sdb-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 18px; flex-shrink: 0;
}
.sdb-fields { flex: 1; }
.sdb-preview {
    margin-top: 10px; font-size: 13px; padding: 8px 12px;
    border-radius: 6px; display: flex; align-items: center; gap: 6px;
}
.sdb-preview-ok   { background: rgba(16,185,129,.1); color: var(--success); }
.sdb-preview-warn { background: rgba(239,68,68,.1); color: var(--danger); }
.sdb-preview i    { flex-shrink: 0; }

/* Detail page: scheduled countdown banner */
.sched-countdown-banner {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 16px 20px; margin-bottom: 16px;
    background: linear-gradient(135deg, rgba(6,182,212,.08), rgba(99,102,241,.06));
    border: 1.5px solid rgba(6,182,212,.25); border-radius: var(--radius-sm);
    transition: all .3s;
}
.sched-countdown-banner.scb-firing {
    border-color: var(--success); background: rgba(16,185,129,.08);
}
.scb-icon { font-size: 28px; color: var(--info); flex-shrink: 0; }
.scb-body { flex: 1; }
.scb-label    { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; }
.scb-datetime { font-size: 15px; font-weight: 700; margin: 2px 0; }
.scb-countdown {
    font-size: 22px; font-weight: 900; color: var(--info);
    letter-spacing: -.5px; font-variant-numeric: tabular-nums;
}

/* Detail page: delay info row */
.delay-info-row {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 10px 14px; background: var(--bg);
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    margin-top: 12px;
}
.dir-item {
    display: flex; align-items: center; gap: 6px; font-size: 13px;
}
.dir-item i    { font-size: 12px; width: 14px; text-align: center; }
.dir-item span { color: var(--text-muted); }
.dir-item strong { font-weight: 700; }

/* Delay progress bar in live log */
.delay-progress-bar-outer {
    height: 4px; background: var(--border);
    border-radius: 99px; overflow: hidden;
}
.delay-progress-bar-inner {
    height: 100%; width: 100%;
    background: linear-gradient(90deg, var(--primary), var(--warning));
    border-radius: 99px;
    transition: width .1s linear;
}

/* Log item new entry animation */
.log-item-new { animation: logSlideIn .3s ease; }
@keyframes logSlideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.card-footer {
    padding: 16px 24px; border-top: 1px solid var(--border);
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}

/* WhatsApp Bubble Preview */
.wa-bubble {
    background: #dcf8c6;
    padding: 12px 16px 20px;
    border-radius: 12px 12px 4px 12px;
    max-width: 320px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,.12);
    font-size: 14px; line-height: 1.5;
}
.wa-time {
    position: absolute; bottom: 6px; right: 10px;
    font-size: 11px; color: rgba(0,0,0,.4);
}

/* Radio Group */
.radio-group { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.radio-card {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer;
    font-size: 13px; font-weight: 600; transition: var(--transition);
    user-select: none;
}
.radio-card:has(input:checked) {
    border-color: var(--primary); background: var(--primary-light); color: var(--primary);
}
.radio-card input { position: absolute; opacity: 0; }
.radio-card i { color: var(--primary); }

/* Contact Checklist */
.contact-select-toolbar {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 10px; flex-wrap: wrap;
}
.contact-checklist {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px; max-height: 280px; overflow-y: auto;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px;
}
.contact-check-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 6px;
    cursor: pointer; transition: var(--transition);
    user-select: none;
}
.contact-check-item:hover { background: var(--bg); }
.contact-check-item:has(input:checked) { background: var(--primary-light); }
.contact-check-item input { flex-shrink: 0; accent-color: var(--primary); width: 16px; height: 16px; }
.contact-check-info { display: flex; flex-direction: column; min-width: 0; }
.contact-check-name { font-size: 13px; font-weight: 600; }
.contact-check-phone { font-size: 12px; color: var(--text-muted); }

/* Grid 2 small */
.grid-2-sm { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Input with suffix */
.input-with-suffix { display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.input-with-suffix input { flex: 1; border: none; padding: 11px 14px; outline: none; font-size: 14px; background: transparent; }
.input-with-suffix:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.input-suffix { padding: 11px 14px; background: var(--bg); color: var(--text-muted); font-size: 13px; font-weight: 600; border-left: 1.5px solid var(--border); }

/* text utils */
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.font-600     { font-weight: 600; }
.d-block      { display: block; }

/* ========== CONTACTS PAGE ========== */
/* Stats bar */
.contact-stats-bar {
    display: flex; align-items: center; gap: 0;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 20px;
    overflow: hidden; flex-wrap: wrap;
}
.csb-item {
    flex: 1; min-width: 140px; padding: 18px 24px;
    display: flex; flex-direction: column; justify-content: center;
}
.csb-divider { width: 1px; background: var(--border); align-self: stretch; flex-shrink: 0; }
.csb-val { font-size: 28px; font-weight: 900; letter-spacing: -1px; }
.csb-label { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.csb-sub  { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.csb-success .csb-val { color: var(--success); }
.csb-warning .csb-val { color: var(--warning); }
.csb-muted   .csb-val { color: var(--text-muted); }
.csb-progress-wrap {
    background: var(--border); border-radius: 99px; height: 8px;
    overflow: hidden; width: 100%; margin-top: 4px;
}
.csb-progress-bar {
    height: 100%; border-radius: 99px;
    background: linear-gradient(90deg, var(--primary), var(--success));
    transition: width .5s ease;
}

/* Toolbar */
.contact-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-count {
    background: rgba(255,255,255,.1); color: inherit;
    padding: 1px 7px; border-radius: 99px;
    font-size: 11px; font-weight: 700; margin-left: 4px;
}
.filter-tab.active .filter-count { background: rgba(255,255,255,.25); }

/* Contact avatar */
.contact-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 12px; font-weight: 800;
    flex-shrink: 0; letter-spacing: -.5px;
}

/* Name cell */
.contact-name-line { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.contact-personalized-chip {
    display: inline-flex; align-items: center;
    background: rgba(99,102,241,.12); color: var(--primary);
    border-radius: 99px; width: 18px; height: 18px;
    justify-content: center; font-size: 9px;
    flex-shrink: 0; cursor: help;
}
.contact-unnamed-chip {
    display: inline-flex; align-items: center;
    background: rgba(245,158,11,.12); color: var(--warning);
    border-radius: 99px; width: 18px; height: 18px;
    justify-content: center; font-size: 9px;
    flex-shrink: 0;
}
.contact-phone { color: var(--text-muted); }
.contact-labels-cell { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; max-width: 220px; }
.contact-label-chip {
    font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 6px;
    background: var(--primary-light); color: var(--primary); border: 1px solid rgba(99,102,241,.25);
}

/* Variable preview row in table */
.var-preview-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.var-mini-tag {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; background: var(--bg);
    border: 1px solid var(--border); border-radius: 6px;
    padding: 2px 8px; white-space: nowrap;
}
.var-mini-tag code { color: var(--primary); font-size: 10px; }
.var-mini-tag em   { font-style: normal; color: var(--success); font-weight: 600; max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
.var-mini-warn {
    font-size: 11px; color: var(--warning);
    display: flex; align-items: center; gap: 4px;
    font-weight: 600;
}

/* Contact var live preview in modals */
.contact-var-live-preview {
    background: rgba(99,102,241,.05);
    border: 1px solid rgba(99,102,241,.15);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-top: 8px;
}
.cvlp-title { font-size: 11px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; display: flex; align-items: center; gap: 5px; }
.cvlp-grid  { display: flex; flex-direction: column; gap: 5px; }
.cvlp-row   { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.cvlp-row code  { color: var(--primary); font-size: 11px; min-width: 110px; }
.cvlp-row span  { color: var(--text-muted); }
.cvlp-row strong { font-weight: 700; color: var(--success); }
.cvlp-warn strong { color: var(--warning); }
.cvlp-fallback { font-size: 10px; color: var(--warning); background: rgba(245,158,11,.1); padding: 1px 6px; border-radius: 4px; }

/* Variable Preview Modal */
.vpm-grid { display: flex; flex-direction: column; gap: 8px; }
.vpm-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: var(--radius-sm);
    background: var(--bg); border: 1px solid var(--border);
    flex-wrap: wrap;
}
.vpm-warn { border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.05); }
.vpm-key  { color: var(--primary); font-size: 12px; font-weight: 700; min-width: 110px; }
.vpm-arrow { color: var(--text-muted); font-size: 12px; }
.vpm-val  { font-weight: 700; font-size: 14px; flex: 1; }
.vpm-fallback-note { font-size: 11px; color: var(--warning); font-weight: 600; }

/* Import format guide */
.import-format-guide {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px 16px;
    margin-bottom: 4px;
}
.ifg-title { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.ifg-table-wrap { overflow-x: auto; margin-bottom: 12px; }
.ifg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ifg-table th {
    padding: 8px 14px; background: var(--bg2); text-align: left;
    font-size: 12px; font-weight: 700; border: 1px solid var(--border);
    white-space: nowrap;
}
.ifg-table td { padding: 7px 14px; border: 1px solid var(--border); font-size: 13px; }
.ifg-table tbody tr:nth-child(even) { background: var(--bg); }

.ifg-badge {
    display: inline-block;
    padding: 2px 7px; border-radius: 99px;
    font-size: 10px; font-weight: 700;
    margin-left: 6px; vertical-align: middle;
}
.ifg-badge-green { background: rgba(16,185,129,.15); color: #065f46; }
.ifg-badge-blue  { background: rgba(99,102,241,.15);  color: var(--primary); }
.ifg-note { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.7; }
.ifg-note i { margin-right: 4px; }
.ifg-note code { font-size: 11px; background: rgba(99,102,241,.1); color: var(--primary); padding: 1px 5px; border-radius: 4px; }
.ifg-aliases { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ifg-aliases strong { margin-right: 4px; }
.ifg-aliases span { background: var(--card); border: 1px solid var(--border); padding: 2px 8px; border-radius: 4px; font-family: monospace; font-size: 11px; }

/* CSV preview */
.csv-preview-title { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 5px; }

/* ========== CUSTOM FIELD SLOTS (contacts stats bar) ========== */
.cf-slots-mini { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.cf-slot-pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 99px; font-size: 11px;
    border: 1px solid var(--border); background: var(--bg);
    color: var(--text-muted); transition: all .15s;
}
.cf-slot-pill.active { border-color: rgba(99,102,241,.3); color: var(--primary); background: var(--primary-light); }
.cf-slot-pill code  { font-size: 10px; font-weight: 800; }
.cf-slot-pill span  { font-weight: 600; }
.cf-count-badge {
    background: var(--primary); color: white;
    border-radius: 99px; padding: 0 5px; font-size: 9px; font-weight: 800;
}

/* Custom field config modal */
.cf-config-grid { display: flex; flex-direction: column; gap: 8px; }

.cf-config-row {
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .15s;
}
.cf-config-row:focus-within {
    border-color: var(--primary);
    background: var(--primary-light);
}
.cf-config-tag {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 11px; font-weight: 800;
    color: var(--primary);
    background: rgba(99,102,241,.12);
    padding: 5px 6px;
    border-radius: 6px;
    text-align: center;
    white-space: nowrap;
    letter-spacing: -.2px;
}
.cf-config-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.cf-config-inputs input {
    font-size: 13px;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    color: var(--text);
    outline: none;
    transition: border-color .15s;
    min-width: 0;
}
.cf-config-inputs input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99,102,241,.12);
}
.cf-config-inputs input::placeholder { color: var(--text-muted); font-size: 12px; }

.cf-config-inputs input:first-child { font-weight: 600; }

.cf-var-hint {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(99,102,241,.05);
    border: 1px solid rgba(99,102,241,.15);
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.65;
}
.cf-var-hint i { color: var(--primary); margin-right: 5px; }
.cf-var-hint code { font-size: 11px; color: var(--primary); background: rgba(99,102,241,.1); padding: 1px 4px; border-radius: 3px; }

/* Custom field in contact table */
.cf-col-header { min-width: 120px; }
.cf-col-tag {
    display: block; font-family: monospace; font-size: 10px;
    color: var(--primary); font-weight: 700; letter-spacing: .3px;
    margin-bottom: 1px;
}
.cf-cell-value { font-size: 13px; font-weight: 500; }
.cf-cell-empty { font-size: 12px; }

/* Custom fields section in add/edit modals */
.cf-fields-section {
    margin-top: 8px; padding: 14px;
    background: rgba(99,102,241,.04);
    border: 1px solid rgba(99,102,241,.12);
    border-radius: var(--radius-sm);
}
.cf-section-title {
    font-size: 12px; font-weight: 700; color: var(--primary);
    text-transform: uppercase; letter-spacing: .5px;
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 12px;
}
.cf-fields-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.cf-label-tag {
    font-size: 10px; font-weight: 700; color: var(--primary);
    background: var(--primary-light); padding: 1px 6px; border-radius: 4px;
    margin-left: 4px;
}
.cvlp-cf-lbl { font-size: 11px; color: var(--text-muted); min-width: 80px; }

/* VPM custom fields section */
.vpm-section-divider {
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .5px;
    padding: 10px 0 4px;
    display: flex; align-items: center; gap: 6px;
    border-top: 1px solid var(--border); margin-top: 6px;
}
.vpm-cf { background: rgba(99,102,241,.04); border-color: rgba(99,102,241,.15); }
.vpm-cf-label { min-width: 80px; font-size: 11px; color: var(--text-muted); }
.vpm-empty { opacity: .6; }

/* Broadcast toolbar additions */
.var-group-label {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-muted); padding: 0 2px; align-self: center;
}
.var-group-divider {
    width: 1px; height: 18px; background: var(--border); align-self: center;
    flex-shrink: 0;
}
.var-tag-custom {
    background: rgba(16,185,129,.1); color: var(--success);
    border-color: rgba(16,185,129,.25);
}
.var-tag-custom:hover { background: var(--success); color: white; }
.var-tag-add {
    background: transparent; color: var(--text-muted);
    border: 1px dashed var(--border);
    font-size: 12px; text-decoration: none;
}
.var-tag-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.sample-data-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ========== BROADCAST VARIABLE TAGS ========== */
.var-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.var-toolbar + textarea {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}
.var-toolbar-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.var-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.var-tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 700;
    background: var(--primary-light); color: var(--primary);
    border: 1px solid rgba(99,102,241,.25);
    cursor: pointer; font-family: inherit;
    transition: all .15s;
}
.var-tag:hover {
    background: var(--primary); color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(99,102,241,.3);
}
.var-tag i { font-size: 10px; }

/* Variable highlights in preview */
mark.var-highlight {
    background: rgba(99,102,241,.15);
    color: var(--primary);
    border-radius: 4px;
    padding: 1px 4px;
    font-weight: 700;
    font-size: 13px;
    border: 1px solid rgba(99,102,241,.2);
}

/* Preview toggle switch */
.var-preview-toggle {
    display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
}
.toggle-switch {
    width: 40px; height: 22px; border-radius: 99px;
    background: var(--border); position: relative;
    cursor: pointer; transition: background .2s;
    border: 1.5px solid var(--border);
}
.toggle-switch.on { background: var(--success); border-color: var(--success); }
.toggle-knob {
    width: 16px; height: 16px; border-radius: 50%; background: white;
    position: absolute; top: 1px; left: 1px;
    transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch.on .toggle-knob { left: 20px; }

/* Sample data inputs */
.sample-data-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    padding: 12px; background: rgba(16,185,129,.06);
    border: 1px solid rgba(16,185,129,.2); border-radius: var(--radius-sm);
}
.sample-data-grid input {
    padding: 8px 12px; font-size: 13px;
    border: 1.5px solid var(--border); border-radius: 6px;
    background: var(--card); color: var(--text); outline: none; width: 100%;
}
.sample-data-grid input:focus { border-color: var(--success); }

/* Variable legend */
.var-legend-grid {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 12px; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.var-legend-item {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; background: var(--card);
    padding: 4px 10px; border-radius: 6px;
    border: 1px solid var(--border);
}
.var-legend-item code { color: var(--primary); font-weight: 700; }
.var-legend-item span { color: var(--text-muted); }
.var-legend-item em   { font-style: normal; font-weight: 600; color: var(--success); }

/* ========== ATTACHMENT UPLOAD ========== */
.attachment-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer; transition: all .2s;
    overflow: hidden;
    min-height: 80px;
    display: flex; align-items: center; justify-content: center;
}
.attachment-zone:hover, .attachment-zone.drag-over {
    border-color: var(--primary); background: var(--primary-light);
}
.attachment-zone.has-file {
    border-style: solid; border-color: var(--success); cursor: default;
}

.az-placeholder {
    display: flex; flex-direction: column; align-items: center;
    gap: 4px; padding: 18px 20px; text-align: center; pointer-events: none;
}
.az-placeholder i    { font-size: 24px; color: var(--text-muted); }
.az-placeholder span { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.az-placeholder small { font-size: 11px; color: var(--text-muted); }

/* Image preview */
.az-img-preview { width: 100%; }
.az-img-preview img {
    width: 100%; max-height: 200px; object-fit: cover; display: block;
}
.az-img-info {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; background: rgba(0,0,0,.04);
}
.az-filename { font-size: 13px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.az-filesize { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* File (non-image) preview */
.az-file-preview {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 20px; width: 100%;
}
.az-file-preview > i { font-size: 32px; flex-shrink: 0; }
.az-file-info  { flex: 1; min-width: 0; }
.az-file-info .az-filename { display: block; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.az-file-info .az-filesize { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; text-transform: capitalize; }

/* Remove button */
.az-remove {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--danger-light); color: var(--danger);
    border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 12px; flex-shrink: 0; transition: all .15s;
    z-index: 2; position: relative;
}
.az-remove:hover { background: var(--danger); color: white; }

/* WA bubble attachment badge */
.wa-attach-badge {
    display: flex; align-items: center; gap: 8px;
    background: rgba(0,0,0,.06); border-radius: 8px;
    padding: 8px 12px; margin-bottom: 6px;
    font-size: 13px; font-weight: 600;
}
.wa-attach-badge i { font-size: 18px; flex-shrink: 0; }

/* Attach type chip in log */
.attach-type-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700;
    background: rgba(99,102,241,.1); color: var(--primary);
    border: 1px solid rgba(99,102,241,.2);
}

/* ========== BILLING PAGE ========== */
.billing-current-plan {
    border: 1.5px solid;
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.bcp-left { display: flex; align-items: center; gap: 14px; }
.bcp-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 20px; flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.bcp-plan-name { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.bcp-plan-sub  { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bcp-days { background: rgba(16,185,129,.12); color: var(--success); padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.bcp-days-urgent { background: rgba(239,68,68,.12); color: var(--danger); }
.bcp-quota-list { display: flex; gap: 8px; flex-wrap: wrap; }
.bcp-quota {
    display: flex; align-items: center; gap: 8px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 12px;
}
.bcp-quota > i { font-size: 13px; flex-shrink: 0; }
.bcp-quota > div { display: flex; flex-direction: column; }
.bcp-q-val   { font-size: 14px; font-weight: 800; line-height: 1.2; }
.bcp-q-label { font-size: 10px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }

/* Package cards grid */
.billing-packages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}
.billing-pkg {
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex; flex-direction: column;
    position: relative;
    transition: all .25s;
}
.billing-pkg:hover { border-color: var(--pkg-color, var(--primary)); transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,.15); }
.billing-pkg-popular { border-color: var(--pkg-color, var(--primary)); box-shadow: 0 0 0 3px rgba(245,158,11,.1); }
.billing-pkg-current { border-color: var(--success); }
.billing-pkg-popular-tag {
    background: linear-gradient(135deg, var(--pkg-color, var(--warning)), var(--pkg-color, var(--warning))cc);
    color: white; text-align: center; padding: 6px;
    font-size: 12px; font-weight: 700;
}
.billing-pkg-current-tag {
    background: rgba(16,185,129,.12); color: var(--success);
    text-align: center; padding: 6px;
    font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; gap: 5px;
}
.billing-pkg-header {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 18px 0;
}
.billing-pkg-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 17px; flex-shrink: 0;
}
.billing-pkg-name  { font-size: 15px; font-weight: 800; }
.billing-price-num { font-size: 20px; font-weight: 900; }
.billing-price-period { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.billing-pkg-desc { font-size: 12px; color: var(--text-muted); padding: 10px 18px 0; line-height: 1.5; }
.billing-feat-list { list-style: none; padding: 14px 18px; flex: 1; display: flex; flex-direction: column; gap: 7px; }
.billing-feat-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.billing-feat-list li.feat-unavail { color: var(--text-muted); }
.feat-icon { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px; flex-shrink: 0; }
.feat-icon-ok { background: rgba(16,185,129,.15); color: var(--success); }
.feat-icon-no { background: var(--bg); color: var(--text-muted); }
.feat-val { font-weight: 700; color: var(--text); min-width: 60px; }
.feat-unavail .feat-val { color: var(--text-muted); font-weight: 500; }
.feat-label { color: var(--text-muted); }
.billing-pkg-footer { padding: 0 18px 18px; }

/* Request form */
.req-pkg-summary {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 16px 20px;
    border: 1.5px solid; border-radius: var(--radius-sm);
    margin-bottom: 24px; flex-wrap: wrap;
}
.rps-left  { display: flex; align-items: center; gap: 12px; }
.rps-icon  { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-size: 18px; flex-shrink: 0; }
.rps-name  { font-size: 17px; font-weight: 800; }
.rps-price { text-align: right; }
.rps-price-num   { font-size: 24px; font-weight: 900; }
.rps-price-label { font-size: 13px; color: var(--text-muted); }

/* Duration selector */
.duration-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.duration-card {
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px 8px; text-align: center; cursor: pointer;
    transition: all .2s;
}
.duration-card:hover { border-color: var(--primary); background: var(--primary-light); }
.duration-card.selected { border-color: var(--primary); background: var(--primary-light); }
.dc-months { font-size: 13px; font-weight: 700; }
.dc-disc   { font-size: 11px; color: var(--success); font-weight: 600; margin: 2px 0; }
.dc-price  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Total box */
.billing-total-box {
    background: var(--bg); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px 20px;
    margin-bottom: 20px;
}
.btb-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.btb-divider { border-top: 1px solid var(--border); margin: 8px 0; }
.btb-total { font-weight: 800; font-size: 16px; }

/* Transfer info */
.req-transfer-info {
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 16px; margin-bottom: 20px;
}
.rti-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.rti-accounts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rti-account { background: var(--bg); padding: 12px; border-radius: var(--radius-sm); }
.rti-bank   { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-bottom: 4px; }
.rti-number {
    font-size: 18px; font-weight: 900; letter-spacing: 1px;
    display: flex; align-items: center; gap: 8px; cursor: pointer;
    margin-bottom: 2px;
}
.rti-number:hover { color: var(--primary); }

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--border); border-radius: var(--radius-sm);
    padding: 32px 20px; text-align: center; cursor: pointer;
    transition: all .2s; position: relative;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }
.upload-zone.has-file { border-style: solid; border-color: var(--success); }
.uz-icon  { font-size: 36px; color: var(--text-muted); margin-bottom: 10px; }
.uz-text  { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.uz-hint  { font-size: 13px; color: var(--text-muted); }
.uz-preview { margin-top: 16px; }
.uz-preview img { max-height: 200px; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.uz-pdf  { font-size: 48px; color: var(--danger); margin-bottom: 8px; }
.uz-fname { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

/* Transfer info on billing index */
.billing-transfer-info { }
.transfer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.transfer-item {
    display: flex; align-items: flex-start; gap: 12px;
    background: var(--bg); padding: 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.transfer-item > i { font-size: 22px; flex-shrink: 0; margin-top: 2px; }
.transfer-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; margin-bottom: 2px; }
.transfer-val   { font-size: 16px; font-weight: 800; }
.transfer-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Superadmin payments table */
.tr-highlight { background: rgba(245,158,11,.04); }
.sa-notif-dot {
    background: var(--danger); color: white;
    font-size: 10px; font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 99px; display: inline-flex;
    align-items: center; justify-content: center;
    padding: 0 5px; margin-left: 4px;
}
.sa-nav-badge {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    background: var(--danger); color: white;
    font-size: 10px; font-weight: 800;
    min-width: 18px; height: 18px; border-radius: 99px;
    display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* ========== AGENT CHAT (WA-style) ========== */
/* Scroll hanya di #acMessagesScroll; halaman tidak memanjang tanpa batas */
.content-area:has(.agent-chat-page) {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 64px);
    min-height: 0;
    overflow: hidden;
}
.agent-chat-page {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}
.agent-chat-toolbar { flex-shrink: 0; }
.agent-chat-shell {
    flex: 1;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    padding: 0;
    overflow: hidden;
}
.ac-sidebar {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: #f8faf8;
    min-height: 0;
}
.ac-sidebar-head { padding: 12px; border-bottom: 1px solid var(--border); background: #ecefec; }
.ac-search {
    width: 100%; padding: 10px 12px; border-radius: 24px; border: none;
    background: #fff; font-size: 14px; box-shadow: var(--shadow);
}
.ac-search:focus { outline: 2px solid rgba(37, 211, 102, .35); }
.ac-sidebar-head { display: flex; flex-direction: column; gap: 8px; }
.ac-filter-label {
    width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
    font-size: 13px; background: #fff; color: var(--text); cursor: pointer;
}
.ac-ti-labels { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 4px 0 2px; align-items: center; }
.ac-list-chip {
    font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 6px; border: 1px solid;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ac-list-chip-more { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.ac-thread-list {
    flex: 1; overflow-y: auto; min-height: 0;
}
.ac-thread-item {
    width: 100%; display: flex; gap: 12px; padding: 12px 14px;
    border: none; border-bottom: 1px solid rgba(0,0,0,.04); background: transparent;
    cursor: pointer; text-align: left; align-items: flex-start;
    transition: background .15s;
}
.ac-thread-item:hover { background: rgba(0,0,0,.04); }
.ac-thread-item.active { background: rgba(37, 211, 102, .12); }
.ac-ti-avatar {
    width: 48px; height: 48px; border-radius: 50%; background: #dfe6df;
    display: flex; align-items: center; justify-content: center; color: #5a6b5a; flex-shrink: 0;
}
.ac-ti-body { flex: 1; min-width: 0; }
.ac-ti-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ac-ti-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-ti-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.ac-ti-preview { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ac-ti-preview .muted { opacity: .75; }
.ac-empty, .ac-empty-chat, .ac-loading {
    padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 14px;
}
.ac-main {
    display: flex; flex-direction: column; min-height: 0; height: 100%;
    background: #e5ddd5;
    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='%23c9c5bd' fill-opacity='0.25'%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");
}
.ac-main-head {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    background: #f0f2f0; border-bottom: 1px solid rgba(0,0,0,.06);
}
.ac-peer-avatar {
    width: 42px; height: 42px; border-radius: 50%; background: #d4ddd4;
    display: flex; align-items: center; justify-content: center; color: #4a5d4a;
}
.ac-peer-meta { flex: 1; min-width: 0; }
.ac-peer-meta strong { display: block; font-size: 16px; }
.ac-peer-meta span { font-size: 13px; }
.ac-status-pill {
    font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px;
    background: var(--border); color: var(--text-muted);
}
.ac-status-pill.ok { background: #d1fae5; color: #065f46; }
.ac-status-pill.bad { background: #fee2e2; color: #991b1b; }
.ac-label-strip {
    flex-shrink: 0;
    background: #ebedeb;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    position: relative;
    z-index: 2;
}
.ac-label-strip-inner {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 8px 16px;
}
.ac-label-strip-title {
    font-size: 12px; font-weight: 700; color: var(--text-muted);
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.ac-label-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; align-items: center; }
.ac-lchip {
    display: inline-flex; align-items: center; font-size: 12px; font-weight: 600;
    padding: 4px 10px; border-radius: 999px; border: 1px solid;
}
.ac-label-empty { font-size: 12px; color: var(--text-muted); font-style: italic; }
.ac-label-edit-btn { flex-shrink: 0; }
.ac-label-panel {
    margin: 0 16px 12px; padding: 14px; background: #fff;
    border-radius: var(--radius-sm); box-shadow: var(--shadow-md); border: 1px solid var(--border);
}
.ac-label-panel-head { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.ac-label-panel-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.45; }
.ac-label-current { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; min-height: 4px; }
.ac-lchip-edit { padding: 4px 6px 4px 10px; }
.ac-lchip-remove {
    background: none; border: none; cursor: pointer; font-size: 16px; line-height: 1;
    opacity: .55; padding: 0 2px; color: inherit; vertical-align: middle;
}
.ac-lchip-remove:hover { opacity: 1; }
.ac-label-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ac-sugg-chip {
    border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px;
    font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text);
    transition: filter .15s;
}
.ac-sugg-chip:hover { filter: brightness(0.97); }
.ac-label-add-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.ac-label-input {
    flex: 1; min-width: 140px; padding: 8px 12px; border-radius: 8px;
    border: 1px solid var(--border); font-size: 14px; font-family: inherit;
}
.ac-label-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ac-messages-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px 16px 8px;
    display: flex;
    flex-direction: column;
}
.ac-load-older {
    align-self: center; margin-bottom: 10px; padding: 6px 14px; border-radius: 16px;
    border: none; background: rgba(255,255,255,.85); font-size: 12px; font-weight: 600;
    cursor: pointer; color: var(--text-muted); box-shadow: var(--shadow);
}
.ac-load-older:hover { background: #fff; color: var(--primary); }
.ac-messages { display: flex; flex-direction: column; gap: 6px; }
.ac-bubble { max-width: 78%; display: flex; flex-direction: column; align-self: flex-start; }
.ac-bubble-out { align-self: flex-end; }
.ac-bubble-inner {
    padding: 8px 12px 10px; border-radius: 8px; font-size: 14px; line-height: 1.45;
    box-shadow: 0 1px 1px rgba(0,0,0,.06);
}
.ac-bubble-in .ac-bubble-inner { background: #fff; border-radius: 0 8px 8px 8px; }
.ac-bubble-out .ac-bubble-inner { background: #dcf8c6; border-radius: 8px 0 8px 8px; }
.ac-bubble-text { word-break: break-word; white-space: pre-wrap; }
.ac-bubble-img { display: block; max-width: min(280px, 100%); border-radius: 6px; margin-bottom: 4px; }
.ac-bubble-file {
    display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: #075e54;
    text-decoration: none; margin-bottom: 4px;
}
.ac-bubble-file:hover { text-decoration: underline; }
.ac-bubble-meta {
    display: flex; flex-direction: column; gap: 3px; margin-top: 6px; padding: 0 4px;
    font-size: 11px; color: var(--text-muted);
}
.ac-bubble-in .ac-bubble-meta { align-items: flex-start; }
.ac-bubble-out .ac-bubble-meta { align-items: flex-end; }
.ac-bubble-user {
    font-size: 11px; font-weight: 600; color: #475569;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ac-bubble-user i { font-size: 10px; opacity: .65; margin-right: 5px; }
.ac-bubble-out .ac-bubble-user { color: #1b4332; }
.ac-bubble-time { font-size: 11px; color: var(--text-muted); opacity: .95; }
.ac-bubble-out .ac-bubble-time { color: #2d6a4f; }
.ac-failed { color: var(--danger); font-weight: 600; }
.ac-session-foot {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 8px; padding: 8px 16px 12px;
    font-size: 12px; color: var(--text-muted); background: #e8ebe8;
    border-top: 1px solid rgba(0,0,0,.06);
}
.ac-session-foot i { opacity: .7; }
.ac-session-foot strong { color: var(--text); font-weight: 600; }
.ac-composer {
    flex-shrink: 0;
    padding: 10px 14px 14px; background: #f0f2f0; border-top: 1px solid rgba(0,0,0,.06);
}
.ac-composer form { display: flex; gap: 8px; align-items: flex-end; }
.ac-textarea {
    flex: 1; min-height: 44px; max-height: 120px; resize: none; padding: 10px 14px;
    border-radius: 24px; border: none; font-family: inherit; font-size: 14px;
    box-shadow: var(--shadow);
}
.ac-textarea:focus { outline: 2px solid rgba(37, 211, 102, .4); }
.ac-attach-btn {
    width: 44px; height: 44px; border-radius: 50%; background: #fff; display: flex;
    align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow);
    color: var(--text-muted); flex-shrink: 0;
}
.ac-attach-btn:hover { color: var(--primary); }
.ac-send-btn {
    width: 48px; height: 48px; border-radius: 50%; padding: 0; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.ac-attach-name { font-size: 12px; color: var(--text-muted); margin: 6px 0 0 52px; }
.ac-device-select, .ac-input-peer { width: 100%; }

@media (max-width: 900px) {
    .content-area:has(.agent-chat-page) { max-height: calc(100dvh - 56px); }
    .agent-chat-shell { grid-template-columns: 1fr; }
    .ac-sidebar {
        max-height: min(220px, 32vh);
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .ac-main { min-height: 0; flex: 1; }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0,0,0,.3);
    }
    .main-wrapper { margin-left: 0; }
    .menu-toggle { display: block; }
    .content-area { padding: 20px; }
    .topbar { padding: 0 20px; }
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-2-sm { grid-template-columns: 1fr; }
    .devices-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .broadcast-detail-layout { grid-template-columns: 1fr; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 20px; }
    .quick-actions { flex-direction: column; }
    .page-actions { flex-direction: column; align-items: stretch; }
    .apikey-actions { width: 100%; }
    .apikey-row { flex-direction: column; align-items: stretch; }
    .test-row { grid-template-columns: 1fr; }
    .radio-group { flex-direction: column; }
    .contact-checklist { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 28px 20px; }
    .topbar .greeting { display: none; }
}
