/* Planta Corvalta. Naranja = lo que hizo el sistema. El resto de la interfaz va en los grises del panel de Falince. */
:root {
  --negro: #0a0b0c;
  --panel: #121314;
  --panel-2: #1a1b1d;
  --linea: #2a2c2f;
  --texto: #ecebe7;
  --tenue: #a3a4a2;
  --apagado: #6f7174;
  --naranja: #ff7a1c;
  --bien: #7cc9a0;
  --mal: #e58a8a;
  --crema: #f2eee7;
  --letra: "Figtree", system-ui, sans-serif;
  --stencil: "Saira Stencil One", Impact, sans-serif;
  --suave: cubic-bezier(.22, 1, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--negro); color: var(--texto); font-family: var(--letra); -webkit-font-smoothing: antialiased; overflow: hidden; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--crema); outline-offset: 2px; }
[hidden] { display: none !important; }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.app { position: relative; height: 100vh; height: 100svh; overflow: hidden; }
.escenario { position: absolute; inset: 0; background: var(--negro); }
#lienzo { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.2s; touch-action: none; }
.app[data-listo] #lienzo { opacity: 1; }

/* ---------- Botones ---------- */
.boton { display: inline-flex; align-items: center; justify-content: center; padding: 15px 24px; border: 1px solid transparent; border-radius: 999px; background: var(--crema); color: var(--negro); font-weight: 700; font-size: .95rem; line-height: 1; text-decoration: none; transition: transform .3s var(--suave), background .25s, opacity .25s; }
.boton:hover:not(:disabled) { background: #fff; transform: translateY(-1px); }
.boton:disabled { opacity: .35; cursor: default; }
.boton.elegido { opacity: 1; background: var(--naranja); color: var(--negro); }
.boton--borde { background: transparent; color: var(--texto); border-color: #4a4c50; }
.boton--borde:hover:not(:disabled) { background: rgb(255 255 255 / .08); }
.boton--chico { padding: 11px 16px; font-size: .86rem; }
.enlace { padding: 0; border: 0; background: none; color: var(--tenue); font-size: .86rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.enlace:hover { color: var(--texto); }

/* ---------- Barra ---------- */
.barra { position: absolute; z-index: 5; top: 16px; left: 20px; right: 20px; display: flex; align-items: center; gap: 20px; pointer-events: none; }
.barra > * { pointer-events: auto; }
.barra__marca { display: inline-flex; align-items: flex-start; gap: 2px; padding: 8px 12px; margin: -8px 0 -8px -12px; border-radius: 999px; background: rgb(10 11 12 / .78); font-weight: 800; font-size: 1.12rem; letter-spacing: -.02em; line-height: 1; text-decoration: none; }
.barra__marca img { height: .62em; width: auto; }
.barra__aviso { color: var(--tenue); font-size: .8rem; }
.barra__boton { padding: 7px 12px; border: 1px solid var(--linea); border-radius: 999px; background: rgb(18 19 20 / .8); color: var(--tenue); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.barra__boton:hover { color: var(--texto); border-color: #4a4c50; }
.barra__boton[aria-pressed="true"] { color: var(--texto); border-color: var(--naranja); }
.app:not([data-estado="inicio"]) .barra { right: 444px; }
.app:not([data-estado="inicio"]) .barra__aviso { display: none; }
.sistema__aviso { padding: 9px 16px; border-top: 1px solid var(--linea); color: var(--apagado); font-size: .74rem; }
.barra #sonido { margin-left: auto; }

/* ---------- Portada ---------- */
.escenario::before { content: ""; position: absolute; z-index: 1; inset: 0 auto 0 0; width: min(760px, 62%); background: linear-gradient(90deg, rgb(10 11 12 / .94) 0%, rgb(10 11 12 / .86) 62%, transparent 100%); pointer-events: none; transition: opacity .8s; }
.app:not([data-estado="inicio"]) .escenario::before { opacity: 0; }
.etapas { display: flex; flex-wrap: wrap; gap: 4px 0; margin-top: 16px; color: #c4c4c0; font-size: .86rem; font-weight: 600; }
.etapas li { display: flex; align-items: center; white-space: nowrap; }
.etapas li:not(:last-child)::after { content: ""; width: 18px; height: 1px; margin: 0 7px; background: #5a5c60; }
.portada__dura { margin-top: 10px; color: var(--tenue); font-size: .86rem; line-height: 1.42; max-width: 52ch; }
.portada { position: absolute; z-index: 4; left: clamp(20px, 5vw, 72px); top: 50%; transform: translateY(-50%); width: min(540px, calc(100% - 40px)); }
.portada h1 { font-size: clamp(2.5rem, 4.6vw, 4.1rem); line-height: 1; letter-spacing: -.04em; font-weight: 700; text-wrap: balance; }
.portada__bajada { margin-top: 18px; color: #c4c4c0; font-size: 1.05rem; line-height: 1.5; max-width: 48ch; }
.pedido { margin-top: 26px; display: flex; flex-direction: column; gap: 10px; padding: 10px; border: 1px solid #3a3c40; border-radius: 18px; background: rgb(14 15 16 / .86); }
.pedido textarea { width: 100%; resize: none; padding: 8px 10px; border: 0; outline: 0; background: none; font-size: 1.04rem; line-height: 1.4; }
.pedido textarea::placeholder { color: var(--apagado); }
.pedido:focus-within { border-color: var(--tenue); }
.pedido .boton { align-self: flex-end; }
.atajos { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.atajos__titulo { width: 100%; color: var(--tenue); font-size: .8rem; }
.atajo { padding: 8px 12px; border: 1px solid var(--linea); border-radius: 12px; background: rgb(22 23 25 / .85); color: #c9c9c5; font-size: .8rem; line-height: 1.3; text-align: left; transition: border-color .2s, color .2s; }
.atajo:hover { border-color: var(--tenue); color: var(--texto); }
.app:not([data-estado="inicio"]) .portada { display: none; }

/* ---------- Rótulo de la estación ---------- */
.rotulo { position: absolute; z-index: 4; left: 24px; bottom: 24px; width: min(390px, calc(100% - 468px)); min-width: 280px; }
.rotulo p { color: var(--tenue); font-size: .84rem; font-weight: 600; }
.rotulo h2 { margin: 2px 0 12px; font: 400 clamp(2rem, 3.4vw, 3rem)/1.02 var(--stencil); letter-spacing: .01em; text-shadow: 0 2px 22px rgb(0 0 0 / .8); }
.rotulo ul { display: grid; gap: 7px; padding: 12px 14px; border: 1px solid var(--linea); border-radius: 12px; background: rgb(14 15 16 / .86); }
.rotulo ul:empty { display: none; }
.rotulo li { position: relative; padding-left: 24px; color: var(--tenue); font-size: .9rem; line-height: 1.3; }
.rotulo li::before { content: ""; position: absolute; left: 0; top: 1px; width: 15px; height: 15px; border: 1px solid #55575a; border-radius: 4px; transition: background .2s, border-color .2s; }
.rotulo li.ok { color: var(--texto); }
.rotulo li.ok::before { background: var(--naranja); border-color: var(--naranja); }
.rotulo li.ok::after { content: ""; position: absolute; left: 5px; top: 3px; width: 5px; height: 9px; border: solid var(--negro); border-width: 0 2px 2px 0; transform: rotate(42deg); }

/* ---------- Panel del sistema ---------- */
.sistema { position: absolute; z-index: 6; top: 12px; right: 12px; bottom: 12px; width: 420px; display: none; flex-direction: column; border: 1px solid var(--linea); border-radius: 16px; background: var(--panel); overflow: hidden; }
.app:not([data-estado="inicio"]) .sistema { display: flex; }
.sistema__cabeza { padding: 15px 16px 12px; border-bottom: 1px solid var(--linea); }
.sistema__titulo { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sistema__titulo h2 { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.sistema__controles { display: flex; gap: 6px; }
.estado { min-height: 1.35em; margin-top: 10px; color: var(--texto); font-size: .9rem; font-weight: 600; line-height: 1.35; }
.estado[data-turno] { color: var(--negro); margin-left: -6px; margin-right: -6px; padding: 5px 8px; border-radius: 8px; background: var(--crema); }
.estado:not([data-turno])::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--naranja); vertical-align: 1px; animation: late 1.2s ease-in-out infinite; }
.app[data-pausa] .estado::before { animation: none; background: var(--apagado); }
@keyframes late { 50% { opacity: .3; } }
.etapas--vivas { margin-top: 8px; color: var(--apagado); font-size: .74rem; }
.etapas--vivas li:not(:last-child)::after { width: 8px; margin: 0 4px; }
.etapas--vivas li.hecha { color: var(--naranja); }
.etapas--vivas li.actual { color: var(--texto); }
.riel { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin-top: 8px; }
.paso { height: 16px; padding: 0; border: 0; background: none; position: relative; }
.paso::after { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 4px; border-radius: 2px; background: #33353a; transition: background .3s; }
.paso:hover::after { background: var(--tenue); }
.paso.hecho::after { background: var(--naranja); }
.paso.actual::after { background: var(--crema); }
.contadores { display: flex; gap: 16px; margin-top: 6px; color: var(--tenue); font-size: .8rem; }
.contadores b { color: var(--texto); font-weight: 700; font-variant-numeric: tabular-nums; }

.feed { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; scrollbar-color: #33353a transparent; }
.sistema__pie { display: none; justify-content: space-between; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--linea); }
.app:not([data-estado="inicio"]) .sistema__pie { display: flex; }
.sistema__pie a { display: none; }
.app[data-estado="final"] .sistema__pie a, .app[data-estado="libre"] .sistema__pie a { display: inline; }
.sistema__pie { justify-content: flex-end; }
.app[data-estado="final"] .sistema__pie, .app[data-estado="libre"] .sistema__pie { justify-content: space-between; }
.efecto { margin: 0 0 9px; color: var(--tenue); font-size: .8rem; line-height: 1.4; }

.msj { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: .92rem; line-height: 1.38; animation: entra .35s var(--suave) both; }
.msj small { display: block; margin-top: 3px; color: var(--apagado); font-size: .74rem; }
.msj--cliente { align-self: flex-end; background: #2a2c2f; border-bottom-right-radius: 4px; overflow-wrap: anywhere; }
.msj--agente { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--linea); border-bottom-left-radius: 4px; }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } }

.reg { padding: 12px 13px; border: 1px solid var(--linea); border-radius: 12px; background: var(--panel-2); animation: entra .35s var(--suave) both; }
.reg h3 { margin-bottom: 9px; font-size: .92rem; font-weight: 700; }
.reg--vivo { border-color: #5a3a22; }
.reg--decision { border-color: var(--crema); }
.datos { display: grid; gap: 5px; }
.datos > div { display: flex; justify-content: space-between; gap: 14px; font-size: .86rem; }
.datos dt { color: var(--tenue); }
.datos dd { text-align: right; font-weight: 600; }
.datos em { color: var(--apagado); font-style: normal; font-weight: 500; font-size: .78rem; }
.lineas { display: grid; gap: 5px; font-size: .84rem; }
.lineas li { display: flex; justify-content: space-between; gap: 14px; color: var(--tenue); }
.lineas li span:last-child { color: var(--texto); font-variant-numeric: tabular-nums; white-space: nowrap; }
.total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--linea); font-size: .86rem; }
.total strong { color: var(--naranja); font-size: 1.32rem; font-variant-numeric: tabular-nums; }
.nota { margin: 8px 0; color: var(--tenue); font-size: .8rem; line-height: 1.4; }
.turno { margin: 12px 0 9px; font-size: .96rem; font-weight: 700; }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; }
.acciones .boton { flex: 1 1 auto; padding: 13px 14px; font-size: .86rem; white-space: nowrap; }
.medidor { height: 6px; margin-top: 10px; border-radius: 3px; background: #33353a; overflow: hidden; }
.medidor i { display: block; height: 100%; background: var(--naranja); }
.ofertas { display: grid; gap: 7px; }
.oferta { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 12px; border: 1px solid #3a3c40; border-radius: 10px; background: var(--panel); text-align: left; transition: border-color .2s; }
.oferta:hover:not(:disabled) { border-color: var(--crema); }
.oferta:disabled { opacity: .45; cursor: default; }
.oferta.elegido { opacity: 1; border-color: var(--naranja); }
.oferta__nombre { font-size: .9rem; font-weight: 700; }
.oferta strong { font-size: .9rem; text-align: right; font-variant-numeric: tabular-nums; }
.oferta__nota, .oferta__fecha { color: var(--tenue); font-size: .78rem; }
.oferta__fecha { text-align: right; }
.marca { grid-column: 1 / -1; margin-top: 3px; font-size: .76rem; font-weight: 600; }
.marca--si { color: var(--bien); }
.marca--no { color: var(--mal); }
.avance { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.avance li { padding: 8px 6px; border: 1px solid var(--linea); border-radius: 8px; color: var(--apagado); font-size: .76rem; text-align: center; font-weight: 600; }
.avance li.actual { color: var(--texto); border-color: var(--crema); }
.avance li.ok { color: var(--negro); border-color: var(--naranja); background: var(--naranja); }
.docs { display: grid; gap: 5px; font-size: .84rem; color: var(--tenue); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpis div { padding: 9px 10px; border: 1px solid var(--linea); border-radius: 9px; }
.kpis strong { display: block; font-size: 1.4rem; line-height: 1.1; }
.kpis span { color: var(--tenue); font-size: .76rem; }
.responder { display: flex; gap: 7px; margin-top: 8px; }
.responder input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid #3a3c40; border-radius: 10px; background: var(--panel); font-size: 16px; outline: 0; }
.responder input:focus { border-color: var(--tenue); }
.feed > .atajos { margin-top: -4px; }

/* ---------- Cierre ---------- */
.cierre { position: absolute; z-index: 7; left: 24px; bottom: 24px; width: min(500px, calc(100% - 492px)); min-width: 320px; padding: 22px; border: 1px solid #3a3c40; border-radius: 16px; background: #0f1011; animation: entra .7s var(--suave) both; }
.cierre h2 { font-size: clamp(1.55rem, 2.3vw, 2.05rem); line-height: 1.05; letter-spacing: -.03em; }
.cierre__pedido { margin-top: 8px; color: var(--tenue); font-size: .9rem; line-height: 1.4; }
.cierre__datos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 18px; margin: 16px 0; }
.cierre__datos dt { color: var(--tenue); font-size: .78rem; }
.cierre__datos dd { font-size: 1.28rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cierre__texto { margin-bottom: 14px; color: var(--tenue); font-size: .82rem; line-height: 1.4; }
.cierre__acciones { display: flex; flex-wrap: wrap; gap: 8px; }
.cierre__acciones .boton { flex: 1 1 auto; padding: 14px 16px; font-size: .88rem; }
.cierre__mas { display: flex; gap: 18px; margin-top: 12px; }

.globo { position: fixed; z-index: 20; left: 0; top: 0; padding: 6px 10px; border-radius: 8px; background: var(--crema); color: var(--negro); font-size: .8rem; font-weight: 700; pointer-events: none; }

/* ---------- Ficha y hoja ---------- */
dialog { color: inherit; }
dialog::backdrop { background: rgb(0 0 0 / .62); }
.ficha { width: min(560px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 24px; border: 1px solid #3a3c40; border-radius: 16px; background: var(--panel); }
.ficha h2 { font: 400 2rem/1.05 var(--stencil); }
.ficha h3 { margin-bottom: 4px; color: var(--tenue); font-size: .82rem; font-weight: 600; }
.ficha p { font-size: .95rem; line-height: 1.45; }
.ficha__hace { margin: 10px 0 16px; }
.ficha__comparar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.ficha__comparar > div { padding: 12px; border: 1px solid var(--linea); border-radius: 10px; }
.ficha__comparar > div:last-child { border-color: #5a3a22; }
.ficha .boton { margin-top: 18px; }

.hoja { width: min(620px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0; border: 0; border-radius: 10px; background: #fff; color: #17181a; }
.hoja__papel { padding: 34px; }
.hoja header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 14px; border-bottom: 2px solid #17181a; font-size: .86rem; text-align: right; }
.hoja__marca { font: 400 2rem/1 var(--stencil); text-align: left; }
.hoja__pedido { margin: 16px 0; font-size: .95rem; line-height: 1.4; }
.hoja table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.hoja td { padding: 7px 0; border-bottom: 1px solid #e0e0dd; }
.hoja td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hoja__total td { border-bottom: 0; padding-top: 12px; font-size: 1.15rem; font-weight: 800; }
.hoja__nota { margin-top: 20px; color: #6a6b6c; font-size: .76rem; line-height: 1.4; }
.hoja__acciones { display: flex; gap: 8px; padding: 0 34px 26px; }
.hoja .boton { background: #17181a; color: #fff; }
.hoja .boton:hover:not(:disabled) { background: #000; }
.hoja .boton--borde { background: none; color: #17181a; border-color: #b6b6b2; }
.hoja .boton--borde:hover:not(:disabled) { background: #eee; }

/* ---------- Pantallas angostas: la misma experiencia, apilada ---------- */
@media (max-width: 899px) {
  .escenario { bottom: auto; height: 44vh; height: 44svh; }
  .app:not([data-estado="inicio"]) .sistema { top: 44vh; top: 44svh; left: 0; right: 0; bottom: 0; width: auto; border-width: 1px 0 0; border-radius: 14px 14px 0 0; }
  .app:not([data-estado="inicio"]) .barra { right: 20px; }
  .barra { top: 12px; left: 14px; right: 14px; gap: 10px; flex-wrap: wrap; }
  .barra__aviso { order: 3; width: 100%; font-size: .74rem; }
  .app:not([data-estado="inicio"]) .barra__aviso { display: none; }
  .portada { position: fixed; top: auto; bottom: max(16px, env(safe-area-inset-bottom)); left: 16px; width: calc(100% - 32px); transform: none; }
  .portada h1 { font-size: clamp(2.05rem, 9.4vw, 2.9rem); }
  .escenario::before { display: none; }
  .portada__bajada { margin-top: 8px; font-size: .92rem; line-height: 1.36; }
  .portada .etapas { margin-top: 9px; font-size: .74rem; }
  .portada .etapas li:not(:last-child)::after { width: 8px; margin: 0 4px; }
  .portada__dura { margin-top: 6px; font-size: .78rem; }
  .pedido { margin-top: 10px; }
  .estado { margin-top: 6px; font-size: .84rem; }
  .pedido textarea { font-size: 16px; }
  .atajos__titulo { display: none; }
  #ejemplos { flex-wrap: nowrap; overflow-x: auto; margin-right: -16px; padding-right: 16px; scrollbar-width: none; }
  #ejemplos .atajo { flex: 0 0 74%; }
  .rotulo { left: 12px; right: 12px; bottom: 10px; width: auto; min-width: 0; }
  .rotulo p { font-size: .76rem; }
  .rotulo h2 { margin: 0 0 6px; font-size: 1.55rem; }
  .rotulo ul { padding: 7px 10px; }
  .rotulo li { display: none; font-size: .82rem; }
  .rotulo li:last-child { display: block; }
  .sistema__cabeza { padding: 11px 14px 8px; }
  .feed { padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); }
  .cierre { position: fixed; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); width: auto; min-width: 0; max-height: calc(100% - 20px); overflow-y: auto; padding: 18px; }
  .ficha__comparar { grid-template-columns: 1fr; }
  .hoja__papel { padding: 22px; }
  .hoja__acciones { padding: 0 22px 20px; }
}

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

/* Solo se imprime el presupuesto */
@media print {
  body { background: #fff; overflow: visible; }
  .app, .globo, .hoja__acciones { display: none !important; }
  dialog::backdrop { display: none; }
  .hoja { position: static; width: 100%; max-height: none; border-radius: 0; }
}
