body {
    font-family: system-ui, sans-serif;
    line-height: 1.5;
    margin: 0;
    padding: 0 1rem 2rem;
    color: #222;
    background: #f7f7f7;
}

header {
    background: #1e3a5f;
    color: #fff;
    padding: 0.75rem 0;
    margin: 0 -1rem 1rem;
    padding-left: 1rem;
    padding-right: 1rem;
}

header .brand {
    font-weight: 600;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

nav a {
    color: #1e3a5f;
    text-decoration: none;
}

nav a:hover {
    text-decoration: underline;
}

/* Faixa global: status operacional do motor WhatsApp */
.wa-global-engine {
    margin: -0.25rem 0 1rem;
    padding: 0.5rem 0.75rem;
    background: #e8eef5;
    border: 1px solid #c5d3e3;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
}

.wa-global-engine__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.65rem;
}

.wa-global-engine__title {
    font-weight: 700;
    color: #1e3a5f;
    margin-right: 0.25rem;
}

.wa-global-engine__badge {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: #fff;
    border: 1px solid #b0c4d8;
    color: #333;
}

.wa-global-engine__badge--idle {
    background: #f0f0f0;
    border-color: #ccc;
}

.wa-global-engine__badge--waiting_next_send {
    background: #fff8e6;
    border-color: #e6c200;
    color: #5c4a00;
}

.wa-global-engine__badge--ready_to_send {
    background: #e6f7ed;
    border-color: #2e9d4f;
    color: #0d4d24;
}

.wa-global-engine__badge--processing {
    background: #e3f2fd;
    border-color: #1976d2;
    color: #0d47a1;
}

.wa-global-engine__badge--daily_limit_reached {
    background: #fce8e6;
    border-color: #d84315;
    color: #6d1f0a;
}

.wa-global-engine__badge--misconfigured,
.wa-global-engine__badge--error {
    background: #fdecea;
    border-color: #c62828;
    color: #7f1010;
}

.wa-global-engine__badge--pending_without_schedule {
    background: #fff3e0;
    border-color: #ef6c00;
    color: #5d3100;
}

.wa-global-engine__badge--paused {
    background: #ede7f6;
    border-color: #5e35b1;
    color: #311b92;
}

.wa-global-engine__badge--outside_execution_window {
    background: #eceff1;
    border-color: #546e7a;
    color: #263238;
}

.wa-global-engine__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.wa-global-engine__actions .button-small {
    font-size: 0.72rem;
    padding: 0.15rem 0.45rem;
}

.wa-global-engine__msg {
    flex: 1 1 12rem;
    color: #333;
}

.wa-global-engine__meta {
    flex: 1 1 100%;
    font-size: 0.72rem;
    color: #555;
}

.wa-dash-engine-inline {
    font-size: 0.78rem;
    color: #333;
    margin: 0.35rem 0 0.75rem;
    padding: 0.35rem 0.5rem;
    background: #f4f7fa;
    border-radius: 4px;
    border-left: 3px solid #1e3a5f;
}

main {
    max-width: 48rem;
}

section {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 1rem 1.25rem;
}

section h1 {
    margin-top: 0;
    font-size: 1.35rem;
}

.button,
button {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.95rem;
    border: 1px solid #1e3a5f;
    border-radius: 4px;
    background: #1e3a5f;
    color: #fff;
    cursor: pointer;
}

.import-form {
    margin: 1rem 0;
}

.import-form label {
    display: block;
    margin-bottom: 0.35rem;
}

.import-form input[type="file"] {
    display: block;
    margin-bottom: 0.75rem;
}

.error {
    color: #a40000;
    margin-top: 1rem;
}

.import-preview {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.import-preview h2 {
    font-size: 1.15rem;
}

.import-preview h3 {
    font-size: 1rem;
    margin-top: 1rem;
}

.map-list {
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 0.5rem;
    max-width: 100%;
}

.preview-table {
    border-collapse: collapse;
    font-size: 0.8rem;
    white-space: nowrap;
}

.preview-table th,
.preview-table td {
    border: 1px solid #ddd;
    padding: 0.35rem 0.5rem;
    text-align: left;
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-table th {
    background: #f0f0f0;
}

.import-result {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.import-result h2 {
    font-size: 1.15rem;
}

.result-stats {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
}

.result-stats li {
    margin: 0.25rem 0;
}

.leads-main {
    max-width: 72rem;
}

.leads-section .leads-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.leads-section .leads-filters label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    gap: 0.25rem;
}

.leads-section .leads-filters input,
.leads-section .leads-filters select {
    min-width: 10rem;
    padding: 0.35rem 0.5rem;
}

.leads-table-wrap {
    margin-top: 0.5rem;
}

.leads-table {
    font-size: 0.8rem;
}

a.leads-row-link {
    color: #1e3a5f;
    text-decoration: none;
}

a.leads-row-link:hover {
    text-decoration: underline;
}

.dashboard-main {
    max-width: 48rem;
}

.dashboard-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.75rem 1rem;
    margin: 1rem 0;
}

.dashboard-metrics div {
    margin: 0;
}

.dashboard-metrics dt {
    font-size: 0.8rem;
    color: #555;
    margin: 0;
}

.dashboard-metrics dd {
    margin: 0.15rem 0 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.dashboard-generate {
    margin-top: 1rem;
}

.dashboard-section-title {
    font-size: 1.05rem;
    margin: 1.5rem 0 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.dashboard-whatsapp-block {
    margin-top: 0.25rem;
}

.wa-dash-loading {
    font-size: 0.85rem;
    color: #555;
    margin: 0.35rem 0 0.5rem;
}

.dashboard-whatsapp-metrics dd {
    font-size: 1rem;
}

.dashboard-whatsapp-actions {
    margin: 0.75rem 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.dashboard-whatsapp-actions .button-small {
    margin-top: 0;
}

.flash-msg {
    color: #a40000;
    margin: 0.75rem 0;
}

.flash-msg--success {
    color: #1b5e20;
    margin: 0.75rem 0;
    padding: 0.5rem 0.65rem;
    background: #e8f5e9;
    border-radius: 4px;
    border: 1px solid #a5d6a7;
}

.flash-msg--error {
    color: #7f1010;
    margin: 0.75rem 0;
    padding: 0.5rem 0.65rem;
    background: #fdecea;
    border-radius: 4px;
    border: 1px solid #c62828;
}

.muted {
    color: #555;
    font-size: 0.9rem;
}

.wa-cfg-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 28rem;
}

.wa-cfg-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.wa-cfg-form input {
    padding: 0.35rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.whatsapp-config-main {
    max-width: 48rem;
}

.batches-main,
.batch-detail-main {
    max-width: 72rem;
}

.batch-detail-back {
    margin: 0 0 0.75rem;
}

.batch-detail-back a {
    color: #1e3a5f;
    text-decoration: none;
}

.batch-detail-back a:hover {
    text-decoration: underline;
}

.batch-ops-title {
    font-size: 1.05rem;
    margin: 1.25rem 0 0.5rem;
}

.batch-ops-table-wrap {
    overflow-x: auto;
}

.batch-ops-table {
    font-size: 0.75rem;
    white-space: normal;
}

.batch-actions-cell {
    min-width: 14rem;
    vertical-align: top;
}

.batch-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
}

.batch-status-forms {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.batch-status-form {
    margin: 0;
}

.button-tiny {
    padding: 0.2rem 0.45rem;
    font-size: 0.68rem;
}

.dashboard-last-batch {
    margin: 1rem 0 0.5rem;
}

.batch-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    margin: 1rem 0;
}

.batch-meta div {
    margin: 0;
}

.batch-meta dt {
    font-size: 0.8rem;
    color: #555;
    margin: 0;
}

.batch-meta dd {
    margin: 0.15rem 0 0;
}

.wa-batch-summary {
    margin: 1rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.wa-summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin: 0.5rem 0 0;
}

.wa-summary-grid div {
    margin: 0;
}

.wa-summary-grid dt {
    font-size: 0.8rem;
    color: #555;
    margin: 0;
}

.wa-summary-grid dd {
    margin: 0.15rem 0 0;
    font-weight: 600;
}

.wa-toolbar {
    margin: 1rem 0 0;
    padding: 0.75rem 0 0;
    border-top: 1px solid #eee;
}

.wa-toolbar-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.wa-toolbar .button-small {
    margin-top: 0;
}

.wa-action-message {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: #1a5f1a;
    min-height: 1.25rem;
}

.wa-action-message--error {
    color: #a40000;
}

.button-secondary {
    background: #fff;
    color: #1e3a5f;
}

.button-secondary:hover {
    background: #eef2f7;
}

.wa-cell-wrap {
    white-space: normal;
    max-width: 10rem;
    word-break: break-word;
}

.wa-cell-mono {
    font-family: ui-monospace, monospace;
    font-size: 0.72rem;
}

.wa-cell-ellipsis {
    max-width: 7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.campaigns-main {
    max-width: 72rem;
}

.campaigns-filters {
    margin: 1rem 0;
}

.campaigns-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.25rem;
    align-items: flex-end;
}

.campaigns-filter-row label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.85rem;
}

.campaigns-filter-row select,
.campaigns-filter-row input {
    font-size: 0.9rem;
    padding: 0.25rem 0.35rem;
}

.campaigns-filter-submit {
    margin-top: 0;
}

.campaigns-meta {
    font-size: 0.85rem;
    color: #444;
    margin: 0.75rem 0;
}

.campaigns-pagination {
    margin: 0.5rem 0;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.campaigns-pagination--bottom {
    margin-top: 1rem;
}

.campaigns-table-wrap {
    margin-top: 0.5rem;
}

.campaigns-table {
    font-size: 0.72rem;
}

.campaigns-cell-ellipsis {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.campaigns-cell-mono {
    font-family: ui-monospace, monospace;
    font-size: 0.7rem;
}

.campaigns-template-lang {
    color: #666;
    font-size: 0.85em;
}

.campaigns-date {
    font-size: 0.7rem;
    white-space: nowrap;
}

.campaign-status {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.12rem 0.35rem;
    border-radius: 3px;
    display: inline-block;
}

.campaign-status--PENDING,
.campaign-status--SENDING {
    background: #fff4d6;
    color: #6b5200;
}

.campaign-status--SENT,
.campaign-status--DELIVERED {
    background: #e6f2ff;
    color: #124080;
}

.campaign-status--READ {
    background: #e8f5e9;
    color: #1b5e20;
}

.campaign-status--RESPONDED {
    background: #e3f2fd;
    color: #0d47a1;
}

.campaign-status--FAILED,
.campaign-status--STOPPED {
    background: #fdecea;
    color: #8b1a1a;
}

.campaign-failure-cell {
    max-width: 11rem;
    font-size: 0.68rem;
    color: #7a2a2a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lead-detail-main {
    max-width: 52rem;
}

.lead-detail-back {
    margin: 0 0 0.75rem;
}

.lead-detail-back a {
    color: #1e3a5f;
    text-decoration: none;
}

.lead-detail-back a:hover {
    text-decoration: underline;
}

.lead-detail-readonly {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.lead-detail-readonly h2,
.lead-edit-form h2 {
    font-size: 1.05rem;
    margin: 1rem 0 0.5rem;
}

.lead-detail-dl {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0.5rem 1rem;
    margin: 0;
}

.lead-detail-dl div {
    margin: 0;
}

.lead-detail-dl dt {
    font-size: 0.8rem;
    color: #555;
    margin: 0;
}

.lead-detail-dl dd {
    margin: 0.1rem 0 0;
    font-weight: 500;
}

.lead-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0.65rem 1rem;
    margin-bottom: 0.5rem;
}

.lead-form-grid label,
.lead-edit-form > label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    gap: 0.25rem;
}

.lead-form-full {
    grid-column: 1 / -1;
}

.lead-form-grid input:not([readonly]),
.lead-form-grid textarea,
.lead-edit-form textarea {
    padding: 0.35rem 0.5rem;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.lead-detail-hint {
    font-size: 0.85rem;
    color: #555;
    margin: 0.75rem 0 0.5rem;
}

.lead-whatsapp-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.whatsapp-preview {
    margin: 0.5rem 0 1rem;
    padding: 0.75rem 1rem;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.lead-whatsapp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.button-secondary {
    background: #fff;
    color: #1e3a5f;
}

.lead-status-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.lead-status-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.lead-status-quick-form {
    margin: 0;
}

.button-small {
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
}

.lead-status-form {
    margin-top: 0.5rem;
}

.lead-history-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.lead-history-table {
    font-size: 0.8rem;
    white-space: normal;
}

.lead-history-note {
    max-width: 18rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.wa-cfg-danger {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e0c4c4;
}

.wa-cfg-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.wa-cfg-modal[hidden] {
    display: none !important;
}

.wa-cfg-modal__panel {
    background: #fff;
    max-width: 28rem;
    width: 100%;
    padding: 1rem 1.25rem;
    border-radius: 6px;
    border: 1px solid #ccc;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}
