/* ============================================================
   Grupo Valmúsica · Panel de Leads
   Capa minimalista sobre Pico CSS · Tipografía Inter
   Paleta de marca: teal #78c7c9 + oscuro #161212
   ============================================================ */

:root {
    /* Marca */
    --vm-teal:    #78c7c9;
    --vm-teal-d:  #3f9092;
    --vm-dark:    #1a1717;

    /* Estados (tonos sobrios, no neón) */
    --c-sin:   #c2570c;
    --c-cont:  #a16207;
    --c-proc:  #1d4ed8;
    --c-cerr:  #15803d;
    --c-rech:  #b91c1c;

    --c-ok:    #15803d;
    --c-info:  #1d4ed8;
    --c-warn:  #c2570c;
    --c-bad:   #b91c1c;
    --c-star:  #e0a82e;

    /* Superficies / texto */
    --surface:   #ffffff;
    --surface-2: #f6f7f8;
    --border:    #eaecef;
    --border-2:  #e0e3e7;
    --text:      #20242a;
    --text-soft: #717784;

    /* Pico overrides */
    --pico-primary:                  var(--vm-teal-d);
    --pico-primary-hover:            #347779;
    --pico-primary-background:       var(--vm-teal-d);
    --pico-primary-hover-background: #347779;
    --pico-border-radius: 8px;
    --pico-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --pico-font-size: 100%;
    --pico-line-height: 1.5;
    --pico-spacing: 0.9rem;
    --pico-form-element-spacing-vertical: 0.4rem;
    --pico-form-element-spacing-horizontal: 0.6rem;
}

html { font-size: 16px; }

body {
    background: var(--surface-2);
    color: var(--text);
    font-family: "Inter", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

main.container { padding-top: 1.5rem; padding-bottom: 3rem; max-width: 1320px; }

h2 { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 1.1rem; }
h3 { font-size: 0.95rem; font-weight: 600; margin: 0; letter-spacing: -0.005em; }

/* ---------- Nav ---------- */
.app-nav {
    background: var(--vm-dark);
    padding: 0.3rem 1.25rem;
    margin-bottom: 0;
    font-size: 0.85rem;
}
.app-nav a {
    color: #b9bec3;
    text-decoration: none;
    border-radius: 7px;
    padding: 0.4rem 0.75rem;
    font-weight: 500;
}
.app-nav a:hover { color: #fff; background: rgba(255,255,255,0.07); }
.app-nav a.active { color: #fff; background: rgba(120,199,201,0.18); }
.app-nav .brand { color: #fff; font-size: 1rem; font-weight: 600; letter-spacing: 0.005em; }
.app-nav .brand::before {
    content: "";
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--vm-teal);
    margin-right: 0.5rem;
    vertical-align: middle;
}
.app-nav a[role="button"].secondary {
    --pico-background-color: transparent;
    --pico-border-color: rgba(255,255,255,0.22);
    --pico-color: #d7dadd;
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
}

/* ---------- Page head ---------- */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.1rem;
}
.page-head h2 { margin: 0; }

/* ---------- Stat cards ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stats .stat {
    padding: 0.9rem 1.05rem;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-soft);
    text-decoration: none;
    transition: border-color .12s ease, box-shadow .12s ease;
    display: block;
}
a.stat:hover { border-color: var(--border-2); box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.stats .stat strong {
    display: block;
    font-size: 1.55rem;
    font-weight: 600;
    line-height: 1.15;
    margin-bottom: 0.15rem;
    color: var(--vm-dark);
    font-feature-settings: "tnum";
    letter-spacing: -0.02em;
}
.c-ok   { color: var(--c-ok) !important; }
.c-info { color: var(--c-info) !important; }
.c-warn { color: var(--c-warn) !important; }
.c-bad  { color: var(--c-bad) !important; }
.c-star { color: var(--c-star) !important; }

/* ---------- Panels ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.panel-head { margin-bottom: 0.9rem; }
.muted { color: var(--text-soft); font-size: 0.85rem; }

/* ---------- Badges (pills suaves) ---------- */
.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.55;
    white-space: nowrap;
    color: color-mix(in srgb, var(--badge, #6b7280) 78%, #000);
    background: color-mix(in srgb, var(--badge, #6b7280) 13%, #fff);
    border: 1px solid color-mix(in srgb, var(--badge, #6b7280) 22%, #fff);
}
.badge-source {
    font-size: 0.6rem;
    padding: 0 6px;
    font-weight: 500;
}
/* Celda de contacto: nombre arriba, badge de fuente debajo, siempre alineado */
.contact-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}
.contact-cell strong { line-height: 1.25; }

/* ---------- Tabla principal ---------- */
table { font-size: 0.8rem; }
table thead th {
    text-transform: uppercase;
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-soft);
    border-bottom: 1px solid var(--border-2);
    padding: 0.5rem 0.7rem;
}
table td { padding: 0.5rem 0.7rem; vertical-align: middle; border-bottom: 1px solid var(--border); }
tbody tr { transition: background .1s ease; }
tbody tr:hover { background: #fafbfc; }
tbody tr.is-done { opacity: 0.55; }
tbody td strong { font-weight: 600; }
table a { color: var(--vm-teal-d); text-decoration: none; }
table a:hover { text-decoration: underline; }

/* ---------- Select de estado (pill suave) ---------- */
.status-select {
    margin: 0;
    padding: 0.18rem 1.4rem 0.18rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 6px;
    width: auto;
    height: auto;
    cursor: pointer;
    border: 1px solid color-mix(in srgb, currentColor 28%, #fff);
    background-color: color-mix(in srgb, currentColor 11%, #fff);
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa0a8' d='M2 4.5l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.45rem center;
    background-size: 0.62rem;
    -webkit-appearance: none;
    appearance: none;
}
.status-select:focus { box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 20%, transparent); }
.status--sin_contactar { color: var(--c-sin); }
.status--contactado    { color: var(--c-cont); }
.status--en_proceso    { color: var(--c-proc); }
.status--cerrado       { color: var(--c-cerr); }
.status--rechazado     { color: var(--c-rech); }

/* ---------- Estrellas de calidad ---------- */
.stars { display: inline-flex; gap: 0; }
.stars .star {
    background: none;
    border: none;
    padding: 0 0.5px;
    margin: 0;
    width: auto;
    font-size: 0.82rem;
    line-height: 1;
    color: #d6d9dd;
    cursor: pointer;
    transition: color .08s ease;
}
.stars .star.on    { color: var(--c-star); }
.stars .star.hover { color: var(--c-star); }

/* ---------- Filtros ---------- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: end;
    margin-bottom: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
}
.filters label {
    margin-bottom: 0;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.filters select,
.filters input[type="search"] {
    margin-bottom: 0;
    margin-top: 0.25rem;
    height: 2.3rem;
    padding: 0 0.6rem;
    font-size: 0.8rem;
    min-width: 130px;
    border-radius: 7px;
    box-sizing: border-box;
    line-height: normal;
}
.filters input[type="search"] {
    -webkit-appearance: none;
    appearance: none;
    background-image: none;
    min-width: 200px;
}
.filters button[type="submit"] {
    margin: 0;
    padding: 0.4rem 1rem;
    font-size: 0.78rem;
    font-weight: 500;
    --pico-background-color: var(--vm-dark);
    --pico-border-color: var(--vm-dark);
    width: auto;
}
.filters a[role="button"] {
    margin: 0;
    padding: 0.4rem 0.9rem;
    font-size: 0.78rem;
}

/* ---------- Paginación ---------- */
.pagination {
    display: flex;
    gap: 0.3rem;
    justify-content: center;
    align-items: center;
    list-style: none;
    padding-left: 0;
    margin-left: 0;
    margin-top: 1.75rem;
    flex-wrap: wrap;
}
.pagination li { margin: 0; padding: 0; list-style: none; }
.pagination li::marker { content: ""; }
.pagination li a,
.pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border-radius: 7px;
    text-decoration: none;
    font-size: 0.78rem;
    font-variant-numeric: normal;
    border: 1px solid var(--border-2);
    color: var(--text);
    background: var(--surface);
    box-sizing: border-box;
}
.pagination li a:hover { border-color: var(--vm-teal); }
.pagination li.active span {
    background: var(--vm-dark);
    color: #fff;
    border-color: var(--vm-dark);
}
.pagination li .gap {
    border: none;
    background: none;
    color: var(--text-soft);
    min-width: auto;
    padding: 0 0.15rem;
}

/* ---------- UTM details ---------- */
.utm-details { font-size: 0.7rem; color: var(--text-soft); max-width: 220px; }
.utm-details dt { font-weight: 600; display: inline; }
.utm-details dd { display: inline; margin: 0; }
.utm-details dd::after { content: ''; display: block; }
/* ---------- Acciones de fila ---------- */
.actions { display: inline-flex; gap: 0.4rem; align-items: center; }
.actions form { margin: 0; }
.btn-details, .btn-delete {
    margin: 0;
    width: auto;
    padding: 0.28rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.3;
}
.btn-details {
    background: var(--vm-dark);
    border: 1px solid var(--vm-dark);
    color: #fff;
}
.btn-details:hover { background: #000; border-color: #000; }
.btn-delete {
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--c-bad) 35%, #fff);
    color: var(--c-bad);
}
.btn-delete:hover { background: color-mix(in srgb, var(--c-bad) 8%, #fff); border-color: var(--c-bad); }

/* ---------- Fila de detalle desplegable ---------- */
.lead-row.is-expanded > td { border-bottom: none; background: #fafbfc; }
.detail-row > td {
    background: #fafbfc;
    padding: 0.9rem 1.1rem 1.1rem;
    border-bottom: 1px solid var(--border-2);
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.9rem 1.5rem;
}
.detail-item { font-size: 0.82rem; }
.detail-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-soft);
    margin-bottom: 0.2rem;
}
.detail-message { grid-column: 1 / -1; line-height: 1.45; }
.detail-utms { grid-column: 1 / -1; }
.detail-utms .utm-details { max-width: none; font-size: 0.78rem; }
.detail-utms .utm-details dt { margin-right: 0.25rem; }
.detail-utms .utm-details dd::after { content: ''; display: block; margin-bottom: 0.15rem; }

/* ---------- Message preview ---------- */
.message-preview {
    display: block;
    max-width: 220px;
    font-size: 0.75rem;
    line-height: 1.35;
    word-break: break-word;
    white-space: normal;
    color: var(--text-soft);
}

/* ---------- Import results ---------- */
.import-results { padding: 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.85rem; }
.import-results.success { background: #ecfdf3; border: 1px solid #bbf7d0; }
.import-results.warning { background: #fffbeb; border: 1px solid #fde68a; }

/* ---------- Forms (alta) ---------- */
form label { font-size: 0.85rem; }
input, select, textarea { font-size: 0.85rem; }

/* ============================================================
   Analítica
   ============================================================ */
.range-tabs {
    display: inline-flex;
    gap: 0.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem;
}
.range-tab {
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-soft);
}
.range-tab:hover { color: var(--text); }
.range-tab.active { background: var(--vm-dark); color: #fff; }

.analytics-table { font-size: 0.8rem; margin: 0; }
.analytics-table td, .analytics-table th { padding: 0.5rem 0.65rem; }

.conv-bar {
    position: relative;
    display: inline-block;
    min-width: 96px;
    height: 16px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    vertical-align: middle;
}
.conv-bar::before {
    content: "";
    position: absolute;
    inset: 0;
    width: var(--pct);
    background: var(--vm-teal);
    border-radius: 999px;
}
.conv-bar span {
    position: relative;
    display: block;
    text-align: center;
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 16px;
    color: var(--vm-dark);
}

/* Bar chart mensual */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 190px;
    padding-top: 1rem;
    overflow-x: auto;
}
.bar-col {
    flex: 1 0 34px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}
.bar-track {
    position: relative;
    width: 60%;
    max-width: 26px;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.bar { position: absolute; bottom: 0; width: 100%; border-radius: 4px 4px 0 0; transition: height .3s ease; }
.bar-total  { background: color-mix(in srgb, var(--vm-teal) 55%, #fff); }
.bar-closed { background: var(--vm-teal-d); width: 55%; }
.bar-val { font-size: 0.66rem; font-weight: 600; color: var(--vm-dark); margin-top: 0.25rem; }
.bar-lbl { font-size: 0.6rem; color: var(--text-soft); margin-top: 0.1rem; text-transform: capitalize; }

.chart-legend { font-size: 0.74rem; color: var(--text-soft); margin-top: 1rem; display: flex; gap: 1.25rem; align-items: center; }
.chart-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 0.35rem; vertical-align: middle; }
.dot-total  { background: color-mix(in srgb, var(--vm-teal) 55%, #fff); }
.dot-closed { background: var(--vm-teal-d); }

/* ---------- Footer ---------- */
footer.container { color: var(--text-soft); padding-bottom: 2rem; font-size: 0.78rem; }

/* ============================================================
   Login
   ============================================================ */
.login-page {
    min-height: 100vh;
    margin: 0;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-wrap {
    width: 100%;
    max-width: 380px;
    margin: 0;
    padding: 0;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2rem 1.9rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.06);
    margin: 0;
}
.login-head { margin-bottom: 1.5rem; text-align: center; }
.login-brand {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--vm-dark);
    letter-spacing: -0.01em;
}
.login-brand::before {
    content: "";
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--vm-teal);
    margin-right: 0.5rem;
    vertical-align: middle;
}
.login-head small { color: var(--text-soft); font-size: 0.82rem; }
.login-error {
    background: color-mix(in srgb, var(--c-bad) 8%, #fff);
    border: 1px solid color-mix(in srgb, var(--c-bad) 25%, #fff);
    color: var(--c-bad);
    font-size: 0.82rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
}
.login-card form { margin: 0; }
.login-card button[type="submit"] { width: 100%; margin-top: 0.5rem; }
