/* ==========================================================================
   TerrenIA360 · Sistema de diseño
   Identidad: azul marino profundo, verde esmeralda, verde lima.
   El plano es el protagonista: la interfaz se comporta como papel técnico
   sobre el que se apoyan fichas con esquina achaflanada (vértice de lote).
   ========================================================================== */

:root {
    /* Paleta de marca */
    --marino-900: #071229;
    --marino-800: #0B1B3F;
    --marino-700: #12295C;
    --marino-600: #1B3B7A;
    --esmeralda:  #0FA968;
    --esmeralda-claro: #12B76A;
    --lima:       #A9DC12;
    --lima-suave: #E8F7B5;

    /* Neutros */
    --lienzo:  #F3F6FB;
    --papel:   #FFFFFF;
    --tinta:   #0B1B3F;
    --gris:    #5C6B85;
    --gris-suave: #8A97AC;
    --borde:   #DEE5F0;
    --borde-fuerte: #C6D1E4;

    /* Semánticos */
    --exito:  #0FA968;
    --aviso:  #E8942C;
    --error:  #DC3545;
    --info:   #2E7CF6;

    /* Estados de lote */
    --estado-disponible: #12B76A;
    --estado-solicitado: #A9DC12;
    --estado-apartado:   #F0921F;
    --estado-vendido:    #0B1B3F;
    --estado-bloqueado:  #6C7A93;
    --estado-nocomer:    #C6D1E4;

    /* Tipografía */
    --fuente-titulo: 'Sora', 'Segoe UI', system-ui, sans-serif;
    --fuente-texto:  'Inter', 'Segoe UI', system-ui, sans-serif;
    --fuente-dato:   'JetBrains Mono', 'SF Mono', Consolas, monospace;

    /* Escala */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --sombra-1: 0 1px 2px rgba(11, 27, 63, .06), 0 1px 3px rgba(11, 27, 63, .04);
    --sombra-2: 0 4px 12px rgba(11, 27, 63, .08);
    --sombra-3: 0 12px 32px rgba(11, 27, 63, .14);
    --lateral: 264px;
    --transicion: 160ms cubic-bezier(.4, 0, .2, 1);
}

[data-tema="oscuro"] {
    --lienzo: #0A1329;
    --papel:  #111E3C;
    --tinta:  #E8EEF9;
    --gris:   #9FB0CC;
    --gris-suave: #7387A6;
    --borde:  #1E2F55;
    --borde-fuerte: #2A3E68;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--fuente-texto);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--tinta);
    background: var(--lienzo);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .titulo {
    font-family: var(--fuente-titulo);
    font-weight: 600;
    letter-spacing: -.015em;
    color: var(--tinta);
    margin: 0;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

a { color: var(--marino-600); text-decoration: none; }
a:hover { color: var(--esmeralda); }

:focus-visible {
    outline: 2px solid var(--esmeralda);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Dato técnico: códigos de lote, áreas, importes.
   El monoespaciado es el lenguaje del catastro, no un adorno. */
.dato {
    font-family: var(--fuente-dato);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}

.codigo-lote {
    font-family: var(--fuente-dato);
    font-weight: 600;
    font-size: .82rem;
    letter-spacing: .01em;
    color: var(--marino-700);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* El punto es el vértice del polígono: marca que hay geometría detrás */
.codigo-lote::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    border: 1.5px solid var(--esmeralda);
    background: var(--papel);
    flex: none;
}

/* ============================ Estructura ============================ */

.aplicacion { display: flex; min-height: 100vh; }

.lateral {
    width: var(--lateral);
    flex: none;
    background: var(--marino-800);
    color: #C9D6EE;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    transition: transform var(--transicion);
}

.lateral__marca {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.lateral__marca img { width: 34px; height: 34px; border-radius: 8px; }

.lateral__marca strong {
    font-family: var(--fuente-titulo);
    font-size: 1.02rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.02em;
}
.lateral__marca strong span { color: var(--lima); }

.lateral__nav { flex: 1; overflow-y: auto; padding: 14px 12px 24px; }

.lateral__grupo {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #6E82A8;
    padding: 16px 10px 7px;
    font-weight: 600;
}

.lateral__enlace {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: var(--r-sm);
    color: #C9D6EE;
    font-size: .88rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background var(--transicion), color var(--transicion);
}

.lateral__enlace:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.lateral__enlace--activo {
    background: linear-gradient(90deg, rgba(15, 169, 104, .22), rgba(169, 220, 18, .06));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--lima);
}

.lateral__enlace svg { width: 17px; height: 17px; flex: none; opacity: .9; }

.lateral__insignia {
    margin-left: auto;
    background: var(--lima);
    color: var(--marino-800);
    font-size: .68rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 20px;
}

.lateral__pie {
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: .78rem;
}

.lateral__plan {
    background: rgba(255, 255, 255, .05);
    border-radius: var(--r-md);
    padding: 12px;
}
.lateral__plan b { color: #fff; display: block; font-size: .85rem; }
.lateral__plan small { color: #8FA2C4; }

.principal {
    flex: 1;
    margin-left: var(--lateral);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.barra {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--borde);
    padding: 12px 26px;
    display: flex;
    align-items: center;
    gap: 14px;
}
[data-tema="oscuro"] .barra { background: rgba(17, 30, 60, .9); }

.barra__titulo { flex: 1; min-width: 0; }
.barra__titulo h1 { font-size: 1.18rem; line-height: 1.2; }
.barra__titulo p { margin: 1px 0 0; font-size: .8rem; color: var(--gris); }

.contenido { padding: 22px 26px 60px; flex: 1; }

.contenido--ancho { max-width: 1500px; }

/* ============================ Tarjetas ============================ */

.tarjeta {
    background: var(--papel);
    border: 1px solid var(--borde);
    border-radius: var(--r-md);
    box-shadow: var(--sombra-1);
}

.tarjeta__cabeza {
    padding: 14px 18px;
    border-bottom: 1px solid var(--borde);
    display: flex;
    align-items: center;
    gap: 12px;
}
.tarjeta__cabeza h2, .tarjeta__cabeza h3 { font-size: .98rem; flex: 1; }
.tarjeta__cuerpo { padding: 18px; }
.tarjeta__pie { padding: 12px 18px; border-top: 1px solid var(--borde); background: var(--lienzo); border-radius: 0 0 var(--r-md) var(--r-md); }

/* Indicador con esquina achaflanada: la silueta de un lote replanteado */
.indicador {
    background: var(--papel);
    border: 1px solid var(--borde);
    border-radius: var(--r-md);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%);
    transition: border-color var(--transicion), transform var(--transicion);
}
.indicador:hover { border-color: var(--borde-fuerte); transform: translateY(-1px); }

.indicador::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 16px; height: 16px;
    background: linear-gradient(225deg, var(--borde) 50%, transparent 50%);
}

.indicador__etiqueta {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--gris);
    font-weight: 600;
    margin: 0 0 6px;
}

.indicador__valor {
    font-family: var(--fuente-titulo);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
}
.indicador__valor--dinero { font-size: 1.28rem; }

.indicador__nota { font-size: .78rem; color: var(--gris); margin: 5px 0 0; }

.indicador--acento { border-left: 3px solid var(--esmeralda); }
.indicador--aviso  { border-left: 3px solid var(--aviso); }
.indicador--lima   { border-left: 3px solid var(--lima); }
.indicador--marino { border-left: 3px solid var(--marino-700); }

/* ===================== Cinta de estados (firma visual) ===================== */

.cinta-estados {
    display: flex;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--borde);
    background: var(--papel);
    min-height: 62px;
}

.cinta-estados__tramo {
    flex-grow: var(--peso, 1);
    flex-basis: 0;
    min-width: 62px;
    padding: 11px 13px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    transition: flex-grow 400ms cubic-bezier(.4, 0, .2, 1);
}
.cinta-estados__tramo b {
    font-family: var(--fuente-titulo);
    font-size: 1.2rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.cinta-estados__tramo span { font-size: .73rem; opacity: .92; margin-top: 3px; }
.cinta-estados__tramo--vacio { background: var(--lienzo) !important; color: var(--gris-suave); }

/* ============================ Distintivos ============================ */

.distintivo {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: .74rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.distintivo__punto { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.distintivo--suave { background: var(--lienzo); color: var(--gris); border: 1px solid var(--borde); }
.distintivo--exito { background: #E6F7EF; color: #0A7A4B; }
.distintivo--aviso { background: #FDF2E3; color: #A8630F; }
.distintivo--error { background: #FDEAEC; color: #A61B27; }
.distintivo--info  { background: #E9F2FE; color: #17549E; }
.distintivo--lima  { background: var(--lima-suave); color: #4F6B00; }

/* ============================ Botones ============================ */

.boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    padding: 8px 15px;
    font-family: var(--fuente-texto);
    font-size: .87rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transicion);
    text-decoration: none;
    line-height: 1.4;
}
.boton svg { width: 16px; height: 16px; }
.boton:disabled { opacity: .55; cursor: not-allowed; }

.boton--primario { background: var(--marino-800); color: #fff; }
.boton--primario:hover { background: var(--marino-700); color: #fff; box-shadow: var(--sombra-2); }

.boton--accion { background: var(--esmeralda); color: #fff; }
.boton--accion:hover { background: #0C8F58; color: #fff; }

.boton--lima { background: var(--lima); color: var(--marino-800); }
.boton--lima:hover { background: #96C40D; color: var(--marino-800); }

.boton--linea { background: transparent; border-color: var(--borde-fuerte); color: var(--tinta); }
.boton--linea:hover { border-color: var(--marino-600); background: var(--lienzo); color: var(--tinta); }

.boton--fantasma { background: transparent; color: var(--gris); }
.boton--fantasma:hover { background: var(--lienzo); color: var(--tinta); }

.boton--peligro { background: transparent; border-color: #F0C2C6; color: var(--error); }
.boton--peligro:hover { background: #FDEAEC; color: #A61B27; }

.boton--chico { padding: 5px 10px; font-size: .78rem; }
.boton--bloque { width: 100%; }

/* ============================ Formularios ============================ */

.campo { margin-bottom: 16px; }

.campo__etiqueta {
    display: block;
    font-size: .81rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--tinta);
}
.campo__etiqueta span { color: var(--error); }

.campo__control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--borde-fuerte);
    border-radius: var(--r-sm);
    font-family: var(--fuente-texto);
    font-size: .89rem;
    color: var(--tinta);
    background: var(--papel);
    transition: border-color var(--transicion), box-shadow var(--transicion);
}
.campo__control:focus {
    outline: none;
    border-color: var(--esmeralda);
    box-shadow: 0 0 0 3px rgba(15, 169, 104, .14);
}
.campo__control:disabled { background: var(--lienzo); color: var(--gris); }
.campo__control--numero { font-family: var(--fuente-dato); text-align: right; }
textarea.campo__control { min-height: 92px; resize: vertical; }
select.campo__control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%235C6B85'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }

.campo__ayuda { font-size: .76rem; color: var(--gris); margin-top: 4px; }
.campo__error { font-size: .78rem; color: var(--error); margin-top: 4px; font-weight: 500; }
.campo--invalido .campo__control { border-color: var(--error); }

.campo-check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 9px; }
.campo-check input { margin-top: 3px; accent-color: var(--esmeralda); width: 15px; height: 15px; }
.campo-check label { font-size: .86rem; cursor: pointer; }
.campo-check small { display: block; color: var(--gris); font-size: .77rem; }

.rejilla { display: grid; gap: 16px; }
.rejilla--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rejilla--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rejilla--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rejilla--auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* Formulario por pasos */
.pasos { display: flex; gap: 0; margin-bottom: 26px; }
.paso {
    flex: 1;
    text-align: center;
    padding-bottom: 11px;
    border-bottom: 3px solid var(--borde);
    font-size: .81rem;
    color: var(--gris);
    font-weight: 500;
}
.paso--activo { border-bottom-color: var(--esmeralda); color: var(--tinta); font-weight: 600; }
.paso--hecho { border-bottom-color: var(--lima); color: var(--tinta); }
.paso b {
    display: inline-flex; align-items: center; justify-content: center;
    width: 21px; height: 21px; border-radius: 50%;
    background: var(--borde); color: var(--gris);
    font-size: .74rem; margin-right: 6px;
    font-family: var(--fuente-dato);
}
.paso--activo b { background: var(--esmeralda); color: #fff; }
.paso--hecho b { background: var(--lima); color: var(--marino-800); }

/* ============================ Tablas ============================ */

.tabla-envoltura { overflow-x: auto; border-radius: var(--r-md); }

.tabla { width: 100%; border-collapse: collapse; font-size: .86rem; }

.tabla thead th {
    background: var(--lienzo);
    padding: 10px 14px;
    text-align: left;
    font-size: .73rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--gris);
    font-weight: 600;
    border-bottom: 1px solid var(--borde);
    white-space: nowrap;
}

.tabla tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--borde);
    vertical-align: middle;
}
.tabla tbody tr:last-child td { border-bottom: none; }
.tabla tbody tr { transition: background var(--transicion); }
.tabla tbody tr:hover { background: rgba(15, 169, 104, .045); }
.tabla__num { text-align: right; font-family: var(--fuente-dato); font-variant-numeric: tabular-nums; }
.tabla__acciones { text-align: right; white-space: nowrap; }

/* ============================ Avisos ============================ */

.aviso {
    display: flex;
    gap: 11px;
    padding: 12px 15px;
    border-radius: var(--r-md);
    font-size: .87rem;
    margin-bottom: 16px;
    border: 1px solid;
    align-items: flex-start;
}
.aviso svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.aviso--exito { background: #E9F8F1; border-color: #B9E7D2; color: #0A6B43; }
.aviso--error { background: #FDEDEF; border-color: #F5C6CB; color: #8E1620; }
.aviso--aviso { background: #FEF6E7; border-color: #F7DCB0; color: #8A5109; }
.aviso--info  { background: #EBF3FE; border-color: #C3DBFB; color: #14488C; }

/* Estado vacío: una invitación a actuar, no un mensaje de error */
.vacio { text-align: center; padding: 52px 24px; }
.vacio__icono {
    width: 62px; height: 62px;
    margin: 0 auto 16px;
    border-radius: var(--r-lg);
    background: var(--lienzo);
    display: grid; place-items: center;
    color: var(--gris-suave);
    border: 1px dashed var(--borde-fuerte);
}
.vacio__icono svg { width: 28px; height: 28px; }
.vacio h3 { font-size: 1.02rem; margin-bottom: 6px; }
.vacio p { color: var(--gris); font-size: .88rem; max-width: 400px; margin: 0 auto 18px; }

/* Cargando */
.esqueleto {
    background: linear-gradient(90deg, var(--borde) 25%, var(--lienzo) 50%, var(--borde) 75%);
    background-size: 200% 100%;
    animation: brillo 1.4s ease-in-out infinite;
    border-radius: var(--r-sm);
    height: 14px;
}
@keyframes brillo { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================ Barra de progreso ============================ */

.progreso { height: 6px; background: var(--borde); border-radius: 20px; overflow: hidden; }
.progreso__relleno { height: 100%; background: linear-gradient(90deg, var(--esmeralda), var(--lima)); transition: width 500ms ease; }
.progreso--fino { height: 4px; }

/* ============================ Menú de usuario ============================ */

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--marino-700), var(--esmeralda));
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    font-family: var(--fuente-titulo);
    flex: none;
}
.avatar--chico { width: 26px; height: 26px; font-size: .66rem; }

.menu-desplegable {
    position: absolute;
    right: 0; top: calc(100% + 8px);
    background: var(--papel);
    border: 1px solid var(--borde);
    border-radius: var(--r-md);
    box-shadow: var(--sombra-3);
    min-width: 232px;
    padding: 6px;
    z-index: 1050;
    display: none;
}
.menu-desplegable.abierto { display: block; }
.menu-desplegable a, .menu-desplegable button {
    display: flex; align-items: center; gap: 9px;
    width: 100%;
    padding: 8px 11px;
    border-radius: var(--r-sm);
    font-size: .86rem;
    color: var(--tinta);
    background: none; border: none; cursor: pointer;
    text-align: left;
}
.menu-desplegable a:hover, .menu-desplegable button:hover { background: var(--lienzo); color: var(--tinta); }
.menu-desplegable hr { border: none; border-top: 1px solid var(--borde); margin: 5px 0; }

.relativo { position: relative; }

/* ============================ Modo soporte ============================ */

.cinta-soporte {
    background: repeating-linear-gradient(45deg, var(--aviso), var(--aviso) 12px, #D9840F 12px, #D9840F 24px);
    color: #fff;
    padding: 7px 26px;
    font-size: .81rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}
.cinta-soporte a { color: #fff; text-decoration: underline; }

/* ============================ Utilidades ============================ */

.fila { display: flex; align-items: center; gap: 10px; }
.fila--entre { justify-content: space-between; }
.fila--fin { justify-content: flex-end; }
.fila--envolver { flex-wrap: wrap; }
.crecer { flex: 1; min-width: 0; }
.pila { display: flex; flex-direction: column; gap: 4px; }

.txt-gris { color: var(--gris); }
.txt-chico { font-size: .8rem; }
.txt-micro { font-size: .73rem; }
.txt-fuerte { font-weight: 600; }
.txt-derecha { text-align: right; }
.txt-centro { text-align: center; }
.truncar { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

.oculto { display: none !important; }

/* ============================ Acceso y registro ============================ */

.acceso {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
}

.acceso__lienzo {
    background: var(--marino-800);
    color: #fff;
    padding: 46px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

/* Retícula de replanteo: el fondo es un plano de lotes */
.acceso__lienzo::before {
    content: '';
    position: absolute;
    inset: -20%;
    background-image:
        linear-gradient(rgba(169, 220, 18, .09) 1px, transparent 1px),
        linear-gradient(90deg, rgba(169, 220, 18, .09) 1px, transparent 1px);
    background-size: 56px 56px;
    transform: rotate(-8deg);
    pointer-events: none;
}

.acceso__lienzo > * { position: relative; z-index: 1; }

.acceso__marca { display: flex; align-items: center; gap: 12px; }
.acceso__marca img { width: 46px; height: 46px; border-radius: 11px; }
.acceso__marca strong { font-family: var(--fuente-titulo); font-size: 1.3rem; letter-spacing: -.02em; }
.acceso__marca strong span { color: var(--lima); }

.acceso__lema { max-width: 470px; }
.acceso__lema h2 {
    font-size: 2.05rem;
    color: #fff;
    line-height: 1.16;
    letter-spacing: -.03em;
    margin-bottom: 14px;
}
.acceso__lema h2 em { font-style: normal; color: var(--lima); }
.acceso__lema p { color: #A9BCDC; font-size: .96rem; }

.acceso__puntos { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.acceso__punto {
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 20px;
    padding: 5px 13px;
    font-size: .8rem;
    color: #D6E2F5;
}

.acceso__panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--papel);
    overflow-y: auto;
}
.acceso__formulario { width: 100%; max-width: 430px; }
.acceso__formulario h1 { font-size: 1.5rem; margin-bottom: 6px; }
.acceso__formulario > p { color: var(--gris); margin: 0 0 26px; font-size: .89rem; }

/* ============================ Responsivo ============================ */

.abrir-lateral { display: none; }

@media (max-width: 1100px) {
    .rejilla--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rejilla--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .acceso { grid-template-columns: 1fr; }
    .acceso__lienzo { display: none; }
}

@media (max-width: 860px) {
    .lateral { transform: translateX(-100%); box-shadow: var(--sombra-3); }
    .lateral.abierto { transform: translateX(0); }
    .principal { margin-left: 0; }
    .abrir-lateral { display: inline-flex; }
    .contenido { padding: 16px 14px 60px; }
    .barra { padding: 10px 14px; }
    .rejilla--2, .rejilla--3, .rejilla--4 { grid-template-columns: 1fr; }
    .cinta-estados { flex-wrap: wrap; }
    .cinta-estados__tramo { min-width: 50%; }
    .velo { position: fixed; inset: 0; background: rgba(7, 18, 41, .45); z-index: 1035; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

@media print {
    .lateral, .barra, .boton, .abrir-lateral { display: none !important; }
    .principal { margin-left: 0; }
    body { background: #fff; }
    .tarjeta { box-shadow: none; border-color: #ccc; }
}

/* ==========================================================================
   Planos interactivos
   El lienzo es el protagonista: la interfaz se retira a los bordes.
   ========================================================================== */

.sin-desplazamiento { overflow: hidden; }

.taller { display: flex; flex-direction: column; height: 100vh; }

.taller__barra {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    background: var(--marino-800);
    color: #fff;
    flex: none;
}
.taller__barra .boton--fantasma { color: #C9D6EE; }
.taller__barra .boton--fantasma:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.taller__barra strong { color: #fff; }
.taller__barra .txt-gris { color: #8FA2C4; }

.taller__cuerpo { display: flex; flex: 1; min-height: 0; }

.taller__panel {
    width: 300px;
    flex: none;
    background: var(--papel);
    border-right: 1px solid var(--borde);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.taller__panel--derecha { border-right: none; border-left: 1px solid var(--borde); width: 320px; }
.taller__panel__seccion { padding: 13px 15px; border-bottom: 1px solid var(--borde); }
.taller__panel__lista { flex: 1; overflow-y: auto; min-height: 0; }

/* Lienzo del plano */
.lienzo {
    flex: 1;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(45deg, #EDF1F7 25%, transparent 25%),
        linear-gradient(-45deg, #EDF1F7 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #EDF1F7 75%),
        linear-gradient(-45deg, transparent 75%, #EDF1F7 75%);
    background-size: 22px 22px;
    background-position: 0 0, 0 11px, 11px -11px, -11px 0;
    background-color: #F7F9FC;
    cursor: grab;
    touch-action: none;
}
[data-tema="oscuro"] .lienzo { background-color: #0A1329; }
.lienzo.arrastrando { cursor: grabbing; }
.lienzo.dibujando { cursor: crosshair; }

.lienzo__mundo {
    position: absolute;
    top: 0; left: 0;
    transform-origin: 0 0;
    will-change: transform;
}
.lienzo__plano { display: block; max-width: none; user-select: none; -webkit-user-drag: none; }
.lienzo__capa { position: absolute; top: 0; left: 0; overflow: visible; }

.poligono {
    stroke: #FFFFFF;
    stroke-width: 1.5;
    stroke-linejoin: round;
    cursor: pointer;
    transition: fill-opacity 120ms ease, stroke-width 120ms ease;
    fill-opacity: .68;
}
.poligono:hover { fill-opacity: .92; stroke-width: 2.5; }
.poligono--apagado { fill-opacity: .12; stroke-opacity: .25; pointer-events: none; }
.poligono--activo { stroke: var(--marino-800); stroke-width: 3; fill-opacity: .95; }
.poligono--seleccionado { stroke: #FF6B00; stroke-width: 3; stroke-dasharray: 6 3; fill-opacity: .85; }
.poligono--sin-lote { fill: #98A2B3; stroke-dasharray: 4 3; }
.poligono--ia { stroke: #A9DC12; stroke-dasharray: 5 3; }

.poligono__etiqueta {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, .85);
    stroke-width: 3;
}

.vertice {
    fill: #FFFFFF;
    stroke: #FF6B00;
    stroke-width: 2;
    cursor: move;
}
.vertice:hover { fill: #FF6B00; }
.vertice--fantasma { fill: rgba(255, 107, 0, .35); stroke: none; cursor: copy; }

.trazo-activo { fill: rgba(255, 107, 0, .18); stroke: #FF6B00; stroke-width: 2; stroke-dasharray: 5 3; }

/* Controles flotantes sobre el lienzo */
.lienzo__controles {
    position: absolute;
    right: 14px; bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 5;
}
.lienzo__boton {
    width: 36px; height: 36px;
    border-radius: var(--r-sm);
    border: 1px solid var(--borde);
    background: var(--papel);
    color: var(--tinta);
    display: grid; place-items: center;
    cursor: pointer;
    box-shadow: var(--sombra-2);
    font-family: var(--fuente-dato);
    font-size: .9rem;
}
.lienzo__boton:hover { background: var(--lienzo); border-color: var(--borde-fuerte); }
.lienzo__boton svg { width: 17px; height: 17px; }

.lienzo__aviso {
    position: absolute;
    left: 50%; top: 14px;
    transform: translateX(-50%);
    background: var(--marino-800);
    color: #fff;
    padding: 7px 15px;
    border-radius: 20px;
    font-size: .82rem;
    box-shadow: var(--sombra-3);
    z-index: 6;
    display: none;
}
.lienzo__aviso.visible { display: block; }

.lienzo__escala {
    position: absolute;
    left: 14px; bottom: 14px;
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--borde);
    border-radius: var(--r-sm);
    padding: 4px 9px;
    font-family: var(--fuente-dato);
    font-size: .72rem;
    color: var(--gris);
    z-index: 5;
}

/* Leyenda de estados sobre el plano */
.leyenda {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.leyenda__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--borde);
    background: var(--papel);
    font-size: .76rem;
    cursor: pointer;
    user-select: none;
    transition: all var(--transicion);
}
.leyenda__item:hover { border-color: var(--borde-fuerte); }
.leyenda__item.apagado { opacity: .4; }
.leyenda__punto { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.leyenda__conteo { font-family: var(--fuente-dato); font-weight: 600; }

/* Ficha lateral del lote */
.ficha-lote {
    position: absolute;
    right: 14px; top: 14px;
    width: 310px;
    max-height: calc(100% - 90px);
    overflow-y: auto;
    background: var(--papel);
    border: 1px solid var(--borde);
    border-radius: var(--r-md);
    box-shadow: var(--sombra-3);
    padding: 16px;
    z-index: 7;
    display: none;
}
.ficha-lote.visible { display: block; }
.ficha-lote__cerrar {
    position: absolute; right: 8px; top: 8px;
    border: none; background: none; cursor: pointer;
    color: var(--gris); font-size: 1.1rem; line-height: 1;
    padding: 4px 8px; border-radius: var(--r-sm);
}
.ficha-lote__cerrar:hover { background: var(--lienzo); }

/* Lista de lotes del editor */
.lote-fila {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 15px;
    border-bottom: 1px solid var(--borde);
    cursor: pointer;
    font-size: .82rem;
}
.lote-fila:hover { background: var(--lienzo); }
.lote-fila--activa { background: rgba(255, 107, 0, .1); box-shadow: inset 3px 0 0 #FF6B00; }
.lote-fila--dibujado { opacity: .55; }
.lote-fila__color { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lote-fila__marca { margin-left: auto; font-size: .7rem; color: var(--esmeralda); font-weight: 600; }

.herramienta {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--borde);
    border-radius: var(--r-sm);
    background: var(--papel);
    cursor: pointer;
    font-size: .83rem;
    font-weight: 500;
    color: var(--tinta);
    margin-bottom: 6px;
    text-align: left;
}
.herramienta:hover { border-color: var(--borde-fuerte); background: var(--lienzo); }
.herramienta--activa { background: var(--marino-800); color: #fff; border-color: var(--marino-800); }
.herramienta svg { width: 16px; height: 16px; flex: none; }
.herramienta kbd {
    margin-left: auto;
    font-family: var(--fuente-dato);
    font-size: .68rem;
    background: rgba(0, 0, 0, .07);
    padding: 1px 5px;
    border-radius: 3px;
}
.herramienta--activa kbd { background: rgba(255, 255, 255, .18); }

@media (max-width: 900px) {
    .taller__panel { position: absolute; z-index: 20; height: 100%; box-shadow: var(--sombra-3); }
    .taller__panel--derecha { right: 0; }
    .ficha-lote { width: calc(100% - 28px); }
}

/* ==========================================================================
   Embudo comercial
   Las columnas son el estado del negocio; las tarjetas, personas concretas.
   ========================================================================== */

.tablero {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 12px;
    align-items: flex-start;
    scroll-snap-type: x proximity;
}

.columna {
    flex: 0 0 252px;
    background: var(--lienzo);
    border: 1px solid var(--borde);
    border-radius: var(--r-md);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 330px);
    scroll-snap-align: start;
}
[data-tema="oscuro"] .columna { background: rgba(255, 255, 255, .03); }

.columna__cabeza {
    padding: 10px 13px;
    border-bottom: 1px solid var(--borde);
    border-radius: var(--r-md) var(--r-md) 0 0;
    background: var(--papel);
    flex: none;
}

.columna__cuerpo {
    padding: 9px;
    overflow-y: auto;
    flex: 1;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: background var(--transicion);
}
.columna__cuerpo.encima {
    background: rgba(15, 169, 104, .1);
    box-shadow: inset 0 0 0 2px var(--esmeralda);
    border-radius: 0 0 var(--r-md) var(--r-md);
}

.ficha-prospecto {
    background: var(--papel);
    border: 1px solid var(--borde);
    border-radius: var(--r-sm);
    padding: 10px 11px;
    cursor: grab;
    box-shadow: var(--sombra-1);
    transition: box-shadow var(--transicion), transform var(--transicion), opacity var(--transicion);
}
.ficha-prospecto:hover { box-shadow: var(--sombra-2); border-color: var(--borde-fuerte); }
.ficha-prospecto.arrastrando { opacity: .4; transform: rotate(1.5deg); }
.ficha-prospecto.guardando { opacity: .55; pointer-events: none; }
.ficha-prospecto--vencida { border-left: 3px solid var(--aviso); }
.ficha-prospecto a { color: var(--tinta); }
.ficha-prospecto a:hover { color: var(--esmeralda); }

/* El nivel de interés se lee de un vistazo, sin ocupar una línea de texto */
.interes {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex: none;
    border: 2px solid transparent;
}
.interes--alto  { background: var(--esmeralda); }
.interes--medio { background: var(--lima); }
.interes--bajo  { background: transparent; border-color: var(--borde-fuerte); }

/* Ventana modal mínima */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(7, 18, 41, .5);
    display: none;
    place-items: center;
    z-index: 1060;
    padding: 20px;
}
.modal.abierto { display: grid; }
.modal__caja {
    background: var(--papel);
    border-radius: var(--r-lg);
    padding: 24px;
    max-width: 430px;
    width: 100%;
    box-shadow: var(--sombra-3);
}

/* Bitácora de contactos */
.bitacora { position: relative; padding-left: 26px; }
.bitacora::before {
    content: '';
    position: absolute;
    left: 8px; top: 6px; bottom: 6px;
    width: 2px;
    background: var(--borde);
}
.bitacora__item { position: relative; padding-bottom: 16px; }
.bitacora__punto {
    position: absolute;
    left: -24px; top: 3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--papel);
    border: 2px solid var(--borde-fuerte);
    display: grid; place-items: center;
    font-size: .62rem;
}
.bitacora__punto--llamada  { border-color: var(--info); color: var(--info); }
.bitacora__punto--whatsapp { border-color: var(--esmeralda); color: var(--esmeralda); }
.bitacora__punto--visita   { border-color: var(--lima); color: #6E8B1F; }
.bitacora__punto--cambio_etapa { border-color: var(--marino-700); background: var(--marino-700); color: #fff; }
.bitacora__punto--sistema  { border-color: var(--borde-fuerte); color: var(--gris-suave); }

@media (max-width: 860px) {
    .columna { flex-basis: 84vw; max-height: none; }
    .tablero { padding-bottom: 18px; }
}

/* ── Editor de planos: piezas nuevas ─────────────────────────────────────── */

.lienzo.empujando { cursor: grab; }
.lienzo.empujando:active { cursor: grabbing; }
.lienzo.dibujando { cursor: crosshair; }

/* El lienzo necesita alto propio: sin esto queda en cero y el plano "no aparece" */
.taller__cuerpo > .lienzo { min-height: 320px; }

.lienzo__cargando {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    background: var(--lienzo);
    z-index: 8;
    padding: 24px;
}

.pista {
    margin-top: 10px;
    padding: 9px 11px;
    background: var(--lima-suave);
    border-left: 3px solid var(--lima);
    border-radius: var(--r-sm);
    font-size: .78rem;
    color: #4F6B00;
    line-height: 1.45;
}
[data-tema="oscuro"] .pista { background: rgba(169, 220, 18, .12); color: var(--lima); }

.lote-fila { user-select: none; }
.lote-fila[draggable="true"] { cursor: grab; }
.lote-fila.arrastrando { opacity: .45; }
.lote-fila--dibujado { opacity: .6; }
.lote-fila__marca { margin-left: auto; color: var(--esmeralda); font-weight: 700; }

/* La figura seleccionada se arrastra entera desde dentro */
.poligono--seleccionado { cursor: move; }

/* Los vértices deben ser fáciles de agarrar también con el dedo */
.vertice { r: 7; }

/* ── Reportes ────────────────────────────────────────────────────────────── */

.embudo {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    min-height: 190px;
}
.embudo__paso {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    text-align: center;
    height: 190px;
}
.embudo__barra {
    width: 100%;
    border-radius: var(--r-sm) var(--r-sm) 0 0;
    min-height: 6px;
    transition: height 500ms cubic-bezier(.4, 0, .2, 1);
}
.embudo__valor {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 4px;
    order: -1;
}

.barras {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 180px;
}
.barras__col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    min-width: 26px;
}
.barras__barra {
    width: 100%;
    background: linear-gradient(180deg, var(--esmeralda), var(--marino-600));
    border-radius: var(--r-sm) var(--r-sm) 0 0;
    min-height: 4px;
    transition: height 500ms cubic-bezier(.4, 0, .2, 1);
}
.barras__col:hover .barras__barra { filter: brightness(1.15); }
.barras__valor { font-size: .72rem; color: var(--gris); margin-bottom: 4px; }

@media (max-width: 860px) {
    .embudo { overflow-x: auto; }
    .embudo__paso { min-width: 92px; }
    .barras__col { min-width: 20px; }
}

/* ── Ficha del lote sobre el plano ───────────────────────────────────────── */

.ficha-lote__mas { margin-top: 8px; }
.ficha-lote__mas-boton {
    width: 100%;
    background: none;
    border: none;
    border-top: 1px solid var(--borde);
    padding: 9px 0 4px;
    color: var(--gris);
    font-family: var(--fuente-texto);
    font-size: .78rem;
    cursor: pointer;
}
.ficha-lote__mas-boton:hover { color: var(--tinta); }
.ficha-lote__mas-lista { margin-top: 4px; }
