:root {
    --ink: #0a0f1a;
    --slate: #2d3548;
    --muted: #6b7a94;
    --light: #c4cdd9;
    --surface: #f4f6f9;
    --white: #ffffff;
    --accent: #1a6bff;
    --accent-soft: #e8f0ff;
    --warm: #ff6b35;
    --green: #22c55e;
    --green-soft: #dcfce7;
    --red: #ef4444;
    --red-soft: #fee2e2;
    --yellow: #eab308;
    --yellow-soft: #fef9c3;
}

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

body {
    font-family: 'DM Sans', -apple-system, sans-serif;
    color: var(--ink);
    background: var(--surface);
    line-height: 1.6;
}

/* ─── LAYOUT ─── */
.app-nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    padding: 0.75rem 2rem;
    background: var(--white);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: flex; align-items: center; justify-content: space-between;
}
.app-nav .logo {
    font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.2rem;
    color: var(--ink); text-decoration: none;
    display: flex; align-items: center; gap: 0.5rem;
}
.app-nav .logo .mark {
    width: 26px; height: 26px; background: var(--ink); border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
}
.app-nav .logo .mark svg { width: 14px; height: 14px; }
.app-nav .nav-tabs { display: flex; gap: 0.25rem; }
.app-nav .nav-tabs button {
    padding: 0.5rem 1rem; border: none; background: none; cursor: pointer;
    font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 500;
    color: var(--muted); border-radius: 6px; transition: all 0.15s;
}
.app-nav .nav-tabs button:hover { background: var(--surface); color: var(--ink); }
.app-nav .nav-tabs button.active { background: var(--accent-soft); color: var(--accent); }

.app-container {
    max-width: 1200px; margin: 0 auto;
    padding: 5rem 2rem 2rem;
}

/* ─── STATS CARDS ─── */
.stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
    background: var(--white); border-radius: 12px; padding: 1.5rem;
    border: 1px solid rgba(0,0,0,0.04);
}
.stat-card .stat-label { font-size: 0.8rem; color: var(--muted); font-weight: 500; margin-bottom: 0.25rem; }
.stat-card .stat-value {
    font-family: 'Space Grotesk', sans-serif; font-size: 1.8rem; font-weight: 700;
    color: var(--ink); letter-spacing: -0.5px;
}
.stat-card .stat-sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }

/* ─── PANELS ─── */
.panel {
    background: var(--white); border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.04); margin-bottom: 1.5rem;
}
.panel-header {
    padding: 1.25rem 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--surface);
}
.panel-header h2 {
    font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 600;
}
.panel-body { padding: 1.5rem; }
.panel-body.no-pad { padding: 0; }

/* ─── BUTTONS ─── */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 1rem; border: none; border-radius: 8px; cursor: pointer;
    font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 500;
    transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: #1458d6; }
.btn-ghost { background: var(--surface); color: var(--ink); }
.btn-ghost:hover { background: #e8ecf1; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: var(--green-soft); color: #16a34a; }
.btn-success:hover { background: #bbf7d0; }
.btn-warn { background: var(--yellow-soft); color: #a16207; }
.btn-warn:hover { background: #fef08a; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── FORMS ─── */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block; font-size: 0.8rem; font-weight: 500;
    color: var(--slate); margin-bottom: 0.35rem;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.6rem 0.75rem; border: 1.5px solid #e2e8f0;
    border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 0.9rem;
    color: var(--ink); transition: border-color 0.15s; background: var(--white);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ─── TABLE ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 0.75rem 1rem; background: var(--surface); }
td { padding: 0.75rem 1rem; font-size: 0.85rem; border-bottom: 1px solid var(--surface); color: var(--slate); }
tr:hover td { background: rgba(26,107,255,0.02); }

/* ─── BADGES ─── */
.badge {
    display: inline-block; padding: 0.2rem 0.6rem; border-radius: 100px;
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-draft { background: var(--surface); color: var(--muted); }
.badge-active, .badge-sent { background: var(--accent-soft); color: var(--accent); }
.badge-queued { background: var(--yellow-soft); color: #a16207; }
.badge-opened { background: var(--green-soft); color: #16a34a; }
.badge-replied { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-clicked { background: #eff6ff; color: #1d4ed8; }
.badge-failed, .badge-bounced { background: var(--red-soft); color: var(--red); }
.badge-paused { background: var(--yellow-soft); color: #a16207; }
.badge-new { background: var(--surface); color: var(--muted); }
.badge-emailed { background: var(--accent-soft); color: var(--accent); }
.badge-completed { background: var(--green-soft); color: #16a34a; }
.badge-sending { background: #fef3c7; color: #92400e; }

/* ─── MODAL ─── */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--white); border-radius: 16px; padding: 2rem;
    width: 90%; max-width: 560px; max-height: 85vh; overflow-y: auto;
    transform: translateY(10px); transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal h3 {
    font-family: 'Space Grotesk', sans-serif; font-size: 1.2rem;
    font-weight: 700; margin-bottom: 1.5rem;
}
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ─── EMAIL PREVIEW ─── */
.email-preview {
    background: var(--surface); border-radius: 10px; padding: 1.25rem;
    margin-bottom: 1rem; cursor: pointer; transition: all 0.15s;
}
.email-preview:hover { background: #eef1f5; }
.email-preview .ep-subject { font-weight: 600; color: var(--ink); margin-bottom: 0.25rem; }
.email-preview .ep-to { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.5rem; }
.email-preview .ep-body { font-size: 0.85rem; color: var(--slate); line-height: 1.5; white-space: pre-line; }
.email-preview .ep-meta { display: flex; gap: 1rem; margin-top: 0.75rem; align-items: center; }

/* ─── ACTIVITY ─── */
.activity-item {
    display: flex; gap: 0.75rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--surface);
    align-items: flex-start;
}
.activity-icon {
    width: 32px; height: 32px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-size: 0.85rem; flex-shrink: 0;
}
.activity-icon.open { background: var(--green-soft); }
.activity-icon.click { background: var(--accent-soft); }
.activity-icon.reply { background: #f0fdf4; }
.activity-icon.bounce { background: var(--red-soft); }
.activity-text { font-size: 0.85rem; color: var(--slate); }
.activity-text strong { color: var(--ink); }
.activity-time { font-size: 0.75rem; color: var(--light); margin-top: 0.15rem; }

/* ─── EMPTY STATE ─── */
.empty-state {
    text-align: center; padding: 3rem 2rem;
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.empty-state h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9rem; color: var(--muted); margin-bottom: 1.5rem; }

/* ─── LOADING ─── */
.spinner {
    width: 20px; height: 20px; border: 2.5px solid var(--surface);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.85rem; padding: 2rem; justify-content: center; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .app-container { padding: 4.5rem 1rem 1rem; }
    .app-nav { padding: 0.75rem 1rem; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
