:root {
  --azul: #0b4ea2; --azul-osc: #083a7a; --fondo: #a9cdf2; --borde: #c9d8ea;
  --verde: #34a853; --rojo: #e53935; --gris: #9e9e9e; --texto: #1a1a1a;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', Arial, sans-serif; background: var(--fondo); color: var(--texto); }
.oculto { display: none !important; }
.muted { color: #555; font-size: .9em; }
.error { color: var(--rojo); font-weight: 600; }
.espacio { flex: 1; }
h1 { color: var(--azul); }
h2, h3 { color: var(--azul-osc); margin: .3em 0; }
h4 { margin: .4em 0; }
label { display: block; font-size: .85em; font-weight: 600; margin: .3em 0; }
label.chk { display: inline-flex; align-items: center; gap: .35em; font-weight: 400; }
input, select, textarea { width: 100%; padding: .45em; border: 1px solid #9db8d6; border-radius: 6px; font: inherit; background: #fff; }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { resize: vertical; }
.btn { border: 1px solid var(--azul); background: #fff; color: var(--azul); border-radius: 8px; padding: .45em .9em; cursor: pointer; font-weight: 600; }
.btn:hover { background: #e8f1fc; }
.btn-azul { background: var(--azul); color: #fff; }
.btn-azul:hover { background: var(--azul-osc); }
.btn-verde { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn-rojo { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn-claro { background: transparent; border-color: #fff; color: #fff; }
.btn-mini { padding: .2em .7em; font-size: .85em; border-radius: 14px; }
.tarjeta { background: #fff; border-radius: 14px; padding: 14px 16px; margin: 12px; box-shadow: 0 1px 4px rgba(8,58,122,.18); }
.fila-flex { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: .4em 0; }
.fila-flex > label { flex: 1; min-width: 130px; }

/* Acceso */
.acceso { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.acceso-caja { width: min(420px, 92vw); }
.acceso-caja .btn { width: 100%; margin-top: .6em; }

/* Barra superior */
.barra { background: var(--azul); color: #fff; display: flex; gap: 12px; align-items: center; padding: 8px 14px; flex-wrap: wrap; position: sticky; top: 0; z-index: 50; }
.buscador { position: relative; flex: 1; min-width: 220px; }
.buscador input { border-radius: 18px; padding-left: 16px; }
.sugerencias { position: absolute; top: 105%; left: 0; right: 0; background: #fff; color: var(--texto); border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.25); overflow: hidden; z-index: 60; }
.sugerencias div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #eee; }
.sugerencias div:hover, .sugerencias div.activa { background: #e8f1fc; }
.sugerencias .s-nombre { font-weight: 700; }
.sugerencias .s-det { font-size: .82em; color: #555; }
.usuario-box { display: flex; gap: 8px; align-items: center; }
.rol { font-weight: 700; text-transform: uppercase; font-size: .85em; }
.switch { color: #fff; display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.franja { background: #ffecb3; color: #6d4c00; text-align: center; font-weight: 700; padding: 6px; position: sticky; top: 52px; z-index: 40; }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 8px 12px 0; flex-wrap: wrap; }
.tab { border: none; background: rgba(255,255,255,.55); padding: .55em 1em; border-radius: 10px 10px 0 0; cursor: pointer; font-weight: 600; color: var(--azul-osc); }
.tab.activa { background: #fff; }

/* Tablas */
.tabla-wrap { overflow-x: auto; }
.tabla { border-collapse: collapse; width: 100%; font-size: .88em; }
.tabla th { background: var(--azul); color: #fff; text-align: left; padding: 6px 8px; white-space: nowrap; }
.tabla td { border-bottom: 1px solid var(--borde); padding: 6px 8px; white-space: nowrap; }
.tabla tr:hover td { background: #f2f7fd; }
.tabla tr.click { cursor: pointer; }
.cards { display: none; }
.cards .card { border: 1px solid var(--borde); border-radius: 10px; padding: 10px; margin: 8px 0; cursor: pointer; }
.cards .card b { color: var(--azul-osc); }

/* Ficha */
.ficha-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.ficha-grid .tarjeta { margin: 6px; }
.ficha-grid-abajo { display: grid; grid-template-columns: 1fr 260px; gap: 0; }
.ficha-grid-abajo .tarjeta { margin: 6px; }
.campos { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
.campos .campo { border-bottom: 1px dotted #b9c9de; padding: 3px 0; }
.campos .campo .campo-et { display: block; font-size: .72em; font-weight: 700; color: #444; text-transform: uppercase; }
.campos .campo .campo-val { display: block; font-size: .95em; min-height: 1.1em; overflow-wrap: break-word; }
.campos-94 { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.dir-box { margin-top: 8px; border-top: 1px solid var(--borde); padding-top: 6px; }
.insignia { background: var(--gris); color: #fff; font-weight: 700; padding: .35em 1.2em; border-radius: 6px; }
.insignia.con { background: var(--verde); }
.insignia.atraso { background: #ef6c00; }
.subform { border: 1px solid var(--borde); border-radius: 10px; padding: 10px; margin-top: 8px; background: #f7fbff; }
.botones-gestion .btn { min-width: 110px; }
.tiempos div { display: flex; justify-content: space-between; border-bottom: 1px dotted #b9c9de; padding: 3px 0; }
.convenio { border: 1px solid var(--borde); border-radius: 10px; padding: 10px; margin: 8px 0; }
.convenio .resumen { display: flex; gap: 16px; flex-wrap: wrap; }
.estado-activa { color: var(--verde); font-weight: 700; }
.estado-cumplida { color: var(--azul); font-weight: 700; }
.estado-cancelada { color: var(--rojo); font-weight: 700; }
.pago-incumplido { color: var(--rojo); font-weight: 700; }
.pago-pagado { color: var(--verde); }

/* Mapa */
.mapa { height: 420px; border-radius: 10px; margin-top: 8px; background: #dfeefc; }
.leyenda { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0; font-size: .9em; }
.leyenda .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.mapa-lista { max-height: 320px; overflow-y: auto; margin-top: 8px; }
.mapa-lista .item { border-bottom: 1px solid var(--borde); padding: 6px 0; font-size: .92em; }
.pin-div { border-radius: 50%; color: #fff; font-weight: 700; text-align: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }

.estados-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 12px; margin: 6px 0; }
.usuario-item { border: 1px solid var(--borde); border-radius: 10px; padding: 10px; margin: 8px 0; }

@media (max-width: 900px) {
  .ficha-grid, .ficha-grid-abajo { grid-template-columns: 1fr; }
  #cartera-tabla-wrap { display: none; }
  .cards { display: block; }
  .campos { grid-template-columns: 1fr 1fr; }
}
select option { background: #fff; color: var(--texto); }
select option:checked { background: var(--azul); color: #fff; }

/* ===== v2.0.0: menú único, semana, tablas dinámicas ===== */
.btn-menu { font-weight: 700; }
.semana-badge { background: #f59e0b; color: #1f2937; font-weight: 700; border-radius: 999px; padding: 4px 12px; font-size: 13px; white-space: nowrap; }
.rol { background: #e0e7ff; color: #3730a3; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.menu-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 900; }
.menu-panel { position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 85vw; background: #fff; z-index: 901; box-shadow: 2px 0 16px rgba(0,0,0,.25); overflow-y: auto; padding: 12px; }
.menu-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.menu-grupo { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #64748b; margin: 14px 4px 6px; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: none; border-radius: 8px; padding: 9px 10px; font-size: 15px; cursor: pointer; color: #0f172a; }
.menu-item:hover { background: #eef2ff; }
.menu-count { color: #b45309; font-weight: 700; font-size: 13px; }
.limpia-box { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 28px; text-align: center; margin-top: 12px; }
.insignia-nueva { background: #16a34a; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.insignia-revision { background: #dc2626; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.movimiento { background: #fef3c7; border: 1px solid #f59e0b; border-radius: 8px; padding: 8px 10px; margin-top: 10px; font-size: 14px; }
.cronometro-box { display: inline-flex; gap: 8px; align-items: center; }
.cronometro-box strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.barra-avance { display: inline-block; width: 90px; height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; vertical-align: middle; }
.barra-relleno { display: block; height: 100%; background: #2563eb; }
.num-verde { color: #15803d; font-weight: 700; }
.num-rojo { color: #dc2626; }
th.ordenable { cursor: pointer; user-select: none; }
th.ordenable:hover { background: #e0e7ff; }
.flecha-ord { color: #2563eb; font-size: 11px; }
tr.fila-totales td { background: #eef2ff; font-weight: 700; border-top: 2px solid #6366f1; }
tr.fila-singestor td { background: #fffbeb; }
.calif { background: #2563eb; color: #fff; font-weight: 800; border-radius: 8px; padding: 2px 10px; font-size: 16px; }
.candado { background: #fef3c7; border: 1px solid #f59e0b; color: #92400e; border-radius: 8px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.comp-fila { display: grid; grid-template-columns: 190px 1fr 36px; gap: 8px; align-items: center; font-size: 13px; margin: 2px 0; }
.comp-fila .barra-avance { width: 100%; }
.switch { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 700; color: #b45309; }
/* La tabla de 36 columnas se muestra también en celular, con desplazamiento horizontal */
@media (max-width: 900px) {
  #cartera-tabla-wrap { display: block !important; overflow-x: auto; }
  .cards { display: none !important; }
  .barra { flex-wrap: wrap; }
  .comp-fila { grid-template-columns: 130px 1fr 32px; }
}

/* ===== v3.0.0: árbol, asistencia, agenda, inactividad, fotos ===== */
.chip-inactividad { background: #fef3c7; color: #92400e; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.franja-agenda { background: #fee2e2; color: #991b1b; cursor: pointer; }
.arbol-paso { margin: 6px 0; }
.arbol-paso label { margin-bottom: 2px; }
.arbol-hoja { background: #ecfdf5; border: 1px solid #16a34a; border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.arbol-hoja .hoja-estatus { font-weight: 800; color: #166534; }
.objecion-panel { background: #fffbeb; border: 1px solid #f59e0b; border-radius: 8px; padding: 10px; margin-top: 8px; }
.objecion-panel .respuesta { font-size: 15px; line-height: 1.45; }
.foto-preview { max-width: 180px; max-height: 180px; border-radius: 8px; border: 1px solid var(--borde); }
.insignia-estado.pendiente_validacion { background: #d97706; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.validacion-box { background: #fffbeb; border: 1px dashed #d97706; border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.bloqueo-box { background: #fee2e2; border: 1px solid #dc2626; border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.agenda-item { border: 1px solid var(--borde); border-radius: 10px; padding: 10px; margin: 8px 0; }
.agenda-item.vencido { border-color: #dc2626; background: #fef2f2; }
.dom-form { border-top: 1px dashed var(--borde); margin-top: 6px; padding-top: 6px; }
