@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;600&display=swap");

:root {
    --bg: #11131c;
    --surface: #171923;
    --surface-low: #0c0e17;
    --surface-high: #1d1f29;
    --surface-higher: #282933;
    --sidebar: #1d1f29;
    --header: rgba(17, 19, 28, .88);
    --primary: #00daf3;
    --primary-strong: #00e5ff;
    --primary-soft: rgba(0, 218, 243, .12);
    --secondary: #cdbdff;
    --text: #e1e1ef;
    --muted: #bac9cc;
    --muted-dim: #849396;
    --border: #3b494c;
    --border-soft: rgba(255, 255, 255, .06);
    --success: #22c55e;
    --warning: #fbbf24;
    --danger: #ff8f85;
    --shadow: 0 24px 70px rgba(0, 0, 0, .28);
    --radius: 14px;
    --radius-sm: 9px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { background: var(--bg); }
body {
    background:
        radial-gradient(circle at 88% -10%, rgba(0, 218, 243, .08), transparent 32%),
        radial-gradient(circle at 20% 4%, rgba(82, 3, 213, .11), transparent 28%),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    margin: 0;
}
body::-webkit-scrollbar,
.admin-sidebar::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
pre::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}
body::-webkit-scrollbar-track,
.admin-sidebar::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track,
pre::-webkit-scrollbar-track { background: var(--bg); }
body::-webkit-scrollbar-thumb,
.admin-sidebar::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb {
    background: var(--surface-higher);
    border-radius: 999px;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover { color: #9cf0ff; text-decoration: none; }
code, pre {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.admin-shell,
.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}
.admin-sidebar,
.sidebar {
    background: rgba(29, 31, 41, .96);
    border-right: 1px solid var(--border);
    color: var(--text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    left: 0;
    overflow-y: auto;
    padding: 28px 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.admin-brand {
    display: block;
    margin-bottom: 44px;
    padding: 0 10px;
}
.admin-brand-mark {
    display: none;
}
.admin-brand strong {
    color: var(--primary);
    display: block;
    font-size: 48px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 0 22px rgba(0, 218, 243, .18);
}
.admin-brand span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    margin-top: 8px;
    text-transform: uppercase;
}
.admin-nav {
    display: grid;
    gap: 8px;
}
.admin-nav a {
    align-items: center;
    border-radius: 10px;
    color: var(--muted);
    display: flex;
    font-size: 15px;
    font-weight: 700;
    gap: 14px;
    min-height: 44px;
    padding: 10px 14px;
    position: relative;
    transition: background .16s ease, color .16s ease, transform .16s ease;
}
.admin-nav a:hover {
    background: var(--surface-higher);
    color: var(--text);
}
.admin-nav a.active {
    background: var(--surface-higher);
    color: var(--primary);
}
.admin-nav a.active:after {
    background: var(--primary);
    border-radius: 999px;
    bottom: 8px;
    content: "";
    position: absolute;
    right: 0;
    top: 8px;
    width: 4px;
}
.admin-nav span {
    color: currentColor;
    flex: 0 0 24px;
    font-size: 20px;
    text-align: center;
}
.admin-main,
.workspace { min-width: 0; }
.admin-topbar,
.topbar {
    align-items: center;
    backdrop-filter: blur(14px);
    background: var(--header);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    display: flex;
    gap: 18px;
    justify-content: space-between;
    min-height: 72px;
    padding: 14px 28px;
    position: sticky;
    top: 0;
    z-index: 15;
}
.admin-topbar p {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 4px;
    text-transform: uppercase;
}
.admin-topbar h1 {
    color: var(--text);
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.15;
    margin: 0;
}
.admin-topbar-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}
.admin-content,
.container {
    margin: 0 auto;
    max-width: 1320px;
    padding: 24px 28px 42px;
}

.status-pill,
.badge,
.live-badge {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 11px;
    font-weight: 900;
    justify-content: center;
    line-height: 1;
    min-height: 26px;
    padding: 7px 10px;
    white-space: nowrap;
}
.status-true,
.live-badge {
    background: rgba(0, 218, 243, .14);
    border: 1px solid rgba(0, 218, 243, .42);
    color: var(--primary);
}
.status-false,
.live-badge.error {
    background: rgba(255, 143, 133, .14);
    border: 1px solid rgba(255, 143, 133, .45);
    color: #ffb4ab;
}
.status-validation {
    background: rgba(251, 191, 36, .14);
    border: 1px solid rgba(251, 191, 36, .46);
    color: #fde68a;
}
.status-production {
    background: rgba(239, 68, 68, .18);
    border: 1px solid rgba(239, 68, 68, .55);
    color: #fecaca;
}
.live-badge.paused {
    background: rgba(251, 191, 36, .14);
    border-color: rgba(251, 191, 36, .42);
    color: #fde68a;
}
.live-updated {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.logout,
.button,
button {
    align-items: center;
    background: var(--primary);
    border: 1px solid rgba(0, 218, 243, .62);
    border-radius: 9px;
    color: #001f24;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 13px;
    font-weight: 900;
    justify-content: center;
    line-height: 1.1;
    min-height: 36px;
    padding: 9px 13px;
    text-align: center;
    transition: opacity .15s ease, transform .15s ease, background .15s ease, border-color .15s ease;
    width: auto;
}
.logout:hover,
.button:hover,
button:hover {
    opacity: .92;
    text-decoration: none;
    transform: translateY(-1px);
}
.logout,
.button.secondary,
summary.button.secondary {
    background: var(--surface-higher);
    border-color: var(--border);
    color: var(--text);
}
.button.danger,
button.danger {
    background: rgba(255, 143, 133, .14);
    border-color: rgba(255, 143, 133, .55);
    color: #ffdad6;
}
.button.warning,
button.warning {
    background: rgba(251, 191, 36, .14);
    border-color: rgba(251, 191, 36, .45);
    color: #fde68a;
}
.live-toggle {
    background: var(--surface-higher);
    border-color: var(--border);
    color: var(--text);
    min-height: 34px;
    padding: 8px 11px;
}

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.grid-2 {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.section { margin: 28px 0; min-width: 0; }
.section-title {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
    min-width: 0;
}
.section-title h2 {
    color: var(--text);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.2;
    margin: 0;
}
.section-title .muted,
.muted {
    color: var(--muted);
}

.card,
.chart-card,
.report-card,
.login-card,
.table-wrap {
    background: linear-gradient(180deg, rgba(29, 31, 41, .82), rgba(23, 25, 35, .88));
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
}
.card,
.chart-card,
.report-card {
    min-width: 0;
    overflow: hidden;
    padding: 24px;
}
.chart-card,
.report-card {
    border-color: rgba(132, 147, 150, .24);
}
.metric-card {
    min-height: 132px;
    overflow: hidden;
    position: relative;
}
.metric-card:after {
    background: radial-gradient(circle, rgba(0, 218, 243, .18), transparent 62%);
    content: "";
    height: 130px;
    position: absolute;
    right: -48px;
    top: -52px;
    width: 130px;
}
.metric-head {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}
.metric-icon {
    align-items: center;
    background: transparent;
    border-radius: 0;
    color: var(--primary);
    display: flex;
    font-size: 19px;
    font-weight: 900;
    height: auto;
    justify-content: center;
    width: auto;
}
.metric {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    margin: 0 0 16px;
    text-transform: uppercase;
}
.metric-value {
    color: var(--text);
    font-size: 31px;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.05;
    overflow-wrap: anywhere;
    position: relative;
    z-index: 1;
}

.empty {
    align-items: center;
    background: rgba(12, 14, 23, .62);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    display: flex;
    justify-content: center;
    min-height: 180px;
    padding: 20px;
    text-align: center;
}
.chart-box {
    height: 280px;
    max-height: 280px;
    min-height: 280px;
    position: relative;
    width: 100%;
}
.chart-box canvas,
canvas { max-height: 280px !important; }
.chart-box canvas {
    height: 280px !important;
    width: 100% !important;
}

.filters {
    align-items: end;
    background: linear-gradient(180deg, rgba(29, 31, 41, .82), rgba(23, 25, 35, .88));
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    margin-bottom: 18px;
    padding: 20px;
}
label {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    margin-bottom: 8px;
    text-transform: uppercase;
}
input,
select,
textarea {
    background: var(--surface-low);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font: inherit;
    min-height: 42px;
    padding: 10px 12px;
    width: 100%;
}
input::placeholder,
textarea::placeholder { color: rgba(186, 201, 204, .55); }
input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 218, 243, .12);
    outline: none;
}
input[type="checkbox"] {
    accent-color: var(--primary);
    min-height: auto;
    margin-right: 8px;
    width: auto;
}

.table-meta {
    align-items: center;
    color: var(--muted);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin: 0 0 12px;
}
.table-wrap {
    overflow-x: auto;
    padding: 0;
    width: 100%;
}
.report-card .table-wrap,
.card .table-wrap {
    background: transparent;
    border: 1px solid var(--border);
    box-shadow: none;
}
table {
    border-collapse: collapse;
    min-width: 940px;
    table-layout: auto;
    width: 100%;
}
th,
td {
    border-bottom: 1px solid rgba(132, 147, 150, .18);
    padding: 15px 16px;
    text-align: left;
    vertical-align: middle;
}
th {
    background: rgba(29, 31, 41, .72);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    position: sticky;
    text-transform: uppercase;
    top: 0;
    z-index: 1;
}
td {
    color: var(--text);
    overflow-wrap: anywhere;
}
tr:hover td { background: rgba(50, 52, 62, .28); }

.actions-cell {
    align-items: center;
    display: table-cell;
    min-width: 180px;
    white-space: normal;
    width: 1%;
}
.actions-cell form {
    display: inline-flex;
    margin: 2px;
}
.actions-cell .button,
.actions-cell button {
    display: inline-flex;
    font-size: 12px;
    margin: 2px;
    min-height: 30px;
    padding: 7px 9px;
    white-space: nowrap;
}

.chip-list {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 100%;
    overflow: hidden;
}
.chip-list code {
    background: rgba(0, 218, 243, .1);
    border: 1px solid rgba(0, 218, 243, .34);
    border-radius: 999px;
    color: var(--primary);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.25;
    max-width: 100%;
    overflow-wrap: anywhere;
    padding: 7px 10px;
    white-space: normal;
    word-break: break-word;
}

.badge {
    background: var(--surface-higher);
    border: 1px solid var(--border);
    color: var(--muted);
}
.badge-synced,
.badge-venta,
.badge-ok,
.badge-active,
.badge-si {
    background: rgba(34, 197, 94, .13);
    border-color: rgba(34, 197, 94, .36);
    color: #86efac;
}
.badge-failed,
.badge-perdido,
.badge-fail,
.badge-no-califica,
.badge-inactive,
.badge-no {
    background: rgba(255, 143, 133, .13);
    border-color: rgba(255, 143, 133, .36);
    color: #ffb4ab;
}
.badge-pending,
.badge-sql {
    background: rgba(251, 191, 36, .13);
    border-color: rgba(251, 191, 36, .36);
    color: #fde68a;
}
.badge-contactado,
.badge-lead {
    background: rgba(0, 218, 243, .13);
    border-color: rgba(0, 218, 243, .36);
    color: var(--primary);
}

.truncate,
.comment {
    display: inline-block;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}
.comment {
    color: var(--muted);
    max-width: 280px;
}
.error {
    background: rgba(255, 143, 133, .12);
    border: 1px solid rgba(255, 143, 133, .38);
    border-radius: 9px;
    color: #ffdad6;
    margin-bottom: 14px;
    padding: 12px 14px;
}
.success {
    background: rgba(34, 197, 94, .12);
    border: 1px solid rgba(34, 197, 94, .38);
    border-radius: 9px;
    color: #bbf7d0;
    margin-bottom: 14px;
    padding: 12px 14px;
}
pre {
    background: var(--surface-low);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    max-height: 420px;
    overflow: auto;
    padding: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.progress-row {
    align-items: center;
    background: rgba(12, 14, 23, .62);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(120px, 160px) 1fr 58px;
    margin: 10px 0;
    padding: 12px;
}
.progress-track {
    background: var(--surface-higher);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}
.progress-fill {
    background: linear-gradient(90deg, #5203d5, var(--primary));
    border-radius: 999px;
    height: 100%;
    min-width: 2px;
}
.rate-bar {
    background: var(--surface-higher);
    border-radius: 999px;
    height: 8px;
    margin-top: 7px;
    overflow: hidden;
    width: 120px;
}
.rate-bar span {
    background: var(--primary);
    display: block;
    height: 100%;
}
.rate-bar.sale span { background: var(--success); }
.rate-bar.bad span { background: var(--danger); }

.login-page {
    align-items: center;
    background:
        radial-gradient(circle at top, rgba(0, 218, 243, .14), transparent 34%),
        var(--bg);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}
.login-card {
    max-width: 430px;
    padding: 30px;
    width: 100%;
}
.login-card h1 { margin: 0 0 8px; }
.kv {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.kv div {
    background: rgba(29, 31, 41, .72);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    box-shadow: none;
    min-width: 0;
    overflow-wrap: anywhere;
    padding: 14px;
}
.kv strong {
    color: var(--muted);
    display: block;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0;
    margin-bottom: 6px;
    text-transform: uppercase;
}
.timeline {
    border-left: 2px solid rgba(0, 218, 243, .28);
    margin-left: 10px;
    padding-left: 18px;
}
.timeline-item {
    background: rgba(29, 31, 41, .72);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    box-shadow: none;
    margin-bottom: 12px;
    padding: 14px;
    position: relative;
}
.timeline-item:before {
    background: var(--primary);
    border: 3px solid var(--surface);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0, 218, 243, .2);
    content: "";
    height: 10px;
    left: -25px;
    position: absolute;
    top: 18px;
    width: 10px;
}
.profile-hero {
    background: linear-gradient(135deg, rgba(0, 218, 243, .18), rgba(82, 3, 213, .18));
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
    margin-bottom: 18px;
    padding: 24px;
}
.profile-hero h2 { margin: 0 0 8px; }
.profile-hero .muted { color: var(--muted); }

.highlight-new td,
.highlight-new { animation: livePulse 5s ease-out; }
.toast {
    background: var(--surface-higher);
    border: 1px solid var(--border);
    border-radius: 10px;
    bottom: 22px;
    box-shadow: var(--shadow);
    color: var(--text);
    font-weight: 900;
    opacity: 0;
    padding: 12px 14px;
    position: fixed;
    right: 22px;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease;
    z-index: 50;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
@keyframes livePulse {
    0% { background: rgba(0, 218, 243, .22); }
    100% { background: transparent; }
}

details summary {
    list-style: none;
}
details summary::-webkit-details-marker {
    display: none;
}

@media (max-width: 1080px) {
    .admin-shell,
    .app-shell {
        grid-template-columns: 230px minmax(0, 1fr);
    }
    .admin-brand strong { font-size: 38px; }
    .admin-content { padding: 20px; }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .admin-shell,
    .app-shell {
        display: block;
    }
    .admin-sidebar,
    .sidebar {
        height: auto;
        padding: 14px;
        position: static;
        width: 100%;
    }
    .admin-brand {
        margin-bottom: 14px;
    }
    .admin-brand strong { font-size: 32px; }
    .admin-nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 6px;
    }
    .admin-nav a {
        flex: 0 0 auto;
        white-space: nowrap;
    }
    .admin-nav a.active:after { display: none; }
    .admin-topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        position: static;
    }
    .admin-topbar-actions {
        justify-content: flex-start;
    }
    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }
    .admin-content { padding: 16px; }
    table { min-width: 820px; }
}
@media (max-width: 560px) {
    body { font-size: 13px; }
    .card,
    .chart-card,
    .report-card { padding: 18px; }
    .progress-row {
        grid-template-columns: 1fr;
    }
    .admin-topbar h1 { font-size: 22px; }
}
