/* ============================================================
   Correprop Gestor — estilo clásico inspirado en archlinux.org
   Barra superior oscura con menús, acento azul #1793d1,
   contenido sobrio sobre fondo con patrón de viviendas.
   ============================================================ */
:root {
    /* Ancho de la barra, el título, el contenido y el pie. Los cuatro leen esta
       misma variable para que queden alineados entre sí en todas las páginas.
       Es el ancho que antes tenía solo el listado de propiedades. */
    --ancho: 1680px;
    --bg: #f4f5f7;
    --card: #ffffff;
    --ink: #222c38;
    --muted: #6b7480;
    --line: #d9dde3;
    --brand: #1793d1;      /* azul Arch */
    --brand-d: #0f77ab;
    --bar: #333333;        /* barra superior */
    --bar-ink: #dddddd;
    --ok: #16a34a;
    --warn: #d97706;
    --danger: #dc2626;
    --radius: 4px;
    --shadow: 0 1px 2px rgba(0,0,0,.07);
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg) url('pattern.svg') repeat;
    font-size: 14px;
    display: flex; flex-direction: column;
}
a { color: var(--brand-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; font-weight: 600; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 600; }
.muted { color: var(--muted); }
.mt { margin-top: 1rem; }

/* ------------------------------------------------------------
   Logo: "correprop" grande con "Gestor" al costado inferior derecho
   ------------------------------------------------------------ */
.logo {
    position: relative; display: inline-block;
    font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em;
    color: #fff; text-decoration: none; line-height: 1;
    padding-right: 2.9rem; padding-bottom: .5rem;
}
.logo:hover { text-decoration: none; }
.logo .logo-sub {
    position: absolute; right: 0; bottom: 0;
    font-size: .72rem; font-weight: 600; letter-spacing: .02em;
    color: var(--brand); font-style: italic;
}
.logo.logo-dark { color: var(--ink); }

/* ------------------------------------------------------------
   Barra superior clásica (archbar) con menús desplegables
   ------------------------------------------------------------ */
.archbar { background: var(--bar); box-shadow: 0 2px 4px rgba(0,0,0,.25); position: sticky; top: 0; z-index: 50; }
.archbar-inner {
    max-width: var(--ancho); margin: 0 auto; padding: 0 1rem;
    display: flex; align-items: center; gap: 1.25rem; min-height: 52px;
}
.mainnav { display: flex; align-items: stretch; flex: 1; }
.mainnav > .nav-item { position: relative; display: flex; }
.mainnav a.nav-link {
    color: var(--bar-ink); font-weight: 600; font-size: .88rem;
    padding: 1rem .8rem; display: flex; align-items: center; gap: .3rem;
}
.mainnav a.nav-link { white-space: nowrap; }
/* Con nueve entradas en el menú, en pantallas medianas se aprieta un poco
   antes que partir los nombres en dos líneas. */
@media (max-width: 1440px) {
    .archbar-inner { gap: .8rem; }
    .mainnav a.nav-link { padding: 1rem .55rem; font-size: .84rem; }
    .user-box { font-size: .78rem; gap: .5rem; }
}
.user-box > span { white-space: nowrap; }
.mainnav a.nav-link:hover { color: #fff; text-decoration: none; background: #404040; }
.mainnav a.nav-link.active { color: #fff; box-shadow: inset 0 -3px 0 var(--brand); }
.caret { font-size: .6rem; opacity: .7; }

.dropdown {
    display: none; position: absolute; top: 100%; left: 0; min-width: 210px;
    background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--brand);
    box-shadow: 0 6px 16px rgba(0,0,0,.18); padding: .35rem 0; z-index: 60;
}
.nav-item:hover .dropdown, .nav-item.open .dropdown { display: block; }
.dropdown a { display: block; padding: .55rem .95rem; color: var(--ink); font-size: .86rem; }
.dropdown a:hover { background: #eef6fb; color: var(--brand-d); text-decoration: none; }
.dropdown .sep { border-top: 1px solid var(--line); margin: .35rem 0; }

.user-box { display: flex; align-items: center; gap: .7rem; color: var(--bar-ink); font-size: .82rem; }
.user-box .user-rol { color: var(--brand); font-weight: 600; }
.user-box a { color: var(--bar-ink); }
.user-box a:hover { color: #fff; }

/* Encabezado de página (título bajo la barra) */
.pagehead { background: rgba(255,255,255,.85); border-bottom: 1px solid var(--line); }
.pagehead-inner {
    max-width: var(--ancho); margin: 0 auto; padding: .8rem 1rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.pagehead h1 { color: var(--brand-d); }

/* Contenido */
.content { max-width: var(--ancho); width: 100%; margin: 0 auto; padding: 1.4rem 1rem 2.5rem; flex: 1; }

/* Pie clásico */
.appfooter { background: var(--bar); color: #9aa2ab; font-size: .78rem; margin-top: auto; }
.appfooter-inner { max-width: var(--ancho); margin: 0 auto; padding: .8rem 1rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.appfooter a { color: var(--bar-ink); }

/* ------------------------------------------------------------
   Cards y grillas
   ------------------------------------------------------------ */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.15rem 1.25rem; margin-bottom: 1.25rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; gap: .75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card > h2, .card-head h2 { border-bottom: 2px solid #e7eaee; padding-bottom: .45rem; }
.card-head h2 { border-bottom: none; padding-bottom: 0; }
.card-head { border-bottom: 2px solid #e7eaee; padding-bottom: .5rem; margin-bottom: .9rem; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; }
.grid-2c { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .grid-2, .grid-2c { grid-template-columns: 1fr; } }

/* Tarjetas de estadísticas */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.card.stat { text-align: center; padding: 1rem; border-top: 3px solid var(--brand); margin-bottom: 0; }
.stat-num { font-size: 1.75rem; font-weight: 700; color: var(--brand-d); }
.stat-label { color: var(--muted); font-size: .8rem; }

/* ------------------------------------------------------------
   Botones
   ------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
    background: #fff; border: 1px solid #c6ccd4; color: var(--ink);
    padding: .48rem .85rem; border-radius: var(--radius); font-size: .85rem; font-weight: 600;
    text-decoration: none; transition: .12s;
}
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand-d); color: #fff; }
.btn-primary:hover { background: var(--brand-d); }
.btn-danger { background: #fff; border-color: #f3b4b4; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: .28rem .55rem; font-size: .78rem; }
.btn-block { width: 100%; justify-content: center; }
.inline { display: inline; }
.right { margin-left: auto; }

/* Alertas */
.alert { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; border: 1px solid; }
.alert-success { background: #f0fdf4; color: #14532d; border-color: #bbe7c8; }
.alert-error { background: #fef2f2; color: #991b1b; border-color: #f3c1c1; }
.alert-warn { background: #fffbeb; color: #92400e; border-color: #f5dfa8; }

/* ------------------------------------------------------------
   Tablas
   ------------------------------------------------------------ */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .55rem .65rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f7f8fa; border-bottom: 2px solid var(--line); }
.table tbody tr:hover { background: #f9fbfd; }
.table-kv th { width: 140px; color: var(--muted); }
.table-docs td { padding: .4rem .45rem; }
.table-docs select, .table-docs input { font-size: .8rem; padding: .3rem; }
.w-90 { width: 90px; }

/* Badges */
.badge {
    display: inline-block; padding: .14rem .5rem; border-radius: 3px;
    font-size: .72rem; font-weight: 600; background: #e8f4fb; color: #0f5e8c;
}
.badge-ok { background: #ecfdf5; color: #065f46; }
.badge-alta, .badge.badge-alta { background: #fef2f2; color: #991b1b; }
.badge-media { background: #fffbeb; color: #92400e; }
.badge-baja { background: #f1f5f9; color: #475569; }
.badge-portal { background: #eefbf3; color: #0c6b3d; border: 1px dashed #79c79b; }
/* Distintivo de etapa: el color lo define el gerente en Administración → Etapas
   y llega en --etapa; el fondo es ese color muy aclarado y el texto, oscurecido. */
.badge-etapa {
    --etapa: #64748b;
    position: static; background: #f1f5f9; color: var(--etapa);
    background: color-mix(in srgb, var(--etapa) 13%, #fff);
    color: color-mix(in srgb, var(--etapa) 78%, #000);
    box-shadow: inset 3px 0 0 var(--etapa);
}
.badge-archivada { background: #e2e8f0; color: #334155; }
/* Rojo fuerte: cierre negativo en la ficha. */
.badge-revisar { background: #dc2626; color: #fff; font-weight: 700; }
/* Tareas abiertas de una propiedad, al lado de su nombre en el listado. */
.badge-tareas { background: #fff7ed; color: #9a3412; margin-left: .3rem; font-weight: 600; }
a.badge-tareas:hover { text-decoration: none; background: #ffedd5; }

/* Leyenda de etapas del listado de propiedades: plegada por defecto para no
   competir con la tabla; al abrirla, una fila por etapa en el orden del flujo. */
.leyenda-etapas { margin: -.4rem 0 1rem; font-size: .82rem; }
.leyenda-etapas > summary {
    cursor: pointer; color: var(--muted); display: inline-block;
    padding: .2rem .1rem; user-select: none;
}
.leyenda-etapas > summary:hover { color: var(--brand-d); }
.leyenda-etapas ul {
    list-style: none; margin: .5rem 0 0; padding: .75rem .9rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: .4rem .9rem;
}
.leyenda-etapas li { display: flex; align-items: baseline; gap: .45rem; }
.leyenda-etapas li .badge { flex: 0 0 auto; }

/* Casilla de confirmación del propietario dentro de la grilla del formulario. */
.check-confirmo { gap: .3rem; }
.check-confirmo > span { display: flex; align-items: center; gap: .45rem; font-weight: 600; }
.check-confirmo input[type="checkbox"] { width: auto; margin: 0; }

/* Cabeceras ordenables del listado de propiedades (v20). */
.th-orden { padding: 0; }
.th-orden a {
    display: flex; align-items: center; gap: .35rem; justify-content: space-between;
    padding: .6rem .7rem; color: inherit; text-decoration: none;
}
/* Los títulos de columna se parten en dos líneas antes que ensanchar la tabla. */
.table-props thead th { white-space: normal; }
.th-orden a:hover { background: #eef4f8; color: var(--brand-d); }
.orden-flecha { font-size: .72em; opacity: .35; }
.orden-flecha.activa { opacity: 1; color: var(--brand-d); }

/* Columnas numéricas estrechas del listado (prioridades). */
.table-props td.mid { text-align: center; font-variant-numeric: tabular-nums; }
/* Códigos de publicación apilados en una sola celda del listado. */
.table-props td.cod-pub { display: table-cell; font-size: .95em; line-height: 1.35; }
.table-props td.cod-pub span { display: block; }
.table-props td.cod-pub b { color: var(--muted); font-weight: 600; font-size: .85em; }

/* Responsable en la cabecera de la ficha: lo primero que se pregunta al abrirla. */
.asignada-a { margin: .45rem 0 0; font-size: .9rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.asignada-a strong { color: var(--muted); font-weight: 600; }

/* «Pedir apoyo / nueva tarea» bajo el responsable, donde estaba «Enviar a revisión». */
.acciones-cabecera { margin: .6rem 0 0; display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; font-size: .88rem; }

/* Etapa y responsable: dos cambios manuales, lado a lado. */
.cambios-manuales {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem 1.6rem;
    padding: .7rem 1rem; border-left: 3px solid var(--brand);
}
.cambio-manual { display: flex; align-items: flex-end; gap: .45rem; margin: 0; }
.cambio-manual label { display: grid; gap: .2rem; font-size: .78rem; font-weight: 600; color: var(--muted); }
.cambio-manual select { width: auto; min-width: 14rem; }
.cambios-nota { margin: 0; font-size: .78rem; flex: 1 1 16rem; }

/* Tareas ya realizadas: plegadas, para que no compitan con las abiertas. */
.gestiones-hechas { margin-top: 1rem; font-size: .9rem; }
.gestiones-hechas > summary { cursor: pointer; color: var(--muted); padding: .2rem .1rem; user-select: none; }
.gestiones-hechas > summary:hover { color: var(--brand-d); }
.gestiones-hechas .table { margin-top: .6rem; }

/* Anti-bot del login: campo trampa fuera de la vista (no display:none, que
   algunos robots detectan) y caja del captcha. */
.campo-trampa { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.captcha-caja { display: grid; gap: .45rem; }
.captcha-fila { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.captcha-fila img { border: 1px solid var(--line); border-radius: 3px; background: #fff; }
.captcha-caja input[name="captcha"] { letter-spacing: .25em; text-transform: uppercase; font-weight: 600; }

/* Barra de guardado al inicio del formulario de propiedad. */
.form-actions-top {
    display: flex; gap: .5rem; justify-content: flex-end; align-items: center;
    margin: 0 0 .9rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line);
}

/* Listado de propiedades: densidad ajustada para que las 12 columnas
   entren sin scroll lateral en un monitor normal. */
.table-props { font-size: .86rem; }
.table-props th, .table-props td { padding: .45rem .5rem; }
.table-props thead th { font-size: .68rem; letter-spacing: .03em; }
.table-props .th-orden a { padding: .45rem .5rem; }
/* El título es lo único que puede crecer: se le da el ancho sobrante
   y se le permite cortar en dos líneas en vez de empujar la tabla. */
.table-props td.col-titulo { min-width: 12rem; }
/* Casilla de la asignación masiva: columna angosta al inicio. */
.table-props .col-sel { width: 1.6rem; text-align: center; }
.table-props .col-sel input { width: auto; margin: 0; cursor: pointer; }
/* Barra de la asignación masiva, sobre la tabla. */
.asignacion-masiva {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
    padding: .55rem .75rem; margin-bottom: .6rem;
    background: var(--bg); border-radius: var(--radius);
}
.asignacion-masiva label { display: flex; align-items: center; gap: .4rem; margin: 0; }
.asignacion-masiva select { width: auto; min-width: 14rem; }
.asignacion-masiva .am-cuenta { color: var(--muted); font-size: .9rem; margin-right: auto; }
.asignacion-masiva.am-activa .am-cuenta { color: inherit; font-weight: 600; }
/* Acciones: el <td> sigue siendo celda (si se le pone flex, la tabla deja de
   calcular su ancho y el contenido se recorta). Quien envuelve es este div,
   con un tope de ancho para que los botones caigan en varias líneas. */
.table-props td.acciones .acciones-wrap {
    display: flex; flex-wrap: wrap; gap: .25rem;
    justify-content: flex-end; align-items: center;
    max-width: 13rem; margin-left: auto;
}
.table-props td.acciones select { max-width: 100%; }
.table-props td.acciones .btn { white-space: nowrap; }
.table-props td.acciones form { margin: 0; }
/* Pantallas de 13" a 15" (1280-1400): se aprieta un punto más la densidad
   para que las 12 columnas sigan cabiendo sin scroll lateral. */
@media (max-width: 1400px) {
    .table-props { font-size: .79rem; }
    .table-props th, .table-props td { padding: .34rem .32rem; }
    .table-props .th-orden a { padding: .34rem .32rem; }
    .table-props td.col-titulo { min-width: 9rem; }
    .table-props td.acciones .acciones-wrap { max-width: 8rem; }
    .table-props .btn-sm { font-size: .7rem; padding: .22rem .4rem; }
    .table-props td.acciones select { font-size: .7rem; padding: .22rem; }
    .table-props td.cod-pub { font-size: .9em; }
}


/* Señales de completitud del formulario de datos: verde = con datos, rojo = sin datos.
   El punto va en la esquina superior derecha de cada campo (los labels son flex-columna). */
form[data-senales] label { position: relative; }
.senal { position: absolute; top: .2rem; right: 0; width: .55rem; height: .55rem; border-radius: 50%; }
.senal-ok    { background: #16a34a; box-shadow: 0 0 0 2px #dcfce7; }
.senal-falta { background: #dc2626; box-shadow: 0 0 0 2px #fee2e2; }

/* Comentarios al costado del formulario de edición */
.comentarios-lateral .card { position: sticky; top: 1rem; }
.comentarios-hilo { max-height: 55vh; overflow-y: auto; padding-right: .25rem; }

/* Panel "Enviar a precaptura" (candidatas, solo gerente) */

/* Leyenda del propietario en el perfil de la propiedad. Rojo = "Propietario no
   existe"; azul = registrado. Pincharla lleva a propietario.php: los datos del
   propietario y las gestiones de cada medio de contacto en tablas (el estado
   activo/inactivo de cada medio lo cambia solo el gerente). */
.propietario-linea { margin: 0 0 .7rem; }
.sin-propietario { color: var(--danger); }
/* La vista del propietario (registro de contactos) se distingue con un
   fondo levemente más oscuro; conserva el patrón de viviendas. */
body.body-oscuro { background-color: #e6e9ed; }
.leyenda-no-existe { color: var(--danger); text-decoration: underline dotted; text-underline-offset: 3px; }
.leyenda-nombre { color: var(--brand-d); text-decoration: underline dotted; text-underline-offset: 3px; }
a.leyenda-no-existe:hover { color: var(--danger); }
.badge-inactivo { background: #fef2f2; color: #991b1b; }
.medios-lista li { display: block; }
.medio-inactivo-txt { opacity: .65; }
.w-fecha { width: 130px; }
.w-usuario { width: 150px; }

/* ------------------------------------------------------------
   Formularios
   ------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.form-grid .col-2 { grid-column: span 2; }
.form-grid .col-3 { grid-column: span 3; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } .form-grid .col-2, .form-grid .col-3 { grid-column: span 1; } }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; color: var(--muted); font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: .5rem; }
input, select, textarea {
    font: inherit; padding: .48rem .6rem; border: 1px solid #c6ccd4;
    border-radius: var(--radius); background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfe3f5; border-color: var(--brand); }
input[type="checkbox"] { width: auto; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.1rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.inline-form input, .inline-form select { width: auto; }

/* Toolbar / filtros */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.filters input, .filters select { width: auto; }

/* ------------------------------------------------------------
   Listas y línea de tiempo
   ------------------------------------------------------------ */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .5rem 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.timeline { list-style: none; margin: 1rem 0 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 1rem 1rem; margin-left: .5rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .25rem; }

/* ------------------------------------------------------------
   Listado de propiedades (tabla)
   ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.table-props td.acciones { text-align: right; }
.table-props td.acciones form { margin-left: .25rem; }
.table-props td.acciones select { width: auto; font-size: .8rem; padding: .3rem; }
.no-img { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); }
.no-img.tall { height: 200px; border: 1px dashed var(--line); border-radius: var(--radius); }
.prop-price { font-weight: 700; color: var(--brand-d); margin: .4rem 0; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
/* Aviso del optimizador de imágenes junto al input de archivo */
.nota-imagen { display: block; width: 100%; color: var(--muted); font-size: .78rem; }

/* Detalle */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.detail-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.detail-actions select { width: auto; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.gallery img { width: 100%; height: 110px; object-fit: cover; border-radius: var(--radius); }
.price { color: var(--brand-d); }

/* Administrador de imágenes */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.img-item { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.img-item.is-cover { outline: 2px solid var(--brand); }
.img-item img { width: 100%; height: 120px; object-fit: cover; display: block; }
.img-item figcaption { display: flex; align-items: center; justify-content: space-between; padding: .35rem; gap: .35rem; }

/* Pestañas */
.tab-nav { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin-bottom: 1.25rem; }
.tab { background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: .6rem .9rem; cursor: pointer; color: var(--muted); font-weight: 600; font-size: .85rem; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand-d); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Coloreo por estado de fila */
tr.estado-ok, tr.estado-hecha { background: #f0fdf4; }
tr.estado-en_proceso { background: #fffbeb; }
tr.estado-cancelada { opacity: .55; }

/* Filas-formulario (documentos / etapas de cierre) */
.row-edit {
    display: grid;
    grid-template-columns: 2fr 1.3fr 1.3fr 1.2fr 1.2fr .9fr .5fr auto;
    gap: .5rem; align-items: center;
    padding: .45rem .3rem; border-bottom: 1px solid var(--line);
}
.row-edit.cierre { grid-template-columns: .4fr 2fr 1.3fr 1.2fr 2fr auto; }
.row-edit.plantilla { grid-template-columns: .5fr 2.6fr 1.1fr 1.4fr 1fr .7fr .5fr auto; align-items: start; }
.row-edit.plantilla.head { align-items: center; }
.row-edit.head { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--line); background: #f7f8fa; }
.row-edit select, .row-edit input { width: 100%; font-size: .8rem; padding: .3rem .4rem; }
.row-edit label.check { justify-content: center; }
.row-edit.estado-ok { background: #f0fdf4; }
.row-edit.estado-en_proceso { background: #fffbeb; }
@media (max-width: 760px) { .row-edit, .row-edit.cierre { grid-template-columns: 1fr 1fr; } .row-edit.head { display: none; } }

/* ------------------------------------------------------------
   Gráficos (SVG generados por js/charts.js)
   ------------------------------------------------------------ */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin-top: .5rem; font-size: .78rem; color: var(--muted); }
.chart-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.chart-empty { color: var(--muted); text-align: center; padding: 1.5rem 0; }

/* Barra de progreso (checklist de cierre, portal) */
.progress { background: #e8ebef; border-radius: 999px; height: 10px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.progress.ok > span { background: var(--ok); }
.progress-label { font-size: .78rem; color: var(--muted); margin-top: .25rem; }

/* ------------------------------------------------------------
   Login y páginas independientes (fondo oscuro con patrón)
   ------------------------------------------------------------ */
.login-body {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1.1rem; min-height: 100vh;
    background: #23282e url('pattern-dark.svg') repeat;
}
/* Pie del ingreso: versión y autoría. La versión es lo primero que se pregunta
   cuando alguien reporta un problema, así que conviene tenerla a la vista. */
.login-pie {
    display: flex; flex-direction: column; align-items: center; gap: .15rem;
    color: #8c98a4; font-size: .78rem; text-align: center; line-height: 1.5;
}
.login-pie strong { color: #b9c5d0; font-weight: 600; }
.login-card { background: #fff; padding: 2rem; border-radius: 6px; border-top: 4px solid var(--brand); width: 380px; max-width: 92vw; box-shadow: 0 10px 40px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: .9rem; }
.login-card .logo { align-self: center; font-size: 2rem; padding-right: 3.4rem; }
.login-card .logo .logo-sub { font-size: .85rem; }
.login-card .muted { text-align: center; margin: 0 0 .5rem; }
details summary { cursor: pointer; color: var(--brand-d); font-weight: 600; }

/* ------------------------------------------------------------
   Portal del cliente (página pública, solo lectura)
   ------------------------------------------------------------ */
.portal-body { background: var(--bg) url('pattern.svg') repeat; margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
.portal-bar { background: var(--bar); }
.portal-bar-inner { max-width: 980px; margin: 0 auto; padding: .8rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.portal-bar .who { color: var(--bar-ink); font-size: .85rem; text-align: right; }
.portal-content { max-width: 980px; width: 100%; margin: 0 auto; padding: 1.5rem 1rem 3rem; flex: 1; }
.portal-prop { margin-bottom: 1.5rem; }
.portal-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.portal-head img { width: 220px; height: 150px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.portal-head .no-img { width: 220px; height: 150px; border: 1px dashed var(--line); border-radius: var(--radius); }
.portal-datos { flex: 1; min-width: 240px; }
.portal-datos h2 { border: none; padding: 0; }
.portal-empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }

/* ── v14: badges de tipo de gestión, links y sugerencias de duplicados ── */
.badge-gestion-correo   { background: #e8f4fb; color: #0f5e8c; }
.badge-gestion-llamada  { background: #f5f3ff; color: #5b21b6; }
.badge-gestion-whatsapp { background: #ecfdf5; color: #065f46; }
.badge-gestion-otro     { background: #f1f5f9; color: #475569; }
.link-inactivo { opacity: .55; }
.sugerencia-duplicado {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); list-style: none; margin: 0; padding: .25rem 0;
}
.sugerencia-duplicado a { display: block; padding: .4rem .7rem; font-size: .82rem; color: var(--ink); }
.sugerencia-duplicado a:hover { background: #eef6fb; color: var(--brand-d); text-decoration: none; }

/* Buscador de contactos: caja de texto + lista flotante de resultados.
   Reemplaza al desplegable cuando hay demasiados registros para desplazarlos. */
.buscador-contacto { position: relative; display: flex; align-items: center; }
.buscador-contacto .bc-texto { padding-right: 1.9rem; }
.bc-limpiar {
    position: absolute; right: .4rem; border: 0; background: none; cursor: pointer;
    color: var(--muted); font-size: 1.1rem; line-height: 1; padding: .15rem .25rem;
}
.bc-limpiar:hover { color: var(--danger); }
.bc-lista {
    position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 60;
    margin: 0; padding: .25rem 0; list-style: none; max-height: 17rem; overflow-y: auto;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(0,0,0,.14);
}
.bc-lista li {
    padding: .4rem .7rem; cursor: pointer; font-size: .86rem; font-weight: 400;
    display: flex; flex-direction: column; gap: .1rem;
}
.bc-lista li.activo { background: #eef6fb; }
.bc-lista li strong { color: var(--ink); font-weight: 600; }
.bc-lista li span { color: var(--muted); font-size: .78rem; }
.bc-lista .bc-vacio { color: var(--muted); cursor: default; font-style: italic; }

/* Registro de propietario: coincidencias con contactos ya existentes, en vivo
   mientras se escribe y, si se envió igual, el aviso del servidor. */
.sugerencias-propietario, .dup-aviso {
    margin-top: .8rem; padding: .7rem .9rem; border-radius: var(--radius);
    background: #fffbeb; border: 1px solid #fcd34d; border-left: 3px solid var(--warn);
}
.dup-aviso { margin: 0 0 1rem; }
.dup-aviso > p { margin: 0 0 .6rem; font-size: .9rem; }
.sp-titulo { margin: 0 0 .4rem; font-size: .82rem; font-weight: 600; color: #92400e; }
.sugerencias-propietario ul, .dup-lista { list-style: none; margin: 0; padding: 0; }
.sugerencias-propietario li, .dup-lista li {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .45rem 0; border-top: 1px solid #fde68a;
}
.sugerencias-propietario li:first-child, .dup-lista li:first-child { border-top: 0; }
.sugerencias-propietario li > div, .dup-lista li > div { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.sugerencias-propietario li small, .dup-lista li small { font-size: .78rem; }
.dup-lista form { margin: 0; flex: 0 0 auto; }
.dup-nuevo { margin-top: .7rem; padding-top: .6rem; border-top: 1px dashed #fcd34d; }

/* ── Octubre 2026: filtros múltiples, etapas, bitácora, CRM y terreno ── */

/* Filtros de los tableros: textos arriba, selectores múltiples debajo y, al
   final, los filtros activos como fichas con su «×». */
.filtros-tablero { display: grid; gap: .6rem; padding: .8rem 1rem; }
.ft-textos { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: .5rem; }
.ft-textos input { width: 100%; }
.ft-selectores { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.ft-selectores > select { width: auto; }
@media (max-width: 760px) { .ft-textos { grid-template-columns: 1fr 1fr; } }

.fm { position: relative; }
.fm > summary {
    list-style: none; cursor: pointer; user-select: none;
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .42rem .7rem; border: 1px solid var(--line); border-radius: var(--radius);
    background: #fff; font-weight: 600; font-size: .85rem;
}
.fm > summary::-webkit-details-marker { display: none; }
.fm > summary::after { content: '▾'; font-size: .7rem; color: var(--muted); }
.fm[open] > summary { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(23,147,209,.15); }
.fm-n {
    background: var(--brand); color: #fff; border-radius: 9px; min-width: 1.15rem;
    padding: 0 .35rem; font-size: .72rem; line-height: 1.15rem; text-align: center;
}
.fm-panel {
    position: absolute; z-index: 30; top: calc(100% + 4px); left: 0;
    min-width: 15rem; max-width: 22rem; background: #fff;
    border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .5rem;
}
.fm-panel-ancho { width: min(46rem, 92vw); max-width: none; }
.fm-opciones { max-height: 18rem; overflow-y: auto; display: grid; gap: .05rem; }
.fm-buscar { width: 100%; margin-bottom: .4rem; }
.fm-op {
    display: flex; flex-direction: row; align-items: center; gap: .45rem; padding: .28rem .35rem;
    border-radius: 3px; cursor: pointer; font-size: .86rem; font-weight: 400;
}
.fm-op:hover { background: #f1f7fb; }
.fm-op input { width: auto; margin: 0; }
.fm-op[hidden] { display: none; }
.fm-txt { flex: 1; }
.fm-color { width: .7rem; height: .7rem; border-radius: 2px; flex: 0 0 auto; }
.fm-cuenta { color: var(--muted); font-variant-numeric: tabular-nums; }
.fm-acciones { display: flex; justify-content: space-between; gap: .4rem; margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.fm-grupos { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .6rem; }
.fm-grupos fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0; padding: .35rem .5rem .5rem; display: grid; gap: .25rem; align-content: start; }
.fm-grupos legend { font-size: .75rem; font-weight: 700; color: var(--muted); padding: 0 .25rem; }
.fm-grupos label { font-size: .84rem; display: grid; gap: .15rem; }
.fm-grupos select, .fm-grupos input[type="number"], .fm-grupos input[type="date"] { width: 100%; }
.fm-prio { grid-template-columns: repeat(auto-fill, minmax(4.2rem, 1fr)) !important; }
@media (max-width: 760px) {
    .fm-panel { position: fixed; left: 4vw; right: 4vw; top: 18vh; max-width: none; width: auto; max-height: 70vh; overflow: auto; }
}

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .55rem;
    background: #e8f4fb; color: #0f5e8c; border-radius: 12px; font-size: .78rem; font-weight: 600;
}
.chip span { font-size: .95rem; line-height: 1; opacity: .7; }
.chip:hover { background: #fee2e2; color: #991b1b; text-decoration: none; }

/* Inicio: cuántas propiedades hay en cada etapa, cada una lleva al tablero filtrado. */
a.card.stat { color: inherit; display: block; }
a.card.stat:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.etapas-tira { display: flex; flex-wrap: wrap; gap: .5rem; padding: .7rem .8rem; }
.etapa-chip {
    --etapa: #64748b;
    display: flex; align-items: baseline; gap: .4rem; padding: .35rem .7rem;
    border-radius: var(--radius); border-left: 4px solid var(--etapa);
    background: color-mix(in srgb, var(--etapa) 9%, #fff); color: var(--ink);
}
.etapa-chip:hover { text-decoration: none; background: color-mix(in srgb, var(--etapa) 18%, #fff); }
.etapa-chip-n { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.etapa-chip-nombre { font-size: .82rem; color: var(--muted); }

/* Bitácora: el tipo de cada registro y el filtro para ver solo uno. */
.filtro-bitacora { display: flex; flex-direction: row; align-items: center; gap: .45rem; font-size: .82rem; font-weight: 600; color: var(--muted); }
.filtro-bitacora select { width: auto; flex: 1; }
.comentarios-hilo li[hidden] { display: none; }
.badge-bitacora { background: #f1f5f9; color: #475569; font-weight: 600; }
.tipo-etapa       { background: #eef2ff; color: #3730a3; }
.tipo-responsable { background: #f5f3ff; color: #5b21b6; }
.tipo-tarea       { background: #fff7ed; color: #9a3412; }
.tipo-gestion     { background: #ecfeff; color: #155e75; }
.tipo-datos       { background: #f1f5f9; color: #334155; }
.tipo-publicacion { background: #fdf2f8; color: #9d174d; }
.tipo-interesado  { background: #ecfdf5; color: #065f46; }
.tipo-terreno     { background: #fefce8; color: #854d0e; }
.tipo-documento   { background: #f0f9ff; color: #075985; }

/* Campo con botones al lado (enlace de Google Maps). */
.campo-con-acciones { display: flex; gap: .35rem; align-items: center; }
.campo-con-acciones input { flex: 1; min-width: 0; }

/* Mantenedor de etapas: orden con flechas. */
.orden-botones { display: inline-flex; align-items: center; gap: .25rem; }
.orden-num { min-width: 1.4rem; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.input-sm { width: 11rem !important; padding: .25rem .4rem; font-size: .8rem; }

/* Tareas: accesos rápidos y filas vencidas. */
.rapidos { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip-rapido { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.chip-rapido:hover { background: #e8f4fb; color: #0f5e8c; }
.check-inline { display: inline-flex; flex-direction: row; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 500; margin-right: .8rem; }
.check-inline input { width: auto; margin: 0; }
.fila-vencida td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.texto-vencido { color: var(--danger); font-weight: 600; }
.mid { text-align: center; font-variant-numeric: tabular-nums; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.tipos-reporte { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .75rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.tipos-reporte legend { font-size: .8rem; font-weight: 700; color: var(--muted); padding: 0 .3rem; }

/* Ficha del interesado: teléfonos y correos a un toque. */
.medios-cabecera { margin: .55rem 0 0; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.lista-tareas li { gap: .4rem; }
.lista-tareas form { margin-left: auto; }

/* Apoyo en terreno: pensado para el celular, una columna y botones grandes. */
.terreno { max-width: 44rem; margin: 0 auto; }
.terreno .form label { font-size: .95rem; }
.terreno input, .terreno select, .terreno textarea { font-size: 16px; }  /* evita el zoom automático del iPhone */
.encargos li { justify-content: space-between; }
.encargo-acciones { display: flex; gap: .35rem; flex-wrap: wrap; }
.tipo-registro { border: 0; padding: 0; margin: 0; display: grid; gap: .4rem; }
.tipo-registro legend { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.opcion-grande {
    display: flex; flex-direction: row; align-items: center; gap: .6rem; padding: .65rem .8rem;
    border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; font-weight: 600;
}
.opcion-grande:has(input:checked) { border-color: var(--brand); background: #eef7fc; }
.opcion-grande input { width: auto; margin: 0; transform: scale(1.2); }
.solo-estado { display: grid; gap: .75rem; }
.solo-estado[hidden] { display: none; }
.btn-grande { width: 100%; padding: .8rem 1rem; font-size: 1rem; }
@media (max-width: 760px) {
    .terreno .card { padding: .9rem; }
    .form-grid-2 { grid-template-columns: 1fr; }
}

.ft-fecha { flex-direction: row; align-items: center; gap: .4rem; white-space: nowrap; }
.ft-fecha input { flex: 1; min-width: 0; }

/* Celular: la barra superior se parte en dos líneas en vez de salirse de la
   pantalla (el apoyo en terreno la usa desde el teléfono). */
@media (max-width: 760px) {
    .archbar-inner { flex-wrap: wrap; gap: 0 .6rem; padding: .25rem .6rem; }
    .mainnav { flex-wrap: wrap; order: 3; flex-basis: 100%; }
    .mainnav a.nav-link { padding: .55rem .55rem; }
    .user-box { margin-left: auto; }
}
.inline-form .buscador-contacto { min-width: 18rem; flex: 1 1 18rem; }

/* Logo de los reportes para el cliente: vista previa sobre un damero, para
   que se note si el fondo es transparente. */
.logo-reporte {
    display: block; max-width: 280px; max-height: 90px; margin: .2rem 0 .6rem;
    padding: .4rem; border: 1px solid var(--line); border-radius: var(--radius);
    background: repeating-conic-gradient(#eef0f3 0 25%, #fff 0 50%) 0 0 / 14px 14px;
}
.logo-reporte-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .4rem 0; }
.logo-reporte-form input[type="file"] { width: auto; }
/* Reporte de asignaciones: cómo se hizo cada una. */
.badge-masiva { background: #f5f3ff; color: #5b21b6; font-weight: 600; }
