/* ─── ManyWhats Admin Panel CSS ──────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Variables ─── */
:root {
    --bg: #0a0e17;
    --bg2: #0d1321;
    --sidebar: #0f1623;
    --card: #111827;
    --card2: #141c2e;
    --border: #1e293b;
    --border2: #263044;
    --primary: #25d366;
    --primary-dim: rgba(37, 211, 102, .15);
    --accent: #6366f1;
    --accent-dim: rgba(99, 102, 241, .15);
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #38bdf8;
    --success: #10b981;
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --sidebar-w: 240px;
    --topbar-h: 60px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, .4);
    --transition: .15s ease;
}

/* ── Reset ─── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
}

input,
select,
textarea,
button {
    font-family: inherit;
}

/* ── Layout ─── */
/* Sidebar is position:fixed so does NOT participate in any grid/flex flow.
   We simply push .main-wrapper right by the sidebar width. */
body:not(.auth-body) {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 200;
    transition: transform .25s ease;
}

.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ── Sidebar Logo ─── */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-dim);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
}

.logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Sidebar Nav ─── */
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 8px 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 1px;
}

.nav-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-link:hover {
    background: rgba(255, 255, 255, .05);
    color: var(--text);
}

.nav-link.active {
    background: var(--primary-dim);
    color: var(--primary);
}

/* ── Sidebar Footer ─── */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.sidebar-user-info {
    min-width: 0;
}

.sidebar-user-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition);
    flex-shrink: 0;
}

.logout-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ── Topbar ─── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 4px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Main Content ─── */
.main-content {
    flex: 1;
    padding: 24px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* ── Page Header ─── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Cards ─── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
}

.card-link {
    font-size: 12px;
    color: var(--primary);
}

.card-body {
    padding: 20px;
}

.mb-4 {
    margin-bottom: 16px;
}

.h-full {
    height: 100%;
}

/* ── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
    border: none;
    white-space: nowrap;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: #000;
}

.btn-primary:hover {
    background: #1db355;
}

.btn-secondary {
    background: var(--card2);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    border-color: var(--border2);
    background: var(--border);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--border);
}

.btn-danger {
    background: rgba(239, 68, 68, .15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, .3);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-lg {
    padding: 12px 20px;
    font-size: 14px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 4px;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Stat Cards ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    transition: border-color var(--transition);
}

.stat-card:hover {
    border-color: var(--border2);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 20px;
    height: 20px;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-trend {
    font-size: 11px;
}

.stat-trend.up {
    color: var(--success);
}

.stat-trend.neutral {
    color: var(--text-muted);
}

/* ── Charts ─── */
.row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-wrap {
    padding: 12px 20px 20px;
    height: 220px;
    position: relative;
}

.chart-wrap-sm {
    height: 170px;
}

.plan-legend {
    padding: 0 20px 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    color: var(--text-muted);
}

.legend-val {
    font-weight: 600;
}

/* ── Tables ─── */
.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(30, 41, 59, .5);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background: rgba(255, 255, 255, .02);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
}

/* ── User cells ─── */
.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cell-name {
    font-weight: 500;
    font-size: 13px;
}

.cell-sub {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Avatars ─── */
.avatar-sm,
.avatar-xs {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: #000;
    background: var(--primary);
    flex-shrink: 0;
    overflow: hidden;
}

.avatar-xs {
    width: 24px;
    height: 24px;
    font-size: 10px;
}

.avatar-sm img,
.avatar-xs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Badges ─── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success {
    background: rgba(16, 185, 129, .15);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, .15);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, .15);
    color: var(--danger);
}

.badge-info {
    background: rgba(56, 189, 248, .15);
    color: var(--info);
}

.badge-muted {
    background: rgba(100, 116, 139, .15);
    color: var(--text-muted);
}

.badge-plan {
    background: var(--accent-dim);
    color: var(--accent);
}

/* Plan-specific */
.badge-free {
    background: rgba(100, 116, 139, .15);
    color: #94a3b8;
}

.badge-starter {
    background: rgba(56, 189, 248, .15);
    color: var(--info);
}

.badge-pro {
    background: var(--accent-dim);
    color: var(--accent);
}

.badge-business {
    background: rgba(245, 158, 11, .15);
    color: var(--warning);
}

/* Role badges */
.badge-role-super_admin {
    background: rgba(239, 68, 68, .15);
    color: var(--danger);
}

.badge-role-admin {
    background: var(--accent-dim);
    color: var(--accent);
}

.badge-role-support {
    background: rgba(100, 116, 139, .15);
    color: var(--text-muted);
}

/* ── Toggle Switch ─── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border2);
    border-radius: 20px;
    transition: background var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform var(--transition);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(16px);
}

/* ── Forms ─── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 9px 12px;
    font-size: 13px;
    transition: border-color var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
}

.form-input::placeholder {
    color: var(--text-muted);
}

textarea.form-input {
    resize: vertical;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    margin-bottom: 24px;
}

.form-footer {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}

.checkbox-label input {
    width: auto;
}

.font-mono {
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.code-editor {
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

/* ── Filter bar ─── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    flex-wrap: wrap;
}

.filter-search {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    color: var(--text-muted);
}

.filter-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    padding: 9px 0;
    font-size: 13px;
    outline: none;
}

.filter-select {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 9px 12px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

/* ── Pagination ─── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.page-btn {
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
}

.page-info {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Actions ─── */
.action-btns {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ── Activity Feed ─── */
.activity-list {
    padding: 8px 0;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(30, 41, 59, .5);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--bg2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.activity-action {
    font-size: 13px;
    font-weight: 500;
}

.activity-meta {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Plans Grid ─── */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.plan-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all var(--transition);
}

.plan-card:hover {
    border-color: var(--border2);
    transform: translateY(-2px);
}

.plan-featured {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 1px var(--primary), 0 8px 32px rgba(37, 211, 102, .15);
}

.plan-badge {
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #000;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.plan-name {
    font-size: 18px;
    font-weight: 700;
}

.price-amount {
    font-size: 32px;
    font-weight: 800;
}

.price-period {
    font-size: 14px;
    color: var(--text-muted);
}

.price-yearly {
    font-size: 12px;
    color: var(--text-muted);
}

.price-save {
    color: var(--primary);
    font-weight: 600;
}

.plan-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.plan-stat strong {
    color: var(--text);
}

.feature-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 3px 0;
}

.feat-off {
    color: var(--text-muted);
}

.feature-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.feature-toggle-row:last-child {
    border-bottom: none;
}

.feature-toggle-label {
    font-size: 13px;
    font-weight: 500;
}

.feature-toggle-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.plan-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

/* ── Modals ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, .7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow);
    animation: slideUp .2s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 15px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    padding: 0 4px;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* ── Alerts ─── */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error {
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .3);
    color: #fca5a5;
}

.alert-success {
    background: rgba(16, 185, 129, .1);
    border: 1px solid rgba(16, 185, 129, .3);
    color: #6ee7b7;
}

.alert-info {
    background: rgba(56, 189, 248, .1);
    border: 1px solid rgba(56, 189, 248, .3);
    color: #7dd3fc;
}

/* ── Toast Notifications ─── */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 240px;
    animation: toastIn .2s ease;
    transition: opacity .2s;
}

.toast.hide {
    opacity: 0;
}

@keyframes toastIn {
    from {
        transform: translateX(20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--info);
}

/* ── Auth Layout ─── */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at top left, #0f1d30 0%, #0a0e17 70%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, .5);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 44px;
    height: 44px;
    background: var(--primary-dim);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-logo-name {
    font-size: 18px;
    font-weight: 800;
}

.auth-logo-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.auth-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 6px;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 24px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
}

.auth-back-link {
    font-size: 12px;
    color: var(--text-muted);
}

.auth-back-link:hover {
    color: var(--primary);
}

.input-with-icon {
    position: relative;
}

.input-with-icon .form-input {
    padding-right: 40px;
}

.input-icon-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 4px;
}

/* ── Stat chip ─── */
.stat-chip {
    background: var(--card2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

/* ── Feature chips ─── */
.feature-chips {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.feat-chip {
    background: var(--primary-dim);
    color: var(--primary);
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    padding: 2px 6px;
}

/* ── Settings ─── */
.settings-tabs-wrap {
    margin-bottom: 20px;
}

.settings-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
}

.settings-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 10px 16px;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}

.settings-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.settings-form {
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── Email Compose ─── */
.compose-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}

.compose-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.editor-tabs {
    display: flex;
    gap: 4px;
}

.editor-tab {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 12px;
    padding: 5px 10px;
    transition: all var(--transition);
}

.editor-tab.active {
    background: var(--card2);
    border-color: var(--border);
    color: var(--text);
}

.template-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.template-btn {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    padding: 8px 12px;
    text-align: left;
    transition: all var(--transition);
}

.template-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}

/* ── Popup preview ─── */
.popup-preview-frame {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 200px;
    padding: 20px;
    overflow: auto;
}

.popup-preview-inner {
    max-width: 500px;
    margin: 0 auto;
}

/* ── Helpers ─── */
.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 12px;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: 8px;
}

.mb-4 {
    margin-bottom: 16px;
}

/* ── Responsive ─── */
@media (max-width: 900px) {
    body:not(.auth-body) {
        grid-template-columns: 1fr;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .topbar-menu-btn {
        display: flex;
    }

    .row-2col {
        grid-template-columns: 1fr;
    }

    .form-two-col {
        grid-template-columns: 1fr;
    }

    .compose-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 560px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 16px;
    }

    .auth-card {
        margin: 16px;
        padding: 28px 20px;
    }
}