:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #dbeafe;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --success: #166534;
    --success-soft: #dcfce7;
    --warning: #92400e;
    --warning-soft: #fef3c7;
    --border: #e2e8f0;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --radius: 18px;
    --sidebar-width: 280px;
}

* { box-sizing: border-box; }

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .10), transparent 34%),
        radial-gradient(circle at bottom right, rgba(14, 165, 233, .10), transparent 30%),
        var(--bg);
    color: var(--text);
}

body.app-body {
    overflow-x: hidden;
}

body.public-body {
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    padding: 22px 18px;
    background: linear-gradient(180deg, #0f172a 0%, #111827 54%, #020617 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,.08);
    box-shadow: 18px 0 50px rgba(15, 23, 42, .18);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 22px;
    border-bottom: 1px solid rgba(255,255,255,.10);
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #38bdf8, #2563eb 62%, #7c3aed);
    color: #fff;
    text-decoration: none;
    font-weight: 900;
    font-size: 22px;
    box-shadow: 0 14px 32px rgba(37, 99, 235, .35);
}

.brand-mark.small {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    font-size: 18px;
}

.sidebar-brand strong {
    display: block;
    font-size: 20px;
    letter-spacing: -.03em;
}

.sidebar-brand span {
    display: block;
    color: #94a3b8;
    font-size: 13px;
    margin-top: 2px;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
    padding: 22px 4px;
}

.sidebar-link {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 14px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    transition: .18s ease;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
    transform: translateX(2px);
}

.sidebar-link.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(37, 99, 235, .95), rgba(14, 165, 233, .85));
    box-shadow: 0 14px 28px rgba(37, 99, 235, .28);
}

.sidebar-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255,255,255,.09);
    font-size: 14px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 4px 4px;
    border-top: 1px solid rgba(255,255,255,.10);
}

.user-card {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 16px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.08);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    background: #fff;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

.user-card strong {
    display: block;
    font-size: 14px;
}

.user-card span {
    display: block;
    color: #94a3b8;
    font-size: 12px;
    margin-top: 2px;
}

.logout-link {
    display: block;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 13px;
    text-align: center;
    color: #fecaca;
    text-decoration: none;
    font-weight: 800;
    font-size: 13px;
    background: rgba(239, 68, 68, .10);
}

.logout-link:hover {
    background: rgba(239, 68, 68, .18);
}

.app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 86px;
    padding: 18px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: rgba(243, 246, 251, .88);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(226, 232, 240, .85);
}

.page-title span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 4px;
}

.page-title h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.1;
    letter-spacing: -.04em;
}

.menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 14px;
    font-size: 22px;
    cursor: pointer;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.container {
    width: min(1180px, calc(100% - 48px));
    margin: 26px auto;
}

.app-container {
    flex: 1;
}

.public-container {
    flex: 1;
}

.public-topbar {
    padding: 18px 24px;
    background: rgba(255,255,255,.8);
    border-bottom: 1px solid var(--border);
}

.public-brand {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.public-brand strong {
    font-size: 20px;
}

h1, h2, h3 {
    letter-spacing: -.03em;
}

h1 { margin: 0 0 18px; }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 0 0 12px; font-size: 17px; }
p { line-height: 1.6; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.card {
    background: rgba(255,255,255,.92);
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

.metric {
    position: relative;
    overflow: hidden;
}

.metric::after {
    content: '';
    position: absolute;
    right: -34px;
    top: -34px;
    width: 95px;
    height: 95px;
    border-radius: 999px;
    background: var(--primary-soft);
}

.metric strong {
    position: relative;
    display: block;
    font-size: 36px;
    line-height: 1;
    margin-bottom: 7px;
    z-index: 1;
}

.metric span {
    position: relative;
    z-index: 1;
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
}

form .row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

label {
    display: block;
    font-weight: 800;
    margin-bottom: 7px;
    color: #334155;
    font-size: 14px;
}

input,
textarea,
select {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 13px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: .18s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

textarea {
    min-height: 240px;
    font-family: Arial, Helvetica, sans-serif;
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 12px 16px;
    border-radius: 13px;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    box-shadow: 0 12px 24px rgba(37, 99, 235, .18);
    transition: .18s ease;
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
    filter: brightness(.98);
}

.btn-mini {
    min-height: 42px;
    padding: 10px 14px;
    white-space: nowrap;
}

.btn.secondary {
    background: #475569;
    box-shadow: 0 12px 24px rgba(71, 85, 105, .14);
}

.btn.danger {
    background: var(--danger);
    box-shadow: 0 12px 24px rgba(185, 28, 28, .14);
}

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

tr:hover td {
    background: #f8fafc;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    background: #e5e7eb;
}

.badge.ativo,
.badge.enviado,
.badge.finalizada {
    color: var(--success);
    background: var(--success-soft);
}

.badge.pendente,
.badge.em_fila {
    color: var(--warning);
    background: var(--warning-soft);
}

.badge.erro,
.badge.descadastrado,
.badge.inativo {
    color: var(--danger);
    background: var(--danger-soft);
}

.alert {
    padding: 14px 16px;
    border-radius: 15px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    background: white;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
    font-weight: 700;
}

.alert.success { color: var(--success); background: var(--success-soft); }
.alert.error { color: var(--danger); background: var(--danger-soft); }
.alert.warning { color: var(--warning); background: var(--warning-soft); }

.help {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.form-field {
    margin-bottom: 16px;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
    background: #f8fafc;
}

.editor-toolbar button {
    width: auto;
    padding: 8px 10px;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 13px;
    box-shadow: none;
}

.editor-toolbar button:hover {
    background: #e5e7eb;
    transform: none;
}

.toolbar-divider {
    width: 1px;
    background: var(--border);
    margin: 4px 4px;
}

.email-editor {
    min-height: 290px;
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: 0 0 14px 14px;
    background: white;
    line-height: 1.6;
    outline: none;
    overflow-y: auto;
}

.email-editor:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.email-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
}

.email-editor h2,
.email-editor h3,
.email-editor p {
    margin-top: 0;
}

.editor-hidden {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.system-footer {
    margin-top: auto;
    padding: 18px 30px;
    color: #64748b;
    font-size: 13px;
}

.system-footer-inner {
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid rgba(226, 232, 240, .95);
}

.app-footer .system-footer-inner {
    width: min(1180px, calc(100% - 48px));
}

/* Login premium */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 38px 16px;
    background:
        radial-gradient(circle at 18% 20%, rgba(37, 99, 235, .22), transparent 28%),
        radial-gradient(circle at 82% 76%, rgba(14, 165, 233, .16), transparent 30%),
        linear-gradient(135deg, #eef4ff 0%, #f8fafc 44%, #eef6ff 100%);
}

.login-card {
    width: min(430px, 100%);
    background: rgba(255,255,255,.88);
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 28px;
    padding: 34px;
    box-shadow: 0 28px 85px rgba(15, 23, 42, .16);
    backdrop-filter: blur(16px);
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo {
    width: 70px;
    height: 70px;
    margin: 0 auto 16px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #38bdf8, #2563eb 62%, #7c3aed);
    color: white;
    font-size: 30px;
    font-weight: 900;
    box-shadow: 0 18px 38px rgba(37, 99, 235, .30);
}

.login-brand h1 {
    margin: 0;
    font-size: 28px;
    color: #0f172a;
}

.login-brand p {
    margin: 8px 0 0;
    color: #64748b;
    font-size: 14px;
}

.login-form {
    display: grid;
    gap: 18px;
}

.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon > span {
    position: absolute;
    left: 14px;
    color: #64748b;
    font-size: 15px;
}

.input-icon input {
    height: 52px;
    padding-left: 44px;
    background: #f8fafc;
}

.toggle-pass {
    position: absolute;
    right: 8px;
    height: 36px;
    padding: 0 12px;
    border-radius: 11px;
    background: #e2e8f0;
    color: #334155;
    box-shadow: none;
    font-size: 12px;
}

.toggle-pass:hover {
    transform: none;
    background: #cbd5e1;
}

.login-button {
    width: 100%;
    height: 52px;
    margin-top: 2px;
}

.login-footer,
.login-copyright {
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
}

.login-footer {
    margin-top: 20px;
}

.login-copyright {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    font-weight: 700;
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 960px) {
    .sidebar {
        transform: translateX(-102%);
        transition: transform .22s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(15, 23, 42, .45);
        opacity: 0;
        visibility: hidden;
        transition: .22s ease;
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    .app-main {
        margin-left: 0;
    }

    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .app-topbar {
        padding: 14px 18px;
    }

    .page-title h1 {
        font-size: 23px;
    }

    .container,
    .system-footer-inner {
        width: min(100% - 28px, 1180px);
    }
}

@media (max-width: 640px) {
    .topbar-actions .btn-mini {
        display: none;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 16px;
        border-radius: 16px;
    }

    .system-footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .login-card {
        padding: 28px 20px;
        border-radius: 24px;
    }
}
.campaigns-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.campaigns-head h2 {
    margin: 0;
    font-size: 22px;
    color: #0f172a;
}

.campaigns-head p {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 14px;
}

.progress-cell {
    min-width: 260px;
}

.campaign-progress-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.campaign-progress-info strong {
    font-size: 14px;
    color: #0f172a;
}

.campaign-progress-info span {
    font-size: 12px;
    color: #64748b;
}

.campaign-progress {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    display: flex;
}

.campaign-progress-sent {
    height: 100%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 999px 0 0 999px;
    transition: width 0.3s ease;
}

.campaign-progress-error {
    height: 100%;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    transition: width 0.3s ease;
}

.campaign-progress-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    font-size: 11px;
}

.campaign-progress-legend span {
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 700;
}

.legend-sent {
    background: #dcfce7;
    color: #166534;
}

.legend-pending {
    background: #e2e8f0;
    color: #475569;
}

.legend-error {
    background: #fee2e2;
    color: #991b1b;
}

@media (max-width: 760px) {
    .campaigns-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .progress-cell {
        min-width: 220px;
    }
}

.btn.danger,
button.danger {
    background: #dc2626;
    color: #ffffff;
    border: 0;
}

.btn.danger:hover,
button.danger:hover {
    background: #b91c1c;
}

.muted {
    color: #94a3b8;
    font-size: 13px;
}