:root {
    --bg: #f6f8f7;
    --panel: #ffffff;
    --ink: #17201c;
    --muted: #66736d;
    --line: #dfe7e2;
    --green: #2fc316;
    --green-dark: #188b0d;
    --blue: #2e72d2;
    --amber: #c77810;
    --red: #c2413a;
    --shadow: 0 18px 50px rgba(16, 28, 22, .12);
}

body.theme-dark {
    --bg: #080d0a;
    --panel: #101813;
    --ink: #eef7f0;
    --muted: #96a69c;
    --line: #26342c;
    --green: #35d51a;
    --green-dark: #65ef4d;
    --blue: #74a9ff;
    --amber: #ffc15a;
    --red: #ff8178;
    --shadow: 0 18px 50px rgba(0, 0, 0, .36);
}

* {
    box-sizing: border-box;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.auth-screen {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at top left, rgba(47, 195, 22, .16), transparent 32%), #08100c;
}

.auth-panel {
    display: grid;
    gap: 24px;
    width: min(440px, 100%);
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.auth-logo {
    width: 280px;
    max-width: 100%;
    padding: 12px;
    border-radius: 8px;
    background: #020403;
}

.brand-logo {
    width: 210px;
    max-width: 100%;
    padding: 10px;
    border-radius: 8px;
    background: #020403;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--green-dark);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 42px;
    line-height: 1;
}

h2 {
    margin-bottom: 0;
    font-size: 30px;
}

h3 {
    margin-bottom: 18px;
    font-size: 17px;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 13px;
}

.stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: #34423b;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    outline: 0;
}

input,
select {
    height: 44px;
    padding: 0 12px;
}

textarea {
    min-height: 84px;
    padding: 12px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(47, 195, 22, .14);
}

.primary,
.ghost,
.nav-link,
.icon-button {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    font-weight: 800;
}

.primary {
    padding: 0 16px;
    background: var(--green);
    color: #062b00;
}

.ghost {
    padding: 0 14px;
    background: color-mix(in srgb, var(--panel) 78%, var(--green) 22%);
    color: var(--ink);
}

.error {
    min-height: 20px;
    margin: 0;
    color: var(--red);
    font-size: 13px;
    font-weight: 700;
}

.app {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    display: flex;
    position: sticky;
    top: 0;
    flex-direction: column;
    gap: 24px;
    height: 100vh;
    padding: 22px;
    border-right: 1px solid var(--line);
    background: var(--panel);
}

nav {
    display: grid;
    gap: 8px;
}

.nav-link {
    padding: 0 14px;
    background: transparent;
    color: #405049;
    text-align: left;
}

.nav-link.active,
.nav-link:hover {
    background: #eaf7e7;
    color: #0c5405;
}

.user-card {
    display: grid;
    gap: 10px;
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

#user-name {
    font-weight: 800;
}

.workspace {
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.filters {
    display: grid;
    grid-template-columns: minmax(240px, 1.4fr) repeat(3, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
}

th,
td {
    padding: 15px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

tbody tr {
    transition: background .15s ease;
}

tbody tr:hover {
    background: color-mix(in srgb, var(--panel) 84%, var(--green) 16%);
}

.lead-name {
    display: grid;
    gap: 3px;
    font-weight: 850;
}

.lead-name small,
.subtle {
    color: var(--muted);
    font-size: 12px;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: #edf3ef;
    color: #26332d;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

body.theme-dark .pill {
    background: #1c2a22;
    color: #e7f5eb;
}

.pill.Nuevo {
    background: #e7f1ff;
    color: var(--blue);
}

.pill.Contactado,
.pill.Tibio {
    background: #fff4dc;
    color: var(--amber);
}

.pill.Interesado,
.pill.Caliente {
    background: #eaf8e7;
    color: var(--green-dark);
}

.pill.Convertido {
    background: #dff7ea;
    color: #087443;
}

.pill.Frío {
    background: #eef2f5;
    color: #51616d;
}

.detail-panel {
    position: fixed;
    z-index: 20;
    top: 0;
    right: 0;
    width: min(620px, 100%);
    height: 100vh;
    overflow: auto;
    padding: 24px;
    background: var(--panel);
    box-shadow: -20px 0 60px rgba(11, 19, 15, .22);
}

.overlay {
    position: fixed;
    z-index: 10;
    inset: 0;
    background: rgba(8, 16, 12, .36);
}

.detail-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.icon-button {
    width: 42px;
    background: #edf3ef;
    color: #26332d;
    font-size: 26px;
    line-height: 1;
}

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

.panel-block {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.timeline {
    display: grid;
    gap: 12px;
}

.timeline-item {
    position: relative;
    padding-left: 22px;
}

.timeline-item::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
}

.timeline-item strong {
    display: block;
}

.tag-row,
.followup-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.metric-grid article,
.charts article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.metric-grid article {
    display: grid;
    gap: 8px;
    padding: 18px;
}

.metric-grid span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.metric-grid strong {
    font-size: 30px;
}

.charts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.charts article {
    padding: 18px;
}

.bar {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    font-weight: 800;
}

.bar-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf3ef;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), #7dd957);
}

.lead-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.split-grid {
    display: grid;
    grid-template-columns: minmax(260px, 380px) 1fr;
    gap: 14px;
}

.panel-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 18px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: 18px;
    height: 18px;
}

.user-list {
    display: grid;
    gap: 10px;
}

.user-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

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

    .sidebar {
        position: static;
        height: auto;
    }

    .filters,
    .metric-grid,
    .charts,
    .split-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 680px) {
    .workspace,
    .detail-panel,
    .auth-panel {
        padding: 18px;
    }

    .filters,
    .metric-grid,
    .charts,
    .detail-grid,
    .lead-form,
    .split-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .brand-logo {
        width: 190px;
    }
}
