/* CICB Lead Console — basado en el diseño de Stitch (DESIGN.md): DM Sans, azul marino + turquesa */
:root {
    --primary: #004161;
    --primary-hover: #011954;
    --sidebar: #002a41;
    --navy: #011954;
    --teal: #14B8D1;
    --teal-soft: #5ce3fd;
    --teal-ink: #006371;
    --canvas: #F4F7FA;
    --surface: #fff;
    --subtle: #ECF4FA;
    --line: #D9E2EC;
    --line-strong: #CCD7E2;
    --ink: #081e2a;
    --ink-soft: #41474d;
    --neutral: #5A6E7D;
    --error: #ba1a1a;
    --wa: #25D366;
    --r: 4px;
    --r-lg: 8px;
    --sidebar-w: 256px;
    --topbar-h: 56px;
}
* { box-sizing: border-box; }
html { height: 100%; }
body {
    margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink);
    font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 14px; line-height: 20px;
    font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 32px; letter-spacing: -.015em; font-weight: 600; margin: 0; }
h2 { font-size: 16px; line-height: 24px; font-weight: 600; margin: 0; }
.muted { color: var(--neutral); }
.small { font-size: 12px; line-height: 16px; }
.strong { font-weight: 600; }
.ms {
    font-family: 'Material Symbols Outlined'; font-weight: 400; font-style: normal; font-size: 20px; line-height: 1;
    display: inline-block; vertical-align: middle; letter-spacing: normal; text-transform: none; white-space: nowrap;
    font-feature-settings: 'liga'; -webkit-font-feature-settings: 'liga'; font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}
.ms.sm { font-size: 16px; } .ms.xs { font-size: 14px; } .ms.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20; }

/* ---------- barra lateral ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar); color: #cae6ff;
    padding: 16px; display: flex; flex-direction: column; justify-content: space-between; z-index: 40; overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 8px 8px 16px; margin-bottom: 16px; border-bottom: 1px solid rgba(0, 65, 97, .9); }
.side-logo { width: 40px; height: 40px; border-radius: 8px; background: #fff; color: var(--teal); display: grid; place-items: center; flex: none; }
.side-title { color: #fff; font-size: 20px; line-height: 24px; font-weight: 700; letter-spacing: -.01em; display: block; }
.side-sub { font-size: 12px; color: #9cccf2; }
.btn-cta {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-bottom: 20px; padding: 8px 12px;
    background: var(--teal-soft); color: var(--teal-ink); border-radius: 8px; font-weight: 600; font-size: 13px;
}
.btn-cta:hover { background: #a4eeff; text-decoration: none; }
.side-nav { display: grid; gap: 4px; }
.side-nav a, .side-foot a, .side-foot button.navlink {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: #9cccf2; font-weight: 600; font-size: 13px;
    background: none; border: 0; width: 100%; font-family: inherit; cursor: pointer; text-align: left;
}
.side-nav a:hover, .side-foot a:hover, .side-foot button.navlink:hover { background: rgba(0, 65, 97, .55); color: #fff; text-decoration: none; }
.side-nav a.on { background: var(--primary); color: #fff; }
.side-nav .badge-n { margin-left: auto; background: var(--error); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.side-foot { border-top: 1px solid rgba(0, 65, 97, .9); padding-top: 12px; margin-top: 16px; display: grid; gap: 4px; }
.side-foot a, .side-foot button.navlink { font-weight: 400; padding: 8px 12px; font-size: 12px; }
.conn { margin-top: 10px; padding: 10px; background: rgba(0, 65, 97, .45); border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.conn .dot { width: 10px; height: 10px; border-radius: 50%; background: #34d399; flex: none; }
.conn.off .dot { background: #94a3b8; }
.conn b { display: block; color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.conn span { font-size: 10px; color: #9cccf2; }
.by { margin-top: 10px; font-size: 10px; color: #7eadd2; text-align: center; }

/* ---------- estructura ---------- */
.shell { padding-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--line-strong);
    display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 24px;
}
.top-left, .top-right { display: flex; align-items: center; gap: 12px; }
.sync { display: flex; align-items: center; gap: 6px; color: #006877; background: #eaf5ff; border: 1px solid rgba(0, 104, 119, .2); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.sync.off { color: var(--neutral); background: var(--subtle); border-color: var(--line); }
.search { position: relative; }
.search .ms { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #72787e; font-size: 18px; }
.search input { padding-left: 34px; width: 100%; }
.top-search { width: 260px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid var(--line-strong); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(0, 65, 97, .1); color: var(--primary); font-weight: 700; font-size: 13px; display: grid; place-items: center; flex: none; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; border-radius: 8px; background: var(--navy); color: #fff; }
.user-chip .who { line-height: 16px; } .user-chip .who b { display: block; font-size: 13px; } .user-chip .who span { font-size: 11px; color: #72787e; }
.content { padding: 24px; }
.page-leads .content { padding: 0; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------- controles ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-strong);
    background: #fff; color: var(--primary); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--canvas); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: #1fb457; }
.btn-danger { color: var(--error); border-color: #f0c4c1; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn.icon { padding: 0 8px; }
input, select, textarea {
    font: inherit; font-size: 13px; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; color: var(--ink); max-width: 100%;
}
.f-sm input, .f-sm select, select.sm, input.sm { height: 32px; font-size: 12px; }
input.sm { width: 11rem; }
textarea { height: auto; padding: 8px 10px; width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 0; border-color: var(--teal); }
input[type=checkbox] { width: 14px; height: 14px; padding: 0; accent-color: var(--primary); }
label { display: block; font-weight: 500; font-size: 13px; }
label > input, label > select { display: block; margin-top: 4px; width: 100%; }
.flash { padding: 10px 14px; border-radius: var(--r-lg); margin: 12px 24px 0; font-weight: 500; }
.page-leads .flash { margin: 12px 24px 0; }
.content .flash { margin: 0 0 16px; }
.flash-ok { background: #E8F8EE; color: #0B6623; } .flash-error { background: #ffdad6; color: #93000a; } .flash-info { background: var(--subtle); color: var(--primary); }
.inline { display: inline; margin: 0; }

/* ---------- indicadores ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid rgba(193, 199, 206, .6); }
.kpi { padding: 12px; border: 1px solid rgba(193, 199, 206, .7); border-radius: var(--r-lg); background: #f6faff; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi .lbl { font-size: 11px; line-height: 14px; letter-spacing: .04em; font-weight: 600; text-transform: uppercase; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 24px; line-height: 32px; font-weight: 700; color: var(--primary); }
.kpi .row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.kpi .pill { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: #E8F8EE; color: #0B6623; }
.kpi .ico { width: 36px; height: 36px; border-radius: var(--r-lg); background: #eaf5ff; color: var(--primary); display: grid; place-items: center; flex: none; }
.kpi.alert { background: rgba(255, 244, 229, .5); border-color: #fcd34d; }
.kpi.alert .lbl { color: #8F4B00; } .kpi.alert .val { color: #78350f; }
.kpi.alert .pill { background: #fef3c7; color: #92400e; } .kpi.alert .ico { background: #fef3c7; color: #92400e; }
.kpi.cyan .pill { background: #E1F8FB; color: #0B6D7A; } .kpi.cyan .ico { background: #E1F8FB; color: #0B6D7A; }
.kpi.green .val { color: #065f46; } .kpi.green .ico { background: #E8F8EE; color: #0B6623; }
.ping { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; animation: ping 1.6s ease-in-out infinite; }
@keyframes ping { 50% { opacity: .35; } }

/* ---------- pestañas y filtros ---------- */
.filterbar { background: var(--surface); border-bottom: 1px solid rgba(204, 215, 226, .8); padding: 10px 24px; display: grid; gap: 10px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid rgba(193, 199, 206, .4); }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; white-space: nowrap; color: var(--ink-soft); font-weight: 600; font-size: 13px; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--primary); text-decoration: none; }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab .n { font-size: 11px; padding: 0 7px; border-radius: 999px; background: var(--subtle); color: var(--ink-soft); font-weight: 600; }
.tab.on .n { color: var(--primary); font-weight: 700; }
.tab .n.st-nuevo { background: #fef3c7; color: #92400e; } /* "Nuevo" destaca en ámbar, como en el diseño */
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; }
.filters .grp { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters input, .filters select { height: 32px; font-size: 12px; background: var(--canvas); }
.filters .search { width: 250px; }
.field-inline { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--neutral); font-weight: 500; }
.field-inline input { margin: 0; width: auto; }
.batch { display: flex; align-items: center; gap: 8px; }
.batch .sel { padding: 4px 10px; background: var(--subtle); border: 1px solid var(--line-strong); border-radius: var(--r); font-size: 12px; }
.batch .sel b { color: var(--primary); }

/* ---------- tabla + panel ---------- */
.split { display: flex; align-items: flex-start; }
.listpane { flex: 1; min-width: 0; background: var(--surface); border-right: 1px solid rgba(204, 215, 226, .8); }
.tablewrap { overflow-x: visible; }
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table thead th {
    position: sticky; top: var(--topbar-h); z-index: 5; height: 36px; padding: 0 12px; background: var(--subtle); border-bottom: 1px solid var(--line-strong);
    font-size: 11px; letter-spacing: .04em; text-transform: uppercase; font-weight: 700; color: var(--neutral); white-space: nowrap;
}
.table td { padding: 8px 12px; border-bottom: 1px solid rgba(193, 199, 206, .6); vertical-align: middle; font-size: 12px; }
.table tbody tr { height: 54px; cursor: pointer; border-left: 4px solid transparent; }
.table tbody tr:hover { background: var(--canvas); }
.table tbody tr.on { background: rgba(234, 245, 255, .7); box-shadow: inset 4px 0 0 var(--teal); }
.table .c-chk { width: 40px; text-align: center; padding: 0 8px; }
.who-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.who-cell .nm { font-size: 13px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 6px; }
.who-cell .ct { color: #72787e; font-size: 12px; }
.src { position: absolute; right: -4px; bottom: -4px; width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.src .ms { font-size: 10px; }
.src.ig { background: linear-gradient(45deg, #9333ea, #ec4899); } .src.fb { background: #1877f2; } .src.manual { background: #5A6E7D; }
.avwrap { position: relative; flex: none; }
.study { display: inline-block; background: #E1F8FB; color: #0B6D7A; font-weight: 600; font-size: 12px; padding: 1px 8px; border-radius: 4px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.ra { width: 28px; height: 28px; border: 1px solid var(--line-strong); border-radius: var(--r); display: grid; place-items: center; background: #fff; color: var(--primary); }
.ra.wa { color: #fff; background: var(--wa); border-color: var(--wa); }
.ra:hover { text-decoration: none; filter: brightness(.95); }
.tag-test { background: #ffe0e0; color: #a00; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; }
.tag-new { background: #fef3c7; color: #78350f; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--neutral); font-size: 12px; }
.empty { padding: 48px 24px; text-align: center; color: var(--neutral); }

/* estados (badges) */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 9999px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; font-weight: 600; white-space: nowrap; background: #EAEFF3; color: #4F5D6B; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-nuevo { background: #ECF4FA; color: #004161; }
.st-contactado { background: #E1F8FB; color: #0B6D7A; }
.st-prefiltro_ok { background: #E8F8EE; color: #0B6623; }
.st-derivado { background: #dce1ff; color: #0d225c; }
.st-no_califica { background: #EAEFF3; color: #4F5D6B; }

/* ---------- panel de detalle ---------- */
.drawer {
    width: 460px; flex: none; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; background: var(--surface);
    box-shadow: 0 8px 24px -4px rgba(1, 25, 84, .08), -1px 0 0 0 var(--line); display: flex; flex-direction: column;
}
.scrim { display: none; }
.dr-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: #fbfdff; }
.dr-head h2 { font-size: 18px; line-height: 24px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dr-head .meta { color: var(--neutral); font-size: 12px; }
.dr-head .x { margin-left: auto; color: var(--neutral); }
.dr-sec { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.cap { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; font-weight: 600; color: var(--neutral); margin-bottom: 6px; display: block; }
.statusrow { display: flex; gap: 8px; }
.statusrow select { flex: 1; height: 38px; font-weight: 600; }
.box { border: 1px solid var(--line); border-radius: var(--r-lg); background: #fbfdff; }
.box .bh { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--canvas); }
.verified { color: #006877; font-size: 11px; letter-spacing: .04em; font-weight: 700; display: flex; align-items: center; gap: 4px; text-transform: uppercase; }
.src-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; padding: 12px 14px; font-size: 12px; }
.src-grid dt { color: var(--neutral); } .src-grid dd { margin: 0; font-weight: 700; color: var(--ink); word-break: break-word; }
.dr-tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.dr-tabs .tab { padding: 10px 10px; }
.kvlist { display: grid; }
.kvlist .kvr { display: flex; justify-content: space-between; gap: 16px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.kvlist .kvr:last-child { border-bottom: 0; }
.kvlist .k { color: var(--neutral); } .kvlist .v { font-weight: 600; text-align: right; word-break: break-word; display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.copy { background: none; border: 0; padding: 2px; color: var(--neutral); cursor: pointer; line-height: 1; }
.copy:hover { color: var(--primary); }
.note { border-left: 3px solid var(--teal); background: #f6fbfd; padding: 8px 12px; border-radius: 0 var(--r) var(--r) 0; margin-top: 10px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { padding-left: 14px; border-left: 2px solid var(--line); font-size: 13px; }
.dr-foot { margin-top: auto; padding: 10px 20px; border-top: 1px solid var(--line); background: var(--canvas); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--neutral); position: sticky; bottom: 0; }
.dr-foot .lock { display: flex; align-items: center; gap: 6px; }
.link-danger { color: var(--error); font-weight: 600; background: none; border: 0; cursor: pointer; font: inherit; font-weight: 600; display: flex; align-items: center; gap: 4px; }

/* ---------- tarjetas de páginas simples ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; margin-bottom: 16px; }
.card h2 { margin-bottom: 12px; }
.narrow { max-width: 440px; }
.stack { display: grid; gap: 12px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.form-row label { flex: 1 1 11rem; }
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.table-card .table thead th { position: static; }
.table-card .tablewrap { overflow-x: auto; }
.table-card .table tbody tr { cursor: default; height: 48px; }
.table-card .table tbody tr:hover { background: transparent; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--sidebar); background: linear-gradient(160deg, #002a41 0%, #011954 100%); }
.login-card { background: #fff; border-radius: 12px; padding: 32px; width: 100%; max-width: 400px; box-shadow: 0 24px 48px -12px rgba(0, 0, 0, .35); }

.login-card h1 { font-size: 22px; }
.login-card form { display: grid; gap: 14px; margin-top: 20px; }
.login-card .flash { margin: 12px 0 0; }
.login-by { margin-top: 20px; text-align: center; font-size: 11px; color: var(--neutral); }

/* ---------- pantallas medianas y chicas ---------- */
@media (max-width: 1699px) {
    .has-drawer .col-x { display: none; }
}
@media (max-width: 1279px) {
    .table thead th { position: static; }
    .tablewrap { overflow-x: auto; }
    .drawer { position: fixed; top: 0; right: 0; height: 100vh; z-index: 60; width: min(480px, 100%); }
    .scrim { display: block; position: fixed; inset: 0; background: rgba(1, 25, 84, .35); z-index: 55; }
}
@media (max-width: 1023px) {
    .sidebar { position: static; width: auto; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 8px; }
    .side-brand { border: 0; margin: 0; padding: 0; } .side-sub { display: none; }
    .btn-cta { width: auto; margin: 0; }
    .sidebar > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
    .side-nav a, .side-foot a, .side-foot button.navlink { width: auto; padding: 8px 10px; }
    .side-nav { display: flex; flex-wrap: wrap; } .side-foot { display: flex; flex-wrap: wrap; border: 0; margin: 0; padding: 0; }
    .conn, .by { display: none; }
    .shell { padding-left: 0; }
    .topbar { padding: 0 12px; } .top-search, .sync { display: none; }
    .kpis { grid-template-columns: repeat(2, 1fr); padding: 12px; }
    .filterbar { padding: 10px 12px; } .content { padding: 12px; }
    .table thead th { position: static; }
    .tablewrap { overflow-x: auto; }
    .col-x { display: none; }
}
@media (max-width: 640px) {
    .kpis { grid-template-columns: 1fr; }
    .filters .search { width: 100%; }
}

/* utilidades (la política de seguridad no permite estilos en línea) */
[hidden] { display: none !important; }
.m-top { margin: 4px 0 0; } .mt-12 { margin-top: 12px; } .ta-r { text-align: right; }
.btn-lg { height: 40px; }
.row-form { display: flex; flex: 1; gap: 8px; }
.cap.nomargin { margin: 0; }
.pad-box { padding: 12px 14px; margin: 0; }

/* logo CICB */
.side-logo img { width: 28px; height: auto; display: block; }
.login-card .login-logo { width: 64px; height: auto; display: block; margin-bottom: 16px; }

.wa-ico { width: 18px; height: 18px; fill: currentColor; display: block; }

/* casilla "Recordarme" */
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink-soft); cursor: pointer; }
label.check input { width: 16px; height: 16px; margin: 0; flex: none; }

/* Ver contraseña (login) */
.pw-wrap { position: relative; display: block; margin-top: 4px; }
.pw-wrap input { display: block; width: 100%; margin-top: 0; padding-right: 42px; }
.pw-toggle { position: absolute; top: 0; right: 0; height: 100%; width: 40px; display: grid; place-items: center; background: none; border: 0; color: var(--neutral); cursor: pointer; border-radius: 0 6px 6px 0; }
.pw-toggle:hover { color: var(--primary); }
.pw-toggle:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }

/* Link "olvidé mi contraseña" */
.login-link { margin-top: 16px; text-align: center; font-size: 13px; }
.login-link a { color: var(--primary); font-weight: 500; }

/* Editar usuario */
.form-actions { display: flex; gap: 8px; align-items: center; }
