:root {
  --fondo: #f6f5f2;
  --papel: #ffffff;
  --tinta: #1c1d1f;
  --suave: #6a6d73;
  --linea: #e4e2dc;
  --acento: #1f5f5b;
  --acento-fuerte: #174a47;
  --acento-tenue: #e7f0ef;
  --ambar: #b7791f;
  --ambar-tenue: #fbf3e2;
  --rojo: #b3392f;
  --rojo-tenue: #fbeceb;
  --verde: #2f7d4f;
  --azul: #2c5f9e;
  --gris: #a3a5aa;
  --radio: 12px;
  --sombra: 0 1px 2px rgba(20, 20, 20, .04), 0 6px 24px rgba(20, 20, 20, .05);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--fondo); color: var(--tinta); -webkit-font-smoothing: antialiased; }
h2 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--suave); margin: 0 0 .75rem; font-weight: 600; }
h3 { margin: 0 0 .5rem; font-size: 1.1rem; }
p { margin: 0 0 .75rem; }
small { color: var(--suave); }
a { color: var(--acento); text-underline-offset: 2px; }
.suave { color: var(--suave); }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hueco { flex: 1; }
.error { color: var(--rojo); background: var(--rojo-tenue); border-radius: 8px; padding: .5rem .75rem; font-size: .9rem; }

.marca { font-weight: 700; letter-spacing: -.01em; font-size: 1.1rem; }
.tarjeta { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); }

/* Botones y campos */
.boton {
  font: inherit; font-weight: 550; padding: .55rem .95rem; min-height: 40px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--linea); background: var(--papel); color: var(--tinta); transition: background .15s, border-color .15s, opacity .15s;
}
.boton:hover { border-color: #cfccc4; background: #fbfaf8; }
.boton:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
.boton.principal { background: var(--acento); border-color: var(--acento); color: #fff; }
.boton.principal:hover { background: var(--acento-fuerte); }
.boton.peligro { color: var(--rojo); border-color: #e6c5c1; }
.boton.peligro:hover { background: var(--rojo-tenue); }
.boton.fantasma { border-color: transparent; background: transparent; color: var(--suave); padding-inline: .6rem; }
.boton.fantasma:hover { background: #ecebe6; color: var(--tinta); }
.boton:disabled { opacity: .55; cursor: progress; }
input, textarea, select {
  font: inherit; color: inherit; width: 100%; padding: .6rem .75rem; border: 1px solid var(--linea); border-radius: 10px; background: var(--papel);
}
label { display: block; font-size: .9rem; font-weight: 550; margin-bottom: .9rem; }
label input, label textarea { margin-top: .35rem; font-weight: 400; }
.codigo { font-variant-numeric: tabular-nums; letter-spacing: .35em; font-size: 1.35rem; text-align: center; }

/* Entrada */
.login { min-height: 100%; display: grid; place-items: center; padding: 1.25rem; }
.login-caja { width: min(100%, 380px); padding: 1.75rem; }
.login-caja .marca { font-size: 1.4rem; margin-bottom: .35rem; }
.login-caja .boton { width: 100%; margin-top: .25rem; }

/* Panel */
.panel { height: 100dvh; display: flex; flex-direction: column; }
.barra {
  display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top));
  background: var(--papel); border-bottom: 1px solid var(--linea);
}
.selector { margin: 0; }
.selector select { min-width: 9rem; padding: .45rem .6rem; font-weight: 550; }
.pestanas { display: none; }
.cuerpo { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 1rem; padding: 1rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.columna { min-height: 0; display: flex; flex-direction: column; }

/* Chat */
.chat { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; }
.mensajes { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.vacio { margin: auto; text-align: center; color: var(--suave); max-width: 30ch; }
.msg { max-width: min(46rem, 88%); padding: .65rem .9rem; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .quien { display: block; font-size: .72rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--suave); margin-bottom: .15rem; }
.msg.jeff { align-self: flex-end; background: var(--acento); color: #fff; border-bottom-right-radius: 4px; }
.msg.jeff .quien { color: rgba(255, 255, 255, .7); }
.msg.sergy { align-self: flex-start; background: #f1f0ec; border-bottom-left-radius: 4px; }
.msg.nova { align-self: flex-start; background: var(--acento-tenue); border: 1px solid #cfe1df; border-bottom-left-radius: 4px; }
.msg.sistema { align-self: center; background: var(--ambar-tenue); color: #6d4a10; font-size: .9rem; }
.msg.pensando { color: var(--suave); font-style: italic; }
.redactor { border-top: 1px solid var(--linea); padding: .75rem; padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
.redactor textarea { resize: none; border-color: transparent; background: #f6f5f2; }
.redactor-pie { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.interruptor { display: inline-flex; align-items: center; gap: .5rem; margin: 0; cursor: pointer; font-weight: 500; }
.interruptor input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pista { width: 38px; height: 22px; border-radius: 999px; background: #d5d3cc; position: relative; transition: background .15s; flex: none; }
.pista::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.interruptor input:checked + .pista { background: var(--acento); }
.interruptor input:checked + .pista::after { transform: translateX(16px); }
.interruptor input:focus-visible + .pista { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Tareas */
.tareas { overflow-y: auto; padding-right: .15rem; }
.lista { display: flex; flex-direction: column; gap: .5rem; }
.tarea {
  display: grid; grid-template-columns: auto 1fr; gap: .15rem .7rem; align-items: center; text-align: left; width: 100%;
  font: inherit; color: inherit; padding: .75rem .9rem; background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); cursor: pointer;
}
.tarea:hover { border-color: #cfccc4; }
.tarea.elegida { border-color: var(--acento); box-shadow: 0 0 0 1px var(--acento); }
.tarea .titulo { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tarea .meta { grid-column: 2; font-size: .82rem; color: var(--suave); }
.luz { width: 12px; height: 12px; border-radius: 50%; background: var(--gris); flex: none; }
.luz.toca { background: var(--ambar); }
.luz.trabaja { background: var(--azul); animation: pulso 1.4s ease-in-out infinite; }
.luz.bien { background: var(--verde); }
.luz.mal { background: var(--rojo); }
@keyframes pulso { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .luz.trabaja { animation: none; } }

/* Fichas */
.ficha { margin-top: 1rem; padding: 1.1rem 1.15rem; }
.ficha-cabecera { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: .5rem; }
.ficha-cabecera h3 { flex: 1; margin: 0; }
.etiqueta { display: inline-block; font-size: .72rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; padding: .15rem .5rem; border-radius: 999px; background: #efeee9; color: var(--suave); white-space: nowrap; }
.etiqueta.n3 { background: var(--rojo-tenue); color: var(--rojo); }
.etiqueta.n2 { background: var(--acento-tenue); color: var(--acento); }
.ficha dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; margin: .75rem 0; font-size: .92rem; }
.ficha dt { color: var(--suave); }
.ficha dd { margin: 0; overflow-wrap: anywhere; }
.ficha ul, .ficha ol { margin: .25rem 0 .75rem; padding-left: 1.2rem; }
.ficha h4 { margin: .9rem 0 .2rem; font-size: .78rem; letter-spacing: .07em; text-transform: uppercase; color: var(--suave); }
.nota { border-radius: 10px; padding: .65rem .8rem; font-size: .92rem; white-space: pre-line; margin: .6rem 0; }
.nota.mal { background: var(--rojo-tenue); color: #7a251e; }
.nota.bien { background: #e9f4ed; color: #1e5a37; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; margin-top: 1rem; }

/* Diálogos y avisos */
.dialogo { border: 1px solid var(--linea); border-radius: 16px; padding: 1.4rem; width: min(92vw, 420px); box-shadow: 0 20px 60px rgba(0, 0, 0, .18); color: var(--tinta); }
.dialogo::backdrop { background: rgba(28, 29, 31, .4); }
.motor { display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--linea); }
.motor:last-child { border-bottom: 0; }
.motor small { grid-column: 2; }
.aviso { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--tinta); color: #fff; padding: .7rem 1rem; border-radius: 12px; max-width: min(92vw, 520px); box-shadow: var(--sombra); z-index: 20; }
.aviso.mal { background: var(--rojo); }
.globo { display: inline-block; min-width: 1.25rem; padding: 0 .35rem; border-radius: 999px; background: var(--ambar); color: #fff; font-size: .75rem; text-align: center; }

/* Móvil: una sección cada vez, con pestañas */
@media (max-width: 860px) {
  .barra { padding-inline: .5rem; gap: .15rem; }
  .barra .marca, .barra .hueco { display: none; }
  .selector { flex: 1; min-width: 0; }
  .selector select { min-width: 0; }
  .barra .boton.fantasma { padding-inline: .45rem; font-size: .9rem; white-space: nowrap; }
  .pestanas { display: flex; background: var(--papel); border-bottom: 1px solid var(--linea); }
  .pestana { flex: 1; font: inherit; font-weight: 600; padding: .7rem; border: 0; background: none; color: var(--suave); border-bottom: 2px solid transparent; cursor: pointer; }
  .pestana.activa { color: var(--acento); border-bottom-color: var(--acento); }
  .cuerpo { grid-template-columns: minmax(0, 1fr); padding: .6rem; gap: 0; }
  .cuerpo[data-zona="chat"] .tareas, .cuerpo[data-zona="tareas"] .chat { display: none; }
  .msg { max-width: 94%; }
  .acciones .boton { flex: 1 1 auto; }
}
