:root {
  --carbon: #2B2E33;
  --piedra: #7A7E82;
  --tostado: #B5A179;
  --crema: #F2EDE4;
  --papel: #FAF7F1;
  --suave: #565A60;
  --linea: #D9D2C4;
  --tostado-tinta: #76643C; /* Tostado oscurecido, legible como texto sobre crema */
  --bien: #1E5B26; --bien-f: #DCE9D5;
  --ojo: #7A5200; --ojo-f: #F8E7BF;
  --mal: #9C1C10; --mal-f: #F6D9D4;
  --titulo: "Fraunces", Georgia, serif;
  --texto: "Nunito Sans", system-ui, "Segoe UI", sans-serif;
  --riel: 13rem;
  --manchas: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260'%3E%3Cdefs%3E%3Cg id='r' fill='%23B5A179'%3E%3Cellipse cx='12' cy='4.6' rx='3.4' ry='2.1'/%3E%3Cellipse cx='19' cy='9.8' rx='3.1' ry='2' transform='rotate(72 19 9.8)'/%3E%3Cellipse cx='16.4' cy='18.2' rx='3.3' ry='2' transform='rotate(144 16.4 18.2)'/%3E%3Cellipse cx='7.6' cy='18.2' rx='2.9' ry='1.9' transform='rotate(216 7.6 18.2)'/%3E%3Cellipse cx='5' cy='9.8' rx='3.2' ry='2' transform='rotate(288 5 9.8)'/%3E%3Ccircle cx='12' cy='12' r='1.8'/%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23r' transform='translate(18 26) scale(1.7)'/%3E%3Cuse href='%23r' transform='translate(140 8) scale(1.1) rotate(20 12 12)'/%3E%3Cuse href='%23r' transform='translate(176 120) scale(2) rotate(-15 12 12)'/%3E%3Cuse href='%23r' transform='translate(64 150) scale(1.35) rotate(40 12 12)'/%3E%3Cuse href='%23r' transform='translate(118 216) scale(1.2) rotate(-35 12 12)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--crema); color: var(--carbon); font: 400 1rem/1.5 var(--texto); }
h1, h2, h3 { font-family: var(--titulo); font-weight: 500; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.5rem); font-variation-settings: "opsz" 144; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
a { color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--carbon); outline-offset: 2px; }
.riel :focus-visible, .acceso :focus-visible { outline-color: var(--crema); }

/* Marco */
.marco { display: grid; grid-template-columns: var(--riel) minmax(0, 1fr); min-height: 100dvh; }
.riel { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 2rem; padding: 1.5rem 1rem; background: var(--carbon) var(--manchas); background-blend-mode: soft-light; color: var(--crema); }
.marca img { width: 100%; max-width: 9.5rem; display: block; }
.riel ul { display: grid; gap: .15rem; }
.riel li a { display: block; padding: .5rem .75rem; border-radius: 4px; text-decoration: none; font-weight: 600; }
.riel li a:hover { background: rgba(242, 237, 228, .1); }
.riel li a[aria-current] { background: var(--tostado); color: var(--carbon); }
.quien { margin-top: auto; display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .875rem; }
.quien .enlace { color: var(--crema); }
.vista { padding: clamp(1rem, 3vw, 2.5rem); min-width: 0; }
.cabecera { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.ayuda { color: var(--suave); margin: 0 0 1rem; }
.vacio { color: var(--suave); padding: .5rem 0; margin: 0; }

/* Controles */
.boton { font: 700 .95rem var(--texto); padding: .65rem 1.1rem; border: 0; border-radius: 4px; background: var(--carbon); color: var(--crema); cursor: pointer; }
.boton:hover { background: #40444b; }
.enlace { font: 600 .875rem var(--texto); background: none; border: 0; padding: 0; text-decoration: underline; color: inherit; cursor: pointer; text-align: left; }
.peligro { color: var(--mal); }
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: .5rem .6rem; background: #fff; border: 1px solid #B9B2A4; border-radius: 4px; }
textarea { resize: vertical; }
.campo { display: grid; gap: .25rem; align-content: start; }
.campo > span { font-weight: 600; font-size: .9rem; }
.campo small { color: var(--suave); }
.pildora { display: inline-block; padding: .05rem .5rem; border-radius: 999px; background: var(--crema); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.pildora.mal { background: var(--mal-f); color: var(--mal); }
.pildora.ojo { background: var(--ojo-f); color: var(--ojo); }
.pildora.bien { background: var(--bien-f); color: var(--bien); }

/* Hoy: la cordillera ocupa todo el ancho de la vista y es lo único grande */
.vista-hoy { padding: 0; }
.cumbre { background: var(--carbon); color: var(--crema); padding: clamp(1.25rem, 4vw, 3rem) clamp(1rem, 3vw, 2.5rem) 0; }
.cumbre-texto p { margin: .5rem 0 0; color: #D8D2C6; }
.cordillera { display: block; width: 100%; height: auto; margin-top: -2.5rem; overflow: visible; }
.cerro-fondo { fill: #383C42; }
.cerro-subido { fill: var(--tostado); }
.cresta { fill: none; stroke: var(--tostado); stroke-width: 1.5; }
.marca-proyeccion { stroke: var(--crema); stroke-width: 1.5; stroke-dasharray: 3 5; }
.paso { fill: var(--crema); opacity: .7; }
.rotulo { fill: #D8D2C6; font: 600 13px var(--texto); }
.rotulo-cumbre { fill: var(--crema); font: 500 20px var(--titulo); }
.huella-dibujo { fill: var(--crema); stroke: var(--carbon); stroke-width: 1.5; paint-order: stroke; }
.cifras { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 calc(-1 * clamp(1rem, 3vw, 2.5rem)); background: var(--tostado); color: var(--carbon); }
.cifras div { padding: .75rem clamp(1rem, 3vw, 2.5rem); }
.cifras dt { font-size: .875rem; }
.cifras dd { margin: 0; font: 500 1.35rem var(--titulo); }
.dos-columnas { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: clamp(1.5rem, 4vw, 3rem); padding: clamp(1.25rem, 3vw, 2.5rem); }
.dos-columnas h2 { margin-bottom: .75rem; }
.accion { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto; gap: .75rem; align-items: start; width: 100%; padding: .7rem 0; background: none; border: 0; border-top: 1px solid var(--linea); font: inherit; color: inherit; text-align: left; cursor: pointer; }
.accion:hover strong { text-decoration: underline; }
.accion-fecha { font: 500 1.05rem var(--titulo); }
.accion-texto { display: grid; }
.accion-texto span { color: var(--suave); font-size: .92rem; }
.barras a { display: grid; grid-template-columns: 9rem minmax(0, 1fr) 1.5rem; gap: .5rem; align-items: center; padding: .3rem 0; text-decoration: none; font-size: .92rem; }
.barra { height: .6rem; background: var(--linea); border-radius: 0 3px 3px 0; }
.barra i { display: block; height: 100%; background: var(--carbon); border-radius: 0 3px 3px 0; }
.barra-num { text-align: right; font-weight: 700; }

/* Embudo */
.tablero { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(14rem, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: 1rem; scroll-snap-type: x proximity; }
.columna { scroll-snap-align: start; background: var(--papel); border-top: 3px solid var(--piedra); padding: .6rem; min-height: 22rem; display: flex; flex-direction: column; gap: .5rem; }
.columna-propuesta, .columna-negociacion { border-top-color: var(--tostado); }
.columna-ganado { border-top-color: var(--bien); }
.columna-perdido { border-top-color: var(--mal); background: none; }
.columna.encima { background: #EFE6D2; }
.columna header h2 { font-size: 1.05rem; }
.columna header span { color: var(--suave); font-size: .85rem; }
.ficha { display: grid; gap: .2rem; justify-items: start; width: 100%; padding: .6rem; background: #fff; border: 1px solid var(--linea); border-radius: 4px; font: inherit; color: inherit; text-align: left; cursor: grab; }
.ficha:hover { border-color: var(--carbon); }
.ficha-valor { font: 500 1.05rem var(--titulo); }
.ficha-accion { color: var(--suave); font-size: .85rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* Tablas */
.filtros { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filtros input { flex: 1 1 16rem; width: auto; }
.filtros select { flex: 0 1 13rem; width: auto; }
.tabla-marco { overflow-x: auto; background: var(--papel); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: .6rem .75rem; border-bottom: 1px solid var(--linea); text-align: left; vertical-align: top; }
thead th { font-weight: 700; border-bottom: 2px solid var(--carbon); white-space: nowrap; }
tbody th { font-weight: 600; }
.vista-clientes tbody tr { cursor: pointer; }
.vista-clientes tbody tr:hover { background: #F0E9DB; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.avance { display: inline-block; width: 5rem; height: .5rem; background: var(--linea); vertical-align: middle; }
.avance i { display: block; height: 100%; background: var(--tostado); }

/* Formularios */
.meta, .ajustes { display: grid; gap: 1.75rem; max-width: 62rem; }
.meta section h2 { margin-bottom: .6rem; }
.formulario { display: grid; gap: 1rem; padding: 1.25rem; background: var(--papel); justify-items: start; }
.formulario > .rejilla, .formulario > .rejilla-3 { width: 100%; }
.formulario.angosto { max-width: 28rem; }
.formulario.angosto .campo, .formulario form { width: 100%; }
.formulario form { display: grid; gap: .75rem; justify-items: start; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .75rem; }
.rejilla-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1.25rem; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: .6rem; align-content: start; }
legend { font: 500 1.05rem var(--titulo); padding: 0 0 .4rem; }
.equipo { width: 100%; }
.equipo li { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--linea); }

/* Ficha lateral */
dialog.panel-lateral { margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(36rem, 100vw); max-width: 100vw; border: 0; padding: 0; background: var(--papel); color: var(--carbon); }
dialog::backdrop { background: rgba(43, 46, 51, .55); }
.panel-lateral[open] { animation: entrar 200ms cubic-bezier(.2, .8, .2, 1); }
@keyframes entrar { from { transform: translateX(2rem); opacity: 0; } }
.panel-lateral > header { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; background: var(--carbon); color: var(--crema); }
.cerrar { background: none; border: 0; color: var(--crema); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: .1rem .4rem; }
.ficha-cliente { display: grid; gap: .9rem; padding: 1.25rem; }
.ficha-cliente h3 { padding-top: .6rem; border-top: 1px solid var(--linea); }
.ficha-cliente h3:first-child { border-top: 0; padding-top: 0; }
.ficha-cliente footer { display: flex; justify-content: space-between; align-items: center; position: sticky; bottom: 0; padding: .75rem 0; background: var(--papel); }

/* Acceso */
.acceso { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; background: var(--carbon) var(--manchas); background-blend-mode: soft-light; color: var(--crema); }
.acceso form { width: min(24rem, 100%); display: grid; gap: 1rem; }
.acceso img { width: 11rem; }
.acceso .campo small { color: #D8D2C6; }
.acceso input { border-color: var(--piedra); color: var(--carbon); }
.acceso .boton { background: var(--tostado); color: var(--carbon); }
.acceso .boton:hover { background: #C6B48E; }
.error-acceso { margin: 0; color: #FFC9C0; font-weight: 600; }
.error-acceso:empty { display: none; }

#aviso { position: fixed; left: 50%; bottom: 1.25rem; transform: translate(-50%, 1rem); opacity: 0; pointer-events: none; z-index: 10; max-width: calc(100vw - 2rem); padding: .6rem 1rem; border-radius: 4px; background: var(--carbon); color: var(--crema); font-weight: 600; transition: opacity 180ms, transform 180ms; }
#aviso.visible { opacity: 1; transform: translate(-50%, 0); }
#aviso.error { background: var(--mal); color: #fff; }

@media (max-width: 820px) {
  .marco { grid-template-columns: minmax(0, 1fr); padding-bottom: 3.5rem; }
  .riel { position: fixed; inset: auto 0 0 0; height: auto; z-index: 5; padding: 0; flex-direction: row; background-image: none; }
  .marca, .quien { display: none; }
  .riel ul { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; gap: 0; }
  .riel li a { text-align: center; padding: .75rem .1rem; font-size: .78rem; border-radius: 0; }
  .cordillera { margin-top: .5rem; }
  .cifras { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dos-columnas { grid-template-columns: minmax(0, 1fr); }
  .tablero { grid-auto-columns: 78vw; }
  .barras a { grid-template-columns: 8rem minmax(0, 1fr) 1.5rem; }
}

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