:root {
    --navy: #1a3054;
    --navy-light: #243d64;
    --red: #e02030;
    --red-hover: #c91a28;
    --bg: #f0f2f6;
    --white: #ffffff;
    --gray-100: #f7f8fa;
    --gray-200: #e8ebf0;
    --gray-300: #d0d5dd;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --text: #1f2937;
    --green: #059669;
    --yellow: #d97706;
    --blue: #2563eb;
    --sidebar-w: 220px;
}

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

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

/* ── LOGIN ── */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(26,48,84,0.08);
    padding: 48px 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-card h1 { font-size: 22px; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.login-card .subtitle { font-size: 14px; color: var(--gray-500); margin-bottom: 32px; }
.login-card .logo { height: 40px; margin-bottom: 20px; }

.login-card input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    outline: none;
    margin-bottom: 16px;
}

.login-card input:focus { border-color: var(--navy); }

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-success { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── BUTTONS ── */
.btn {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-red { background: var(--red); color: var(--white); }
.btn-red:hover { background: var(--red-hover); }
.btn-navy { background: var(--navy); color: var(--white); }
.btn-navy:hover { opacity: 0.9; }
.btn-outline { background: var(--white); color: var(--navy); border: 1.5px solid var(--gray-300); }
.btn-outline:hover { border-color: var(--navy); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger-outline { background: var(--white); color: #b91c1c; border: 1.5px solid #fecaca; }
.btn-danger-outline:hover { background: #fef2f2; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; }
.btn-green { background: var(--green); color: var(--white); }
.btn-green:hover { opacity: 0.9; }

/* ── LAYOUT: SIDEBAR + MAIN ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 { font-size: 16px; font-weight: 700; }
.sidebar-header .subtitle { font-size: 11px; opacity: 0.6; margin-top: 4px; }

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.sidebar-nav a.active { background: rgba(255,255,255,0.12); color: var(--white); border-right: 3px solid var(--red); }

.sidebar-nav a .nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
}

.sidebar-footer .user-email { opacity: 0.6; margin-bottom: 8px; }

.sidebar-footer .btn-logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: var(--white);
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
}

.sidebar-footer .btn-logout:hover { background: rgba(255,255,255,0.1); }

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 0;
}

/* ── PAGE HEADER ── */
.page-header {
    padding: 24px 32px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-header h2 { font-size: 20px; font-weight: 700; color: var(--navy); }

/* ── CARDS / STATS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    padding: 24px 32px;
}

.stat-card {
    background: var(--white);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.stat-card .stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--navy);
}

.stat-card .stat-detail { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ── TOOLBAR ── */
.toolbar {
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-input {
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    outline: none;
    width: 280px;
    background: var(--white);
}

.search-input:focus { border-color: var(--navy); }
.toolbar-spacer { flex: 1; }

.filter-select {
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    outline: none;
    background: var(--white);
}

/* ── TABLE ── */
.table-container { padding: 0 32px 32px; overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    font-size: 14px;
}

thead { background: var(--navy); color: var(--white); }

th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fb; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active { background: #ecfdf5; color: var(--green); }
.badge-draft { background: var(--gray-100); color: var(--gray-500); }
.badge-sending { background: #eff6ff; color: var(--blue); }
.badge-sent { background: #ecfdf5; color: var(--green); }
.badge-scheduled { background: #fef3c7; color: var(--yellow); }
.badge-error { background: #fef2f2; color: #b91c1c; }

.actions { display: flex; gap: 6px; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state h2 { font-size: 18px; margin-bottom: 8px; color: var(--gray-700); }

/* ── MODAL ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--white);
    border-radius: 12px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.modal-header h2 { font-size: 18px; font-weight: 700; color: var(--navy); }

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: var(--gray-200); }

.modal-body { padding: 24px 28px 28px; }
.modal-body .form-group { margin-bottom: 16px; }

.modal-body label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 6px;
}

.modal-body input,
.modal-body textarea,
.modal-body select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    outline: none;
}

.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus { border-color: var(--navy); }

.modal-body textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-footer {
    padding: 0 28px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ── CHART CONTAINER ── */
.chart-container {
    background: var(--white);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    margin: 0 32px 24px;
}

.chart-container h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 16px;
}

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--navy);
    color: var(--white);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 200;
    animation: slideUp 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

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

/* ── CSV DROP ZONE ── */
.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--navy);
    background: var(--gray-100);
}

.drop-zone .icon { font-size: 32px; margin-bottom: 8px; }
.drop-zone .label { font-size: 14px; }
.drop-zone .hint { font-size: 12px; margin-top: 4px; }

/* ── CAMPAIGN EDITOR ── */
.html-editor {
    width: 100%;
    min-height: 300px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    resize: vertical;
}

.html-editor:focus { border-color: var(--navy); outline: none; }

.preview-frame {
    width: 100%;
    min-height: 400px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    background: var(--white);
}

/* ── RESPONSIVE ── */

.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table-container { overflow-x: auto; }

@media (max-width: 1200px) {
    td, th { padding: 10px 10px; font-size: 13px; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .toolbar, .table-container, .stats-grid, .page-header, .chart-container { padding-left: 16px; padding-right: 16px; }
    .page-header { flex-wrap: wrap; }
    .page-header .actions { width: 100%; }
    .search-input { width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    .login-card { padding: 32px 24px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    td, th { padding: 8px 8px; font-size: 12px; }
}
