:root {
    --bg: #0b0e14;
    --bg-panel: #131722;
    --bg-panel-2: #191f2e;
    --border: #262c3d;
    --text: #e6e9f0;
    --text-dim: #8a90a3;
    --accent: #6366f1;
    --accent-hover: #7678f5;
    --accent-soft: rgba(99, 102, 241, 0.15);
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
    --radius: 10px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: radial-gradient(circle at top left, #141a2b 0%, var(--bg) 55%);
    color: var(--text);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: rgba(19, 23, 34, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.2px;
}

.brand-badge {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.nav {
    display: flex;
    gap: 4px;
}

.nav a {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-dim);
    transition: background 0.15s, color 0.15s;
}

.nav a:hover { color: var(--text); background: var(--bg-panel-2); }
.nav a.active { color: var(--text); background: var(--accent-soft); }
.nav a.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ---------- Layout ---------- */
.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 { margin: 0 0 4px; font-size: 22px; }
.page-header p { margin: 0; color: var(--text-dim); font-size: 14px; }

/* ---------- Stat cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.stat-card .label { color: var(--text-dim); font-size: 13px; margin-bottom: 6px; }
.stat-card .value { font-size: 24px; font-weight: 700; }
.stat-card.subscribed .value { color: var(--green); }
.stat-card.unsubscribed .value { color: var(--text-dim); }
.stat-card.bounced .value { color: var(--red); }

/* ---------- Panel / Toolbar ---------- */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.toolbar .spacer { flex: 1; }

input[type="text"], input[type="search"], select {
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

input[type="text"]:focus, select:focus { border-color: var(--accent); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-panel-2);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: #222939; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger { color: var(--red); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.12); border-color: var(--red); }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
    text-align: left;
    padding: 12px 18px;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
tbody tr:last-child td { border-bottom: none; }

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

.badge.subscribed { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.badge.unsubscribed { background: rgba(138, 144, 163, 0.15); color: var(--text-dim); }
.badge.bounced { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.badge.complained { background: rgba(234, 179, 8, 0.15); color: var(--yellow); }

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

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-dim);
}

.pagination .controls { display: flex; gap: 6px; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 7, 12, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

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

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 420px;
    max-width: 92vw;
    padding: 22px;
}

.modal h2 { margin: 0 0 16px; font-size: 17px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input[type="text"], .field input[type="file"] { width: 100%; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.help-text { font-size: 12.5px; color: var(--text-dim); margin-top: 8px; line-height: 1.5; }

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 100;
    display: none;
}

.toast.show { display: block; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

@media (max-width: 720px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .nav { display: none; }
}
