:root {
    --primary: #0b1628;
    --primary-soft: #12213a;
    --primary-light: #1b2e4d;
    --gold: #c9a45c;
    --gold-light: #e6c985;
    --gold-soft: rgba(201, 164, 92, 0.12);
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-soft: #f8f9fb;
    --text: #111827;
    --text-soft: #374151;
    --muted: #6b7280;
    --muted-light: #9ca3af;
    --border: #e5e7eb;
    --border-soft: #edf0f3;
    --success: #16835b;
    --success-soft: rgba(22, 131, 91, 0.10);
    --danger: #b83232;
    --danger-soft: rgba(184, 50, 50, 0.10);
    --whatsapp: #1faa59;
    --radius-xl: 30px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 14px;
    --shadow-soft: 0 12px 40px rgba(11, 22, 40, 0.06);
    --shadow-card: 0 18px 55px rgba(11, 22, 40, 0.09);
    --shadow-modal: 0 30px 90px rgba(11, 22, 40, 0.18);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 90% 0%, rgba(201, 164, 92, 0.06), transparent 28%), var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, input, select {
    font: inherit;
}

button {
    border: 0;
}

button, select {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid rgba(201, 164, 92, 0.25);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.app-shell {
    min-height: 100vh;
    width: 100%;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: max(12px, env(safe-area-inset-top)) 18px 12px;
    background: rgba(255, 255, 255, 0.90);
    border-bottom: 1px solid rgba(229, 231, 235, 0.75);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.topbar-left, .topbar-actions {
    display: flex;
    align-items: center;
}

.topbar-left {
    gap: 12px;
}

.topbar-actions {
    gap: 8px;
}

.icon-button {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: var(--primary);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(11, 22, 40, 0.05);
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.icon-button i {
    font-size: 19px;
}

.icon-button:hover {
    background: var(--surface-soft);
    border-color: #d9dde3;
}

.icon-button:active {
    transform: scale(0.95);
}

.topbar-title {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.eyebrow {
    color: var(--gold);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.18em;
}

.topbar-title h1 {
    margin: 0;
    color: var(--primary);
    font-size: 20px;
    line-height: 1.15;
    font-weight: 750;
    letter-spacing: -0.025em;
}

.main-content {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 70px;
}

.state-card {
    min-height: 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.state-card h2 {
    margin: 18px 0 8px;
    color: var(--primary);
    font-size: 20px;
    font-weight: 750;
}

.state-card p {
    max-width: 360px;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.65;
}

.loading-icon {
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    color: var(--gold);
    background: var(--gold-soft);
}

.loading-icon i {
    font-size: 27px;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.state-icon {
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    color: var(--gold);
    background: var(--gold-soft);
}

.state-icon.danger {
    color: var(--danger);
    background: var(--danger-soft);
}

.state-icon i {
    font-size: 29px;
}

.page-intro {
    margin-bottom: 24px;
}

.section-kicker, .result-label {
    display: block;
    margin-bottom: 7px;
    color: var(--gold);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.page-intro h2 {
    margin: 0;
    color: var(--primary);
    font-size: clamp(28px, 6vw, 38px);
    line-height: 1.05;
    font-weight: 780;
    letter-spacing: -0.045em;
}

.page-intro p {
    max-width: 620px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.65;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.stat-card {
    min-height: 132px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 17px;
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, #ffffff 0%, #fafbfc 100%);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.stat-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--gold);
    background: var(--gold-soft);
}

.stat-icon i {
    font-size: 19px;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stat-content span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.stat-content strong {
    color: var(--primary);
    font-size: 25px;
    line-height: 1;
    font-weight: 780;
    letter-spacing: -0.035em;
}

.toolbar-card {
    padding: 15px;
    margin-bottom: 28px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box > i {
    position: absolute;
    left: 15px;
    color: var(--muted);
    font-size: 19px;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    height: 52px;
    padding: 0 46px 0 44px;
    border-radius: 16px;
    color: var(--text);
    background: var(--surface-soft);
    border: 1px solid transparent;
    outline: none;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input::placeholder {
    color: #9ca3af;
}

.search-box input:focus {
    background: #ffffff;
    border-color: rgba(201, 164, 92, 0.45);
    box-shadow: 0 0 0 4px rgba(201, 164, 92, 0.08);
}

.clear-search {
    position: absolute;
    right: 10px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.clear-search:hover {
    background: #eef0f3;
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 13px;
}

.filter-field {
    min-width: 0;
}

.filter-field label {
    display: block;
    margin: 0 0 6px 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.select-wrap {
    position: relative;
}

.select-wrap > i {
    position: absolute;
    left: 14px;
    top: 50%;
    color: var(--muted);
    font-size: 17px;
    transform: translateY(-50%);
    pointer-events: none;
}

.select-wrap select {
    width: 100%;
    height: 48px;
    appearance: none;
    -webkit-appearance: none;
    padding: 0 40px 0 42px;
    border-radius: 14px;
    color: var(--text);
    background: var(--surface-soft);
    border: 1px solid transparent;
    outline: none;
    cursor: pointer;
}

.select-wrap::after {
    content: "";
    position: absolute;
    right: 15px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
}

.select-wrap select:focus {
    background: #fff;
    border-color: rgba(201, 164, 92, 0.45);
    box-shadow: 0 0 0 4px rgba(201, 164, 92, 0.08);
}

.result-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 13px;
}

.result-header h3 {
    margin: 0;
    color: var(--primary);
    font-size: 19px;
    line-height: 1.2;
    font-weight: 750;
    letter-spacing: -0.025em;
}

.result-count {
    flex-shrink: 0;
    padding: 7px 10px;
    border-radius: 999px;
    color: var(--primary);
    background: var(--gold-soft);
    font-size: 10px;
    font-weight: 750;
}

.leads-list {
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.lead-card {
    position: relative;
    padding: 17px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.lead-card:hover {
    border-color: #d9dde3;
    box-shadow: 0 18px 45px rgba(11, 22, 40, 0.09);
}

.lead-main {
    display: flex;
    align-items: flex-start;
    gap: 13px;
}

.lead-avatar {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    color: var(--primary);
    background: linear-gradient(145deg, #f7edda, #efe2c5);
    font-size: 16px;
    font-weight: 800;
}

.lead-content {
    min-width: 0;
    flex: 1;
}

.lead-name-row {
    display: flex;
    align-items: center;
    gap: 7px;
}

.lead-name {
    margin: 0;
    color: var(--primary);
    font-size: 15px;
    line-height: 1.25;
    font-weight: 750;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lead-source {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 7px;
    border-radius: 999px;
    color: var(--success);
    background: var(--success-soft);
    font-size: 8px;
    font-weight: 800;
    white-space: nowrap;
}

.lead-project {
    margin-top: 5px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lead-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-top: 5px;
}

.lead-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 10px;
}

.lead-meta-item i {
    font-size: 12px;
}

.lead-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 15px;
}

.lead-action {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 12px;
    border-radius: 13px;
    color: var(--primary);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.lead-action:hover {
    background: #f0f2f5;
    border-color: #d9dde3;
}

.lead-action:active {
    transform: scale(0.97);
}

.lead-action i {
    font-size: 16px;
}

.lead-action.whatsapp {
    color: #ffffff;
    background: var(--whatsapp);
    border-color: var(--whatsapp);
}

.lead-action.whatsapp:hover {
    background: #198f4a;
    border-color: #198f4a;
}

.empty-state {
    padding: 55px 24px;
    text-align: center;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px dashed #d9dde3;
}

.empty-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 17px;
    border-radius: 22px;
    color: var(--gold);
    background: var(--gold-soft);
}

.empty-icon i {
    font-size: 29px;
}

.empty-state h3 {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 18px;
    font-weight: 750;
}

.empty-state p {
    max-width: 420px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.65;
}

.primary-button {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 17px;
    border-radius: 14px;
    color: #ffffff;
    background: var(--primary);
    font-size: 12px;
    font-weight: 750;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(11, 22, 40, 0.16);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button:hover {
    background: var(--primary-soft);
    box-shadow: 0 14px 28px rgba(11, 22, 40, 0.20);
}

.primary-button:active {
    transform: scale(0.97);
}

.primary-button i {
    font-size: 17px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 20px max(20px, env(safe-area-inset-bottom));
    background: rgba(7, 15, 28, 0.52);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lead-detail-modal {
    position: relative;
    width: min(100%, 470px);
    max-height: min(720px, calc(100vh - 40px));
    overflow-y: auto;
    padding: 28px 22px 22px;
    border-radius: 30px;
    background: linear-gradient(160deg, #ffffff 0%, #fbfbfc 100%);
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: var(--shadow-modal);
    animation: modalUp 0.25s cubic-bezier(.2,.8,.2,1);
}

@keyframes modalUp {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--muted);
    background: #f1f3f5;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease;
}

.modal-close:hover {
    background: #e9ebee;
}

.modal-close:active {
    transform: scale(0.94);
}

.modal-close i {
    font-size: 18px;
}

.detail-icon {
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    border-radius: 19px;
    color: var(--gold);
    background: var(--gold-soft);
}

.detail-icon i {
    font-size: 28px;
}

.detail-heading {
    padding-right: 35px;
}

.detail-heading > span {
    display: block;
    margin-bottom: 5px;
    color: var(--gold);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.16em;
}

.detail-heading h2 {
    margin: 0;
    color: var(--primary);
    font-size: 25px;
    line-height: 1.1;
    font-weight: 780;
    letter-spacing: -0.035em;
}

.detail-heading p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.detail-info {
    display: flex;
    flex-direction: column;
    margin-top: 22px;
    overflow: hidden;
    border-radius: 19px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: 0;
}

.detail-row-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--primary);
    background: #ffffff;
}

.detail-row-icon i {
    font-size: 17px;
}

.detail-row > div:last-child {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.detail-row span {
    color: var(--muted);
    font-size: 10px;
}

.detail-row strong {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-actions {
    margin-top: 17px;
}

.whatsapp-button {
    width: 100%;
    background: var(--whatsapp);
    box-shadow: 0 12px 28px rgba(31, 170, 89, 0.20);
}

.whatsapp-button:hover {
    background: #198f4a;
    box-shadow: 0 16px 32px rgba(31, 170, 89, 0.25);
}

.toast {
    position: fixed;
    z-index: 200;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    width: min(calc(100% - 32px), 420px);
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 14px;
    border-radius: 17px;
    background: rgba(11, 22, 40, 0.96);
    color: #ffffff;
    box-shadow: 0 18px 50px rgba(11, 22, 40, 0.25);
    transform: translate(-50%, 12px);
    animation: toastIn 0.25s ease forwards;
}

@keyframes toastIn {
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.toast-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    color: var(--gold-light);
    background: rgba(201, 164, 92, 0.13);
}

.toast-icon i {
    font-size: 17px;
}

.toast-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toast-content strong {
    font-size: 12px;
    font-weight: 750;
}

.toast-content span {
    color: rgba(255, 255, 255, 0.68);
    font-size: 10px;
    line-height: 1.4;
}

@media (min-width: 640px) {
    .topbar {
        padding-left: 28px;
        padding-right: 28px;
    }
    .main-content {
        width: min(1180px, calc(100% - 48px));
        padding-top: 38px;
    }
    .stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 14px;
    }
    .stat-card {
        min-height: 142px;
        padding: 18px;
    }
    .filter-row {
        grid-template-columns: minmax(0, 1.6fr) minmax(190px, 0.7fr);
    }
    .lead-card {
        padding: 19px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 20px;
    }
    .lead-main {
        flex: 1;
        min-width: 0;
    }
    .lead-actions {
        grid-template-columns: auto auto;
        justify-content: flex-end;
        margin-top: 0;
        flex-shrink: 0;
    }
    .lead-action {
        min-width: 115px;
    }
}

@media (min-width: 900px) {
    .topbar {
        min-height: 82px;
        padding-left: 36px;
        padding-right: 36px;
    }
    .main-content {
        padding-top: 46px;
        padding-bottom: 90px;
    }
    .page-intro {
        margin-bottom: 30px;
    }
    .page-intro p {
        font-size: 15px;
    }
    .stat-card {
        min-height: 152px;
        padding: 20px;
    }
    .stat-icon {
        width: 42px;
        height: 42px;
        border-radius: 13px;
    }
    .stat-icon i {
        font-size: 20px;
    }
    .stat-content strong {
        font-size: 28px;
    }
    .toolbar-card {
        padding: 18px;
    }
    .lead-card {
        padding: 20px;
    }
    .lead-card:hover {
        transform: translateY(-1px);
    }
}

@media (min-width: 1200px) {
    .main-content {
        width: min(1180px, calc(100% - 80px));
    }
    .topbar {
        padding-left: max(36px, calc((100vw - 1180px) / 2));
        padding-right: max(36px, calc((100vw - 1180px) / 2));
    }
}

@media (max-width: 380px) {
    .main-content {
        width: min(100% - 22px, 1180px);
    }
    .topbar {
        padding-left: 12px;
        padding-right: 12px;
    }
    .stats-grid {
        gap: 8px;
    }
    .stat-card {
        min-height: 122px;
        padding: 14px;
    }
    .stat-content strong {
        font-size: 22px;
    }
    .lead-card {
        padding: 14px;
    }
    .lead-actions {
        gap: 6px;
    }
    .lead-action {
        padding: 0 8px;
        font-size: 10px;
    }
    .lead-action i {
        font-size: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}