/* ============================================
   Broadcast Email System - Complete Redesign
   Dark/Light Theme | Professional Layout
   ============================================ */

/* -- Reset & Base -- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============ THEME VARIABLES ============ */
:root {
    --primary: #1e3a8a;
    --primary-dark: #0f172a;
    --primary-light: #2563eb;
    --primary-glow: rgba(30, 58, 138, 0.2);
    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.12);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.12);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.12);
    --info: #0284c7;
    --info-bg: rgba(2, 132, 199, 0.12);
    --radius: 8px;
    --radius-sm: 6px;
    --radius-xs: 4px;
    --transition: 0.2s ease-in-out;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --sidebar-width: 260px;
}

/* ============ DARK THEME (default) ============ */
[data-theme="dark"] {
    --bg-body: #0b1329;
    --bg-card: rgba(23, 35, 61, 0.85);
    --bg-card-solid: #17233d;
    --bg-input: rgba(15, 23, 42, 0.7);
    --bg-sidebar: #091020d9;
    --bg-sidebar-hover: rgba(37, 99, 235, 0.12);
    --bg-sidebar-active: linear-gradient(135deg, rgba(30, 58, 138, 0.4), rgba(37, 99, 235, 0.25));
    --bg-hover: rgba(100, 116, 139, 0.1);
    --bg-muted: rgba(100, 116, 139, 0.14);
    --border: rgba(100, 116, 139, 0.22);
    --border-light: rgba(100, 116, 139, 0.12);
    --border-focus: rgba(37, 99, 235, 0.6);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 36px rgba(0, 0, 0, 0.45);
    --scrollbar-thumb: rgba(100, 116, 139, 0.3);
    --scrollbar-track: transparent;
    --table-stripe: rgba(100, 116, 139, 0.05);
    --badge-bg: rgba(100, 116, 139, 0.18);
    --overlay: rgba(0, 0, 0, 0.65);
}

/* ============ LIGHT THEME ============ */
[data-theme="light"] {
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-solid: #ffffff;
    --bg-input: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-sidebar-hover: rgba(30, 58, 138, 0.06);
    --bg-sidebar-active: linear-gradient(135deg, rgba(30, 58, 138, 0.12), rgba(37, 99, 235, 0.08));
    --bg-hover: rgba(0, 0, 0, 0.04);
    --bg-muted: rgba(0, 0, 0, 0.05);
    --border: #cbd5e1;
    --border-light: #e2e8f0;
    --border-focus: rgba(37, 99, 235, 0.5);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-inverse: #f1f5f9;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 6px 30px rgba(0, 0, 0, 0.08);
    --scrollbar-thumb: rgba(0, 0, 0, 0.15);
    --scrollbar-track: transparent;
    --table-stripe: rgba(241, 245, 249, 0.6);
    --badge-bg: rgba(0, 0, 0, 0.05);
    --overlay: rgba(0, 0, 0, 0.4);
}
    --bg-sidebar-active: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.06));
    --bg-hover: rgba(0, 0, 0, 0.04);
    --bg-muted: rgba(0, 0, 0, 0.05);
    --border: rgba(0, 0, 0, 0.1);
    --border-light: rgba(0, 0, 0, 0.05);
    --border-focus: rgba(99, 102, 241, 0.4);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #f1f5f9;
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.1);
    --scrollbar-thumb: rgba(0, 0, 0, 0.15);
    --scrollbar-track: transparent;
    --table-stripe: rgba(0, 0, 0, 0.02);
    --badge-bg: rgba(0, 0, 0, 0.06);
    --overlay: rgba(0, 0, 0, 0.4);
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
    font-size: 14px;
}

/* ============ TYPOGRAPHY SCALE (compact) ============ */
h1, .h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h2, .h2 { font-size: 1.2rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
h3, .h3 { font-size: 0.95rem; font-weight: 600; line-height: 1.3; }
h4, .h4 { font-size: 0.85rem; font-weight: 600; line-height: 1.35; }
p, .text-body { font-size: 0.85rem; line-height: 1.55; }
.text-sm { font-size: 0.78rem; line-height: 1.5; }
.text-xs { font-size: 0.7rem; line-height: 1.45; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.caption { font-size: 0.68rem; color: var(--text-muted); }

/* Spacing scale */
:root {
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
}

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

/* -- Sidebar -- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: background var(--transition), border-color var(--transition);
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }
.sidebar::-webkit-scrollbar-track { background: var(--scrollbar-track); }

.sidebar-header {
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #1e3a8a);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
}

.sidebar-logo-text h1 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    transition: color var(--transition);
}

.sidebar-logo-text small {
    font-size: 0.62rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.sidebar-nav {
    padding: 12px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 14px 14px 4px;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all var(--transition);
    border: 1px solid transparent;
    position: relative;
}

.sidebar-link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
    transform: translateX(2px);
}

.sidebar-link.active {
    background: var(--bg-sidebar-active);
    border-color: rgba(37, 99, 235, 0.2);
    color: var(--text-primary);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-link-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--bg-muted);
    flex-shrink: 0;
    transition: all var(--transition);
}

.sidebar-link:hover .sidebar-link-icon {
    background: rgba(37, 99, 235, 0.12);
}

.sidebar-link.active .sidebar-link-icon {
    background: rgba(37, 99, 235, 0.18);
    color: var(--primary-light);
}

.sidebar-link-content strong {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
}

.sidebar-link-content small {
    display: block;
    font-size: 0.64rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.sidebar-badge {
    margin-left: auto;
    font-size: 0.58rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary-light);
}

/* -- Sidebar Footer -- */
.sidebar-footer {
    padding: 14px 12px;
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--bg-muted);
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), #1e3a8a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-info strong {
    display: block;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info small {
    font-size: 0.64rem;
    color: var(--text-muted);
}

.sidebar-footer-actions {
    display: flex;
    gap: 8px;
}

.btn-sidebar {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    font-family: var(--font);
}

.btn-sidebar svg {
    transition: transform 0.2s ease;
}

.btn-sidebar:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: rotate(15deg);
}

.btn-sidebar.logout {
    border-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.btn-sidebar.logout:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #ef4444 !important;
    transform: rotate(15deg) !important;
}

.btn-sidebar.logout:hover svg {
    transform: rotate(15deg);
}

/* ============ MAIN CONTENT AREA ============ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 32px 40px;
    max-width: 100%;
    min-width: 0;
}

/* -- Top Bar -- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 1.1rem;
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: rotate(15deg);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.breadcrumb a:hover { color: var(--primary); }

.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1px;
    letter-spacing: -0.01em;
}

.page-subtitle {
    font-size: 0.76rem;
    color: var(--text-secondary);
    max-width: 600px;
    line-height: 1.4;
}

/* ============ STATS GRID ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.stat-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    font-size: 1.05rem;
}

.stat-card-icon.primary { background: rgba(37, 99, 235, 0.12); color: var(--primary-light); }
.stat-card-icon.success { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.stat-card-icon.warning { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.stat-card-icon.info { background: rgba(59, 130, 246, 0.12); color: var(--info); }

.stat-card-label {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 3px;
}

.stat-card-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-card-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    margin-top: 4px;
    padding: 2px 7px;
    border-radius: 999px;
}

.stat-card-change.up { background: var(--success-bg); color: var(--success); }
.stat-card-change.down { background: var(--danger-bg); color: var(--danger); }

/* ============ CARD ============ */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.card-header h3 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-body { padding: 16px; }

/* ============ FORM ELEMENTS ============ */
.form-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    transition: all var(--transition);
}

.form-card:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group {
    margin-bottom: 14px;
}

.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.form-label .label-icon {
    color: var(--text-muted);
}

.form-hint {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 400;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.82rem;
    line-height: 1.5;
    transition: all var(--transition);
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

textarea.monospace {
    font-family: var(--font-mono);
    font-size: 0.84rem;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    line-height: 1.4;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-muted);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-success {
    background: linear-gradient(135deg, #059669, var(--success));
    color: white;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, var(--danger));
    color: white;
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.btn-warning {
    background: linear-gradient(135deg, #d97706, var(--warning));
    color: white;
}

.btn-warning:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm { padding: 5px 10px; font-size: 0.72rem; }
.btn-lg { padding: 11px 20px; font-size: 0.88rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; width: 32px; height: 32px; }

/* ============ FORM LAYOUT ============ */
.form-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Email Actions */
.email-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.email-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.email-counter #emailCount {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary-light);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 24px;
}

/* Placeholder hints */
.placeholder-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.placeholder-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.placeholder-info code {
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary-light);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
}

/* ============ LAYOUT CARDS ============ */
.layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.layout-option {
    position: relative;
    cursor: pointer;
}

.layout-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.layout-option-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.layout-option input[type="radio"]:checked + .layout-option-inner {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.layout-option-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-muted);
    border-radius: 8px;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all var(--transition);
}

.layout-option input[type="radio"]:checked + .layout-option-inner .layout-option-icon {
    background: var(--primary);
    color: white;
}

.layout-option-check {
    margin-left: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: all var(--transition);
    flex-shrink: 0;
}

.layout-option input[type="radio"]:checked + .layout-option-inner .layout-option-check {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ============ TABLE ============ */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

table th,
table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.84rem;
}

table th {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--badge-bg);
}

table tbody tr:hover { background: var(--bg-hover); }
table tbody tr:nth-child(even) { background: var(--table-stripe); }

.action-dropdown-toggle {
    background: var(--bg-card, #ffffff) !important;
    color: var(--text-primary, #1e293b) !important;
    border: 1px solid var(--border, #cbd5e1) !important;
    padding: 5px 12px !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    cursor: pointer !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease !important;
}

.action-dropdown-toggle:hover {
    background: var(--bg-hover) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}

[data-theme="dark"] .action-dropdown-toggle {
    background: var(--bg-card, #1e293b) !important;
    color: var(--text-primary, #f8fafc) !important;
    border-color: var(--border, #334155) !important;
}

[data-theme="light"] .action-dropdown-toggle {
    background: #ffffff !important;
    color: #1e293b !important;
    border-color: #cbd5e1 !important;
}

.action-dropdown-menu .dropdown-item:hover {
    background: var(--bg-hover, rgba(37, 99, 235, 0.08)) !important;
}

/* ============ PROGRESS ============ */
.progress-section {
    margin-top: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    animation: slideUp 0.4s ease-out;
}

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

.progress-header {
    margin-bottom: 16px;
}

.progress-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.progress-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat {
    font-size: 0.82rem;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
}

.stat-total { background: var(--badge-bg); color: var(--text-secondary); }
.stat-success { background: var(--success-bg); color: var(--success); }
.stat-fail { background: var(--danger-bg); color: var(--danger); }
.stat-info { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }

.pagination-group {
    display: inline-flex;
    border-radius: 6px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.pagination-group .page-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: none;
    border-right: 1px solid var(--border);
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pagination-group .page-btn:last-child {
    border-right: none;
}

.pagination-group .page-btn:hover:not(:disabled):not(.active) {
    background: var(--bg-hover);
    color: var(--primary);
}

.pagination-group .page-btn.active {
    background: var(--primary, #1e293b);
    color: #ffffff;
    font-weight: 600;
}

.pagination-group .page-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: var(--bg-muted);
}

.stat strong { font-weight: 700; }

.progress-bar-wrap {
    width: 100%;
    height: 6px;
    background: var(--bg-muted);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
}

.results-list::-webkit-scrollbar { width: 4px; }
.results-list::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 2px; }

.result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.result-item.success { border-color: rgba(16, 185, 129, 0.2); }
.result-item.fail { border-color: rgba(239, 68, 68, 0.2); }

.result-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.result-item.success .result-icon { background: var(--success-bg); color: var(--success); }
.result-item.fail .result-icon { background: var(--danger-bg); color: var(--danger); }

.result-info { flex: 1; min-width: 0; }
.result-email { font-size: 0.84rem; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-message { font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; }
.result-badge { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 10px; border-radius: 20px; flex-shrink: 0; }
.result-item.success .result-badge { background: var(--success-bg); color: var(--success); }
.result-item.fail .result-badge { background: var(--danger-bg); color: var(--danger); }

.progress-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============ MODAL ============ */
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), #1e3a8a);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    color: white;
    box-shadow: 0 4px 16px var(--primary-glow);
}

.modal-title {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.modal-subtitle {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.modal-details {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 20px;
}

.modal-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.modal-detail-row + .modal-detail-row { border-top: 1px solid var(--border-light); }

.detail-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.detail-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-email-list { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 0 4px; max-height: 100px; overflow-y: auto; }
.modal-email-tag { display: inline-block; background: rgba(37, 99, 235, 0.1); color: var(--primary-light); font-size: 0.72rem; font-weight: 500; padding: 3px 8px; border-radius: 999px; border: 1px solid rgba(37, 99, 235, 0.15); }
.modal-message-preview { margin-top: 4px; padding: 10px 12px; background: rgba(0,0,0,0.04); border-radius: var(--radius-xs); font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; max-height: 120px; overflow-y: auto; white-space: pre-wrap; }

.modal-actions { display: flex; gap: 10px; }
.modal-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: var(--radius-sm); font-family: var(--font); font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: all var(--transition); border: none; }
.modal-btn-cancel { background: var(--bg-muted); color: var(--text-secondary); border: 1px solid var(--border); }
.modal-btn-cancel:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-btn-confirm { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 4px 12px var(--primary-glow); }
.modal-btn-confirm:hover { transform: translateY(-1px); box-shadow: 0 6px 20px var(--primary-glow); }

/* ============ TOAST ============ */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    max-width: 90%;
    width: max-content;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease-out;
    backdrop-filter: blur(12px);
}

.toast-success { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.3); color: #6ee7b7; }
.toast-error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: #fca5a5; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============ FOOTER ============ */
.app-footer {
    text-align: center;
    margin-top: 48px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.app-footer p { font-size: 0.78rem; color: var(--text-muted); }

/* ============ UTILITIES ============ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }

/* ============ MOBILE MENU BUTTON ============ */
.mobile-menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    order: 10;
}

.mobile-menu-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Desktop: hamburger di right side topbar */
@media (min-width: 769px) {
    .mobile-menu-btn { display: none !important; }
}

/* ============ TOGGLE SWITCH ============ */
.tracking-options {
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all var(--transition);
}

.toggle-label:hover {
    border-color: var(--border);
    background: var(--bg-hover);
}

.toggle-label-text {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 500;
}

.toggle-label-text svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.slider {
    position: absolute;
    inset: 0;
    background: var(--bg-muted);
    border-radius: 24px;
    transition: all var(--transition);
}

.slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all var(--transition);
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
}

.ai-settings {
    margin-top: 12px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

.ai-settings .form-group {
    margin-bottom: 12px;
}

.ai-settings .form-group:last-child {
    margin-bottom: 0;
}

.ai-settings label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

/* ============ SEARCH BOX & FILTER BAR ============ */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    transition: all var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.88rem;
    outline: none;
    min-width: 0;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.form-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.88rem;
    cursor: pointer;
    outline: none;
    transition: all var(--transition);
    min-width: 140px;
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ============ FORM ROW ============ */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============ PAGINATION ============ */
.pagination {
    display: flex;
    justify-content: center;
    padding: 16px 0;
}

.pagination-inner {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-inner .btn {
    min-width: 36px;
    justify-content: center;
}

/* ============ TABLE CARD ============ */
.table-card .card-body {
    padding: 0;
}

.table-card .table-wrapper {
    border: none;
    border-radius: 0;
}


/* ============ MODAL OVERLAY (fullscreen backdrop) ============ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--overlay);
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease-out;
}

.modal-overlay.active,
.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display:flex"] {
    display: flex !important;
}

/* ============ MODAL (alternate classes for compatibility) ============ */
.modal {
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
    margin: 20px;
}

/* Large modal variants */
.modal-detail {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-preview {
    max-width: 640px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--bg-muted);
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px 24px;
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 24px 0;
    border-bottom: 1px solid var(--border);
}
.modal-tab {
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.modal-tab:hover { color: var(--text-primary); }
.modal-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.modal-detail-tab {
    display: none;
}
.modal-detail-tab.active {
    display: block;
}

.export-report-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.export-report-btn:hover { background: var(--primary-hover); }

/* ============ AUTH / UNSUBSCRIBE PAGE ============ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-body);
    padding: 20px;
}

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

.auth-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

/* ==================== RESPONSIVE ==================== */

/* --- LAPTOP KECIL (≤1024px) --- */
@media (max-width: 1024px) {
    .main-content { margin-left: var(--sidebar-width); padding: 20px 24px 32px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* --- TABLET & MOBILE (≤768px) --- */
/* Sidebar → bottom sheet overlay, not full-side */
@media (max-width: 768px) {
    /* ── SIDEBAR: clean simple mobile sidebar ── */
    .sidebar {
        transform: translateX(-100%);
        width: 250px;
        border-radius: 0 12px 12px 0;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        padding-top: env(safe-area-inset-top, 0px);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 40px rgba(0, 0, 0, 0.5);
    }

    /* Sidebar header compact */
    .sidebar-header { padding: 12px 12px 10px; }
    .sidebar-logo { gap: 8px; }
    .sidebar-logo-icon { width: 30px; height: 30px; border-radius: 8px; }
    .sidebar-logo-text h1 { font-size: 0.82rem; }
    .sidebar-logo-text small { font-size: 0.6rem; }

    /* Hide icon and subtitle in mobile sidebar — text only */
    .sidebar-link-icon { display: none; }
    .sidebar-link-content small { display: none; }
    .sidebar-badge { display: none; }

    /* Nav items simple */
    .sidebar-nav { padding: 6px 8px; gap: 0; }
    .nav-section-label {
        font-size: 0.55rem;
        padding: 12px 12px 2px;
        letter-spacing: 0.1em;
    }
    .sidebar-link {
        padding: 10px 12px;
        border-radius: 8px;
        gap: 0;
        font-size: 0.78rem;
    }
    .sidebar-link-content strong {
        font-size: 0.78rem;
        font-weight: 500;
    }
    .sidebar-link.active::before {
        left: -8px;
        width: 3px;
        height: 16px;
        border-radius: 0 2px 2px 0;
    }

    /* Sidebar footer compact */
    .sidebar-footer { padding: 8px 10px; gap: 6px; }
    .sidebar-user { padding: 6px 8px; gap: 6px; border-radius: 6px; }
    .sidebar-user-avatar { width: 26px; height: 26px; border-radius: 6px; font-size: 0.65rem; }
    .sidebar-user-info strong { font-size: 0.7rem; }
    .sidebar-user-info small { font-size: 0.6rem; }
    .btn-sidebar { padding: 6px 10px; font-size: 0.68rem; border-radius: 6px; }

    /* ── OVERLAY ── */
    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 99;
        display: none;
    }
    .mobile-overlay.active { display: block; }

    /* ── MOBILE MENU BUTTON: show in topbar-right ── */
    .mobile-menu-btn {
        display: flex !important;
        width: 38px;
        height: 38px;
        border-radius: 8px;
        margin-left: auto;
    }

    /* ── MAIN CONTENT ── */
    .main-content {
        margin-left: 0;
        padding: 12px 12px 24px;
    }

    /* ── TOPBAR: compact ── */
    .topbar {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        margin-bottom: 14px;
    }
    .topbar-left { gap: 8px; align-items: center; flex: 1; min-width: 0; }
    .topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
    .page-title { font-size: 1.05rem; }
    .page-subtitle { font-size: 0.72rem; margin-top: 1px; }

    /* ── STATS: 2-column grid, compact ── */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
    .stat-card { padding: 14px 12px; border-radius: var(--radius-sm); }
    .stat-card-icon { width: 34px; height: 34px; margin-bottom: 8px; font-size: 0.95rem; border-radius: 9px; }
    .stat-card-label { font-size: 0.64rem; letter-spacing: 0.05em; }
    .stat-card-value { font-size: 1.2rem; }
    .stat-card-change { font-size: 0.66rem; }

    /* ── FILTER BAR: vertical stack ── */
    .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
    .filter-bar .search-box { width: 100%; min-width: 0; flex: none; }
    .filter-bar .form-select { width: 100%; min-width: 0; }
    .filter-bar .btn { width: 100%; justify-content: center; }

    /* ── BULK SEND BAR ── */
    #bulkSendBar .btn-sm { min-height: 36px; }

    /* ── LAYOUT GRID ── */
    .layout-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .layout-option-inner { padding: 10px 12px; }
    .layout-option-icon { width: 30px; height: 30px; }

    /* ── CARDS ── */
    .card { border-radius: var(--radius-sm); }
    .card-header { padding: 12px 14px; }
    .card-header h3 { font-size: 0.88rem; }
    .card-body { padding: 14px; }

    /* ── FORM ── */
    .form-card { padding: 14px; }
    .form-row { grid-template-columns: 1fr; gap: 10px; }
    .form-group { margin-bottom: 14px; }
    .form-label { font-size: 0.78rem; }

    /* ── TABLES: horizontal scroll ── */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    }
    .table-wrapper::after {
        content: '';
        position: absolute;
        top: 0; right: 0; bottom: 0;
        width: 24px;
        background: linear-gradient(to left, var(--bg-card-solid), transparent);
        pointer-events: none;
        border-radius: 0 var(--radius-sm) 0 0;
    }
    table { min-width: 700px; }
    table th, table td { padding: 8px 10px; font-size: 0.76rem; white-space: nowrap; line-height: 1.35; }
    table th { font-size: 0.64rem; letter-spacing: 0.04em; }
    table td .btn, table td .btn-sm { min-height: 28px !important; padding: 4px 8px !important; font-size: 0.72rem !important; }
    table td[style*="display:flex"], table td[style*="display: flex"] { gap: 4px; flex-wrap: wrap; align-items: center; }

    /* ── MODAL: near-fullscreen ── */
    .modal,
    .modal-detail,
    .modal-preview {
        max-width: 100% !important;
        margin: 8px;
        border-radius: 12px;
        max-height: 93vh;
    }
    .modal-overlay { padding: 0; }
    .modal-header { padding: 14px 14px 0; }
    .modal-header h3 { font-size: 0.9rem; }
    .modal-body { padding: 14px; }
    .modal-close { width: 34px; height: 34px; font-size: 1.2rem; }

    /* Modal tabs: horizontal swipe */
    .modal-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 2px;
        padding: 6px 10px 0;
        scrollbar-width: none;
    }
    .modal-tabs::-webkit-scrollbar { display: none; }
    .modal-tab { padding: 7px 10px; font-size: 11px; flex-shrink: 0; white-space: nowrap; }

    /* Modal actions */
    .modal-actions { flex-direction: column; gap: 6px; }
    .modal-btn { width: 100%; }
    .modal-content { max-width: 100%; margin: 8px; padding: 18px; }

    /* ── PROGRESS SECTION ── */
    .progress-section { padding: 14px; }
    .progress-stats { gap: 6px; }
    .stat { font-size: 0.72rem; padding: 3px 9px; }
    .progress-header h3 { font-size: 0.9rem; }
    .progress-actions { flex-direction: column; align-items: stretch; }
    .progress-actions .btn { width: 100%; }

    /* ── RESULTS ── */
    .result-item { padding: 8px 10px; flex-wrap: wrap; gap: 6px; }
    .result-email { font-size: 0.78rem; }
    .result-message { font-size: 0.7rem; }

    /* ── TOAST ── */
    .toast {
        top: 8px; left: 8px; right: 8px;
        transform: none; max-width: none;
        padding: 10px 14px; font-size: 0.78rem;
        border-radius: var(--radius-sm);
    }

    /* ── AUTH ── */
    .auth-card { padding: 24px 18px; }

    /* ── FOOTER ── */
    .app-footer { margin-top: 24px; padding-top: 12px; }
    .app-footer p { font-size: 0.7rem; }

    /* ── PAGINATION ── */
    .pagination-inner .btn { min-width: 38px; height: 38px; font-size: 0.8rem; }

    /* ── EMAIL ACTIONS ── */
    .email-actions { flex-wrap: wrap; gap: 6px; }
    .email-counter { font-size: 0.74rem; }
}

/* --- HP KECIL (≤480px) --- */
@media (max-width: 480px) {
    /* Sidebar narrower on small phones */
    .sidebar { width: 240px; }

    /* Main content edge-to-edge */
    .main-content { padding: 8px 8px 20px; }

    /* Stats: tetap 2 kolom agar compact */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
    .stat-card {
        padding: 10px 8px;
        border-radius: var(--radius-xs);
    }
    .stat-card-icon { width: 28px; height: 28px; margin-bottom: 5px; font-size: 0.8rem; border-radius: 7px; }
    .stat-card-label { font-size: 0.56rem; }
    .stat-card-value { font-size: 1.05rem; }

    /* Topbar: tetap row, hamburger di kanan */
    .topbar {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        margin-bottom: 10px;
    }
    .topbar-left { flex: 1; min-width: 0; }
    .topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
    .page-title { font-size: 0.95rem; }
    .page-subtitle { font-size: 0.68rem; }

    /* Sidebar header */
    .sidebar-header { padding: 10px 8px 8px; }

    /* Sidebar links simpler */
    .sidebar-link { padding: 8px 10px; }
    .sidebar-link-content strong { font-size: 0.74rem; }

    /* Tables */
    table { min-width: 580px; }
    table th, table td { padding: 6px 8px; font-size: 0.72rem; line-height: 1.3; }
    table td .btn, table td .btn-sm { min-height: 26px !important; padding: 3px 6px !important; font-size: 0.7rem !important; }

    /* Bulk send bar: keep interval row compact */
    #bulkSendBar input[type="number"] { width: 44px !important; padding: 4px 2px !important; font-size: 13px !important; }

    /* Layout grid single */
    .layout-grid { grid-template-columns: 1fr; }

    /* Modal box (custom template preview) */
    .modal-box {
        width: 96% !important;
        max-width: 100% !important;
        border-radius: 8px !important;
    }

    /* Modal tighter */
    .modal, .modal-detail, .modal-preview {
        margin: 4px;
        border-radius: 8px;
        max-height: 96vh;
    }
    .modal-header h3 { font-size: 0.85rem; }
    .modal-close { width: 36px; height: 36px; }
    .modal-tab { padding: 5px 8px; font-size: 10px; }
    .modal-detail-row { flex-direction: column; align-items: flex-start; gap: 2px; }
    .detail-value { max-width: 100%; text-align: left; }

    /* Buttons & inputs: bigger touch targets */
    .btn { min-height: 44px; padding: 10px 16px; font-size: 0.85rem; }
    .btn-sm { min-height: 38px; padding: 6px 12px; font-size: 0.78rem; }
    /* Override: table buttons stay compact even on small phones */
    table td .btn, table td .btn-sm { min-height: 26px !important; padding: 3px 6px !important; font-size: 0.7rem !important; }
    /* Action column: icon-only row, no wrap */
    table td > div[style*="display:flex"] { flex-wrap: nowrap !important; gap: 2px !important; }
    table td > div[style*="display:flex"] .btn-sm { padding: 3px 4px !important; }
    table td .action-label { display: none; }
    /* Hide jabatan, perusahaan, bidang columns on small phones (col 4,5,6) */
    #contactsTable th:nth-child(4), #contactsTable td:nth-child(4),
    #contactsTable th:nth-child(5), #contactsTable td:nth-child(5),
    #contactsTable th:nth-child(6), #contactsTable td:nth-child(6) { display: none; }
    #contactsTable { min-width: 420px; }
    #contactsTable th:last-child { width: auto !important; }
    .btn-icon { min-height: 44px; min-width: 44px; }
    .theme-toggle { width: 44px; height: 44px; }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    select,
    textarea {
        font-size: 16px;
        padding: 11px 12px;
    }
    .search-box input { font-size: 16px; padding: 10px 0; }
    .form-select { font-size: 16px; padding: 10px 12px; min-width: 0; }

    /* Email actions */
    .email-actions { flex-direction: column; align-items: stretch; }
    .email-actions .btn { width: 100%; }

    /* Export */
    .export-report-btn { width: 100%; justify-content: center; }

    /* Toast */
    .toast { top: 4px; left: 4px; right: 4px; border-radius: var(--radius-xs); }

    /* Forms */
    .form-select { min-width: 0; }

    /* Pagination smaller */
    .pagination-inner .btn { min-width: 36px; height: 36px; font-size: 0.76rem; }
}