* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f3f4f6;
    color: #111827;
}

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
    padding: 32px;
}

.login-card h1,
.topbar h1,
.panel h2 {
    margin: 0 0 8px;
}

.topbar {
    background: #111827;
    color: #ffffff;
    padding: 22px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.topbar .muted {
    color: #d1d5db;
}

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

.panel,
.stat-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.panel {
    padding: 24px;
    margin-top: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat-card {
    padding: 18px;
}

.stat-card strong {
    display: block;
    font-size: 28px;
    margin-bottom: 4px;
}

.stat-card span,
.muted,
.hint {
    color: #6b7280;
}

.hint {
    margin-top: 6px;
    font-size: 13px;
}

label {
    display: block;
    font-weight: 700;
    margin: 18px 0 8px;
}

input,
textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 15px;
    font-family: Arial, Helvetica, sans-serif;
    background: #ffffff;
}

textarea {
    resize: vertical;
    line-height: 1.5;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary {
    background: #2563eb;
    color: #ffffff;
}

.btn-secondary {
    background: #374151;
    color: #ffffff;
}

.btn-light {
    background: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
}

.btn.small {
    min-height: 34px;
    padding: 7px 12px;
}

.full {
    width: 100%;
    margin-top: 22px;
}

.button-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.alert {
    padding: 14px 16px;
    border-radius: 10px;
    margin: 14px 0;
    font-weight: 600;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 16px;
}

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

th,
td {
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    padding: 10px;
    vertical-align: top;
}

th {
    background: #f9fafb;
    color: #374151;
}

.center {
    text-align: center;
}

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-sending {
    background: #dbeafe;
    color: #1e40af;
}

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

.badge-failed {
    background: #fee2e2;
    color: #991b1b;
}

.error-text {
    color: #991b1b;
    max-width: 260px;
    word-break: break-word;
}

@media (max-width: 820px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .button-row .btn {
        width: 100%;
    }
}

/* Rich email editor */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
    background: #f9fafb;
}

.toolbar-btn {
    border: 1px solid #d1d5db;
    background: #ffffff;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.toolbar-btn:hover {
    background: #eef2ff;
}

.rich-editor {
    width: 100%;
    min-height: 420px;
    border: 1px solid #d1d5db;
    border-radius: 0 0 10px 10px;
    padding: 16px;
    font-size: 15px;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.55;
    background: #ffffff;
    color: #111827;
    overflow: auto;
}

.rich-editor:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.rich-editor:empty::before {
    content: attr(data-placeholder);
    color: #9ca3af;
}

.rich-editor a {
    color: #2563eb;
    text-decoration: underline;
}

.rich-editor p,
.rich-editor div {
    margin-top: 0;
}

.rich-editor table {
    width: auto;
    border-collapse: collapse;
}

.rich-editor td,
.rich-editor th {
    border: 1px solid #d1d5db;
    padding: 6px 8px;
}
