:root {
    --blue: #1d4ed8;
    --blue-dark: #1e3a8a;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f1f5f9;
    --card: #ffffff;
    --green: #16a34a;
    --red: #dc2626;
    --amber: #d97706;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.center { text-align: center; }
.num { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--blue-dark);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.brand-mark { font-size: 22px; }
.brand strong { display: block; font-size: 15px; color: #fff; }
.brand small { color: #94a3b8; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
    color: #cbd5e1;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
}
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }

.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.btn-block { width: 100%; text-align: center; }
.user-chip { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #cbd5e1; }
.user-chip .muted { color: #94a3b8; }

.content { flex: 1; padding: 28px 36px; max-width: 1100px; }

/* Header */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; }
.page-head p { margin: 0; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px; }
.actions { display: flex; gap: 8px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 18px; }
.card h2 { margin: 0 0 14px; font-size: 15px; color: var(--blue-dark); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }

.totals { display: flex; gap: 40px; justify-content: flex-end; padding: 16px 10px 0; border-top: 1px solid var(--line); margin-top: 8px; }
.totals strong { display: block; font-size: 20px; color: var(--blue); }

/* Stats */
.stats { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; min-width: 120px; }
.stat-num { display: block; font-size: 22px; font-weight: 700; }

/* Buttons */
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 14px; cursor: pointer; }
.btn:hover { text-decoration: none; background: #f8fafc; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { background: #fff; border-color: #fca5a5; color: #b91c1c; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

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

/* Forms */
form label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; text-transform: uppercase; letter-spacing: .4px; }
form input[type=text], form input[type=email], form input[type=password], form input[type=file], form select, form textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; background: #f8fafc;
}
form input:focus, form select:focus, form textarea:focus { outline: none; border-color: var(--blue); background: #fff; }
form .help-text, form .form-help { font-size: 12px; color: var(--muted); }
.form-error, form ul li { color: var(--red); font-size: 13px; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-draft, .badge-r-pending { background: #e2e8f0; color: #475569; }
.badge-under_review, .badge-queued, .badge-r-queued { background: #dbeafe; color: var(--blue-dark); }
.badge-sending, .badge-r-sent { background: #fef3c7; color: var(--amber); }
.badge-finished, .badge-r-delivered, .badge-r-read { background: #dcfce7; color: var(--green); }
.badge-failed, .badge-r-failed { background: #fee2e2; color: var(--red); }
.badge-discarded, .badge-r-skipped_suppressed, .badge-r-skipped_invalid { background: #f1f5f9; color: var(--muted); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-danger { background: #fee2e2; color: #991b1b; }

/* Mensaje de campaña / paginación */
.message-box { background: #f8fafc; border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; font-size: 14px; }
.pagination { display: flex; align-items: center; gap: 14px; justify-content: center; padding-top: 14px; }
.page-head h2 { margin: 0; }

/* Preview: mensaje renderizado por fila */
.msg-row td { background: #f8fafc; padding-top: 6px; padding-bottom: 12px; }
.msg-line { font-size: 13px; color: var(--ink); margin: 2px 0; white-space: pre-wrap; }
.msg-tag { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: #fff; background: var(--blue); border-radius: 4px; padding: 1px 6px; margin-right: 6px; }

/* Preview / inline forms */
.inline-form { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.inline-form label { margin: 0; }
.inline-form select { width: auto; min-width: 220px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; text-transform: none; font-weight: 400; color: var(--ink); }
.checkbox-row input { width: auto; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--blue-dark); }
.login-card { background: #fff; padding: 36px; border-radius: 14px; width: 340px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.login-brand { font-size: 20px; font-weight: 700; }
.login-card .btn { margin-top: 18px; }
