* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f3f4f6;
    color: #0f172a;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

a {
    color: inherit;
}

.app-header {
    background: #4b5563;
    color: #ffffff;
    padding: 24px 36px;
    border-bottom: 4px solid #22c55e;
}

.app-header h1 {
    margin: 0;
    font-size: 26px;
}

.app-header p {
    margin: 6px 0 0;
    color: #e5e7eb;
}

.app-main {
    width: min(1280px, calc(100% - 48px));
    margin: 32px auto;
}

.page-card {
    background: #ffffff;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.page-card h1,
.page-card h2 {
    margin: 0 0 14px;
    color: #111827;
}

.muted {
    color: #475569;
    margin: 0 0 16px;
}

.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-weight: 600;
}

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

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

.import-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.import-form input[type="file"] {
    min-height: 44px;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 14px;
    border: 0;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-dark {
    background: #475569;
    color: #ffffff;
}

.btn-dark:hover {
    background: #334155;
}

.btn-light {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-light:hover {
    background: #cbd5e1;
}

.btn-danger {
    background: #dc2626;
    color: #ffffff;
}

.btn-danger:hover {
    background: #b91c1c;
}

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

.stat-card {
    min-height: 92px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    padding: 18px;
    background: #ffffff;
}

.stat-card span {
    display: block;
    color: #475569;
    font-size: 13px;
    margin-bottom: 10px;
}

.stat-card strong {
    display: block;
    font-size: 28px;
    color: #020617;
}

.filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 18px 0;
}

.filters-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filters label {
    font-weight: 600;
    color: #1f2937;
}

.filters select {
    min-width: 210px;
    height: 42px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #0f172a;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.leads-table th {
    background: #f8fafc;
    color: #334155;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0;
}

.leads-table th,
.leads-table td {
    padding: 16px 14px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0;
}

.leads-table th:nth-child(1),
.leads-table td:nth-child(1) {
    min-width: 140px;
}

.leads-table th:nth-child(2),
.leads-table td:nth-child(2),
.leads-table th:nth-child(3),
.leads-table td:nth-child(3) {
    min-width: 150px;
}

.leads-table th:nth-child(4),
.leads-table td:nth-child(4),
.leads-table th:nth-child(5),
.leads-table td:nth-child(5),
.leads-table th:nth-child(6),
.leads-table td:nth-child(6) {
    min-width: 150px;
}

.leads-table th:last-child,
.leads-table td:last-child {
    min-width: 260px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-phone {
    background: #dbeafe;
    color: #1d4ed8;
}

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

.badge-sent {
    background: #e2e8f0;
    color: #334155;
}

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

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

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

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

.actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.action-text {
    color: #475569;
    line-height: 1.35;
}

.empty-state {
    text-align: center;
    color: #64748b;
    padding: 32px;
}

.pagination {
    margin-top: 18px;
}

.lead-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.summary-box {
    border: 1px solid #d8dee8;
    border-radius: 8px;
    padding: 14px;
    background: #f8fafc;
}

.summary-box span {
    display: block;
    color: #64748b;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.summary-box strong {
    color: #0f172a;
}

.response-form textarea {
    width: 100%;
    max-width: 760px;
    min-height: 120px;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    resize: vertical;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.message-card {
    border-radius: 8px;
    padding: 18px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
}

.message-card.inbound {
    border-color: #86efac;
    background: #f0fdf4;
}

.message-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    font-weight: 700;
}

.message-body {
    white-space: pre-line;
    line-height: 1.5;
}

.message-meta {
    margin-top: 12px;
    color: #64748b;
    font-size: 13px;
}

@media (max-width: 980px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 640px) {
    .app-main {
        width: min(100% - 24px, 1280px);
        margin: 20px auto;
    }

    .app-header {
        padding: 20px;
    }

    .page-card {
        padding: 18px;
    }

    .stats-grid,
    .lead-summary {
        grid-template-columns: 1fr;
    }

    .filters,
    .filters-inline,
    .import-form {
        align-items: stretch;
        flex-direction: column;
    }

    .filters select,
    .btn,
    .import-form input[type="file"] {
        width: 100%;
    }
}

.blocked-warning {
    display: inline-flex;
    max-width: 220px;
    padding: 8px 10px;
    border-radius: 6px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
}

.form-actions {
    margin-top: 12px;
}

.field-error {
    margin-top: 8px;
    color: #991b1b;
    font-size: 13px;
    font-weight: 700;
}

.message-card.outbound {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.message-card.inbound {
    border-color: #86efac;
    background: #f0fdf4;
}

.auth-page {
    min-height: calc(100vh - 130px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 48px;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 18px;
}

.form-group label {
    font-weight: 700;
    color: #24324a;
}

.input {
    width: 100%;
    height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 14px;
    background: #ffffff;
}

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

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 18px 0;
    color: #334155;
}

.error {
    margin: 4px 0 0;
    color: #dc2626;
    font-size: 13px;
    font-weight: 600;
}