:root {
    --grad: linear-gradient(135deg, #0A54F8 0%, #65FE80 100%);
    --bg: #f3f5fa;
    --card-bg: #ffffff;
    --border: #e5e8f0;
    --text: #16213a;
    --muted: #6b7488;
    --primary: #0A54F8;
    --primary-dark: #0842c4;
    --accent: #65FE80;
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --error-bg: #fef2f2;
    --error-text: #b91c1c;
    --pending-bg: #fef9c3;
    --pending-text: #854d0e;
    --sent-bg: #dcfce7;
    --sent-text: #166534;
    --failed-bg: #fee2e2;
    --failed-text: #991b1b;
    --shadow-sm: 0 1px 2px rgba(16, 24, 60, 0.05), 0 1px 3px rgba(16, 24, 60, 0.06);
    --shadow-md: 0 4px 14px rgba(16, 24, 60, 0.08);
    --shadow-glow: 0 6px 20px rgba(10, 84, 248, 0.25);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    max-width: 1040px;
    margin: 0 auto;
    padding: 20px;
}

/* ---------- Nav ---------- */

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 22px;
    margin-bottom: 22px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.nav-logo-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    background: var(--grad);
    box-shadow: 0 0 0 4px rgba(10, 84, 248, 0.12);
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-links a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    padding: 8px 14px;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-links a:hover {
    background: #eef2ff;
    color: var(--primary);
}

.nav-links a.active {
    background: var(--grad);
    color: #fff;
}

.nav-links a.nav-logout {
    color: var(--error-text);
}

.nav-links a.nav-logout:hover {
    background: var(--error-bg);
    color: var(--error-text);
}

/* ---------- Cards ---------- */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}

.card h2 {
    margin-top: 0;
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

@media (max-width: 700px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Stats ---------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

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

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

.stat-highlight {
    grid-column: 1 / -1;
    background: var(--grad);
    border: none;
    box-shadow: var(--shadow-glow);
}

.stat-highlight .stat-num,
.stat-highlight .stat-label {
    color: #fff;
}

.stat-num {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
}

/* ---------- Forms ---------- */

label {
    display: block;
    font-weight: 700;
    margin: 14px 0 6px;
    font-size: 0.88rem;
    color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fbfcfe;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(10, 84, 248, 0.12);
}

textarea {
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    border: none;
    border-radius: 9px;
    padding: 11px 20px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 16px;
    transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--grad);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 8px 24px rgba(10, 84, 248, 0.32);
}

.btn-secondary {
    background: #eef1f7;
    color: var(--text);
}

.btn-secondary:hover { background: #e2e6ef; }

.btn-block { width: 100%; }

.btn-sm { padding: 7px 14px; font-size: 0.83rem; margin-top: 0; }

.inline-form {
    display: flex;
    flex-direction: column;
}

.muted { color: var(--muted); font-size: 0.9rem; }

/* ---------- Alerts ---------- */

.alert {
    padding: 13px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-bg); color: var(--success-text); border-color: #a7f3d0; }
.alert-error { background: var(--error-bg); color: var(--error-text); border-color: #fecaca; }

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.badge-pending { background: var(--pending-bg); color: var(--pending-text); }
.badge-sent { background: var(--sent-bg); color: var(--sent-text); }
.badge-failed { background: var(--failed-bg); color: var(--failed-text); }
.badge-unsubscribed { background: #e5e8f0; color: #4b5266; }

/* ---------- Table ---------- */

.table-scroll {
    overflow-x: auto;
    border-radius: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th {
    text-align: left;
    padding: 10px 12px;
    background: #f7f9fc;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr:hover { background: #f9fafc; }

.error-cell {
    max-width: 280px;
    white-space: normal;
    color: var(--error-text);
    font-size: 0.8rem;
}

.report-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.filter-links {
    display: flex;
    gap: 4px;
    background: #f3f5fa;
    padding: 4px;
    border-radius: 10px;
}

.filter-links a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 7px;
    transition: background 0.15s ease, color 0.15s ease;
}

.filter-links a:hover { color: var(--text); }

.filter-links a.active {
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.pagination {
    margin-top: 16px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination a {
    padding: 7px 13px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
}

.pagination a.active {
    background: var(--grad);
    color: #fff;
    border-color: transparent;
}

/* ---------- Login ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--grad);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border-radius: 18px;
    padding: 36px 32px;
    box-shadow: 0 20px 60px rgba(8, 20, 60, 0.35);
    text-align: center;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.login-logo-mark {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: var(--grad);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: var(--shadow-glow);
}

.login-card h1 {
    font-size: 1.3rem;
    margin: 0 0 6px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.login-card label {
    text-align: left;
}

.login-card .alert {
    text-align: left;
}
