:root {
    color-scheme: light;
    --wa-green: #128c7e;
    --wa-dark: #075e54;
    --paper: #ffffff;
    --line: #d9e2df;
    --text: #17211f;
    --muted: #5d6c68;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #edf5f2;
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.app-card {
    width: min(100%, 520px);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 18px 45px rgba(12, 40, 34, 0.12);
}

h1 {
    margin: 0;
    font-size: clamp(1.55rem, 5vw, 2rem);
    line-height: 1.15;
    letter-spacing: 0;
}

.subtitle {
    margin: 6px 0 0;
    color: var(--muted);
}

.logout-link {
    flex: 0 0 auto;
}

.top-actions,
.admin-actions,
.filter-actions,
.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.login-form {
    margin-top: 18px;
}

.notice {
    display: none;
    margin-bottom: 14px;
    padding: 11px 12px;
    border-radius: 8px;
    font-size: 0.95rem;
}

.notice.show {
    display: block;
}

.notice.success {
    background: #e6f4ee;
    color: #0c5b42;
}

.notice.warning {
    background: #fff8e5;
    color: #775407;
}

.notice.error {
    background: #fde9e9;
    color: #8b2020;
}

.loading {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    color: var(--muted);
}

.lead-panel {
    display: grid;
    gap: 12px;
}

.lead-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdfc;
}

.lead-row span,
.message-preview span {
    color: var(--muted);
    font-size: 0.92rem;
}

.lead-row strong {
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
}

.message-preview {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf9;
}

.message-preview p {
    margin: 7px 0 0;
    line-height: 1.5;
}

.button-stack {
    display: grid;
    gap: 10px;
    margin-top: 4px;
}

.btn {
    min-height: 48px;
}

.btn-success {
    --bs-btn-bg: var(--wa-green);
    --bs-btn-border-color: var(--wa-green);
    --bs-btn-hover-bg: var(--wa-dark);
    --bs-btn-hover-border-color: var(--wa-dark);
}

.empty-panel {
    margin-top: 16px;
    text-align: center;
}

.empty-panel p {
    margin-bottom: 16px;
    color: var(--muted);
}

.admin-shell {
    min-height: 100vh;
    padding: 18px;
}

.admin-page {
    width: min(100%, 1120px);
    margin: 0 auto;
}

.admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

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

.stat-card,
.admin-panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(12, 40, 34, 0.08);
}

.stat-card {
    padding: 14px;
}

.stat-card span,
.panel-title-row span {
    color: var(--muted);
    font-size: 0.9rem;
}

.stat-card strong {
    display: block;
    margin-top: 2px;
    font-size: 1.6rem;
    line-height: 1;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 0.8fr);
    gap: 16px;
    margin-bottom: 16px;
}

.admin-panel {
    padding: 16px;
}

.admin-panel h2 {
    margin: 0 0 14px;
    font-size: 1.2rem;
    letter-spacing: 0;
}

.admin-form,
.filter-form {
    display: grid;
    gap: 10px;
}

.filter-actions {
    margin-top: 4px;
}

.filter-actions .btn {
    flex: 1 1 120px;
}

.leads-panel {
    padding: 0;
    overflow: hidden;
}

.panel-title-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 16px 0;
}

.admin-table {
    margin: 0;
}

.admin-table th {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
}

.admin-table td {
    min-width: 110px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-pending {
    background: #e8f3ff;
    color: #14558f;
}

.status-opened {
    background: #fff8e5;
    color: #775407;
}

.status-contacted {
    background: #e6f4ee;
    color: #0c5b42;
}

.status-skipped {
    background: #fde9e9;
    color: #8b2020;
}

.row-actions {
    flex-wrap: nowrap;
}

.row-actions form {
    margin: 0;
}

@media (max-width: 430px) {
    .app-shell {
        align-items: start;
        padding: 12px;
    }

    .app-card {
        padding: 18px;
    }

    .lead-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .lead-row strong {
        text-align: left;
    }
}

@media (max-width: 760px) {
    .admin-shell {
        padding: 12px;
    }

    .admin-header,
    .panel-title-row {
        flex-direction: column;
    }

    .admin-actions .btn,
    .top-actions .btn {
        flex: 1 1 auto;
    }

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

    .row-actions {
        flex-wrap: wrap;
    }
}
