/* Clean minimal: blanco, negro y grises. El color solo para estados (error, aviso, acuerdo). */
:root {
  --fondo: #ffffff;
  --superficie: #fafafa;
  --texto: #111111;
  --texto-2: #555555;
  --texto-3: #8a8a8a;
  --linea: #e4e4e4;
  --linea-fuerte: #111111;
  --sombreado: #f2f2f2;
  --tinta: #111111;          /* botón primario */
  --tinta-texto: #ffffff;
  --error: #b42318;  --error-fondo: #fef3f2;
  --aviso: #9a5b00;  --aviso-fondo: #fffaeb;
  --ok: #067647;     --ok-fondo: #ecfdf3;
  --radio: 6px;
  --fuente: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --fondo: #0e0e0e; --superficie: #161616; --texto: #ededed; --texto-2: #a8a8a8; --texto-3: #767676;
    --linea: #2a2a2a; --linea-fuerte: #ededed; --sombreado: #1f1f1f; --tinta: #ededed; --tinta-texto: #0e0e0e;
    --error: #fda29b; --error-fondo: #2a1211; --aviso: #fdd27a; --aviso-fondo: #2a2210; --ok: #75e0a7; --ok-fondo: #0f2a1d;
  }
}
:root[data-tema="oscuro"] {
  --fondo: #0e0e0e; --superficie: #161616; --texto: #ededed; --texto-2: #a8a8a8; --texto-3: #767676;
  --linea: #2a2a2a; --linea-fuerte: #ededed; --sombreado: #1f1f1f; --tinta: #ededed; --tinta-texto: #0e0e0e;
  --error: #fda29b; --error-fondo: #2a1211; --aviso: #fdd27a; --aviso-fondo: #2a2210; --ok: #75e0a7; --ok-fondo: #0f2a1d;
}
:root[data-tema="claro"] { color-scheme: light; }
:root[data-tema="oscuro"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 15px/1.5 var(--fuente); font-variant-numeric: tabular-nums;
}
#app { max-width: 980px; margin: 0 auto; padding: 0 16px 48px; }
a { color: inherit; text-underline-offset: 3px; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; margin-bottom: 12px; }
h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--texto-3); margin: 20px 0 8px; }

.cabecera { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 32px 0 16px; border-bottom: 1px solid var(--linea-fuerte); }
.sub { margin: 4px 0 0; color: var(--texto-2); }
.idiomas { display: flex; gap: 2px; }
.ajustes { display: flex; gap: 12px; flex-wrap: wrap; }
.idioma { background: none; border: 1px solid var(--linea); color: var(--texto-2); padding: 4px 10px; font: inherit; font-size: 0.85rem; cursor: pointer; border-radius: var(--radio); }
.idioma[aria-pressed="true"] { border-color: var(--linea-fuerte); color: var(--texto); }

.pestanas { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--linea); margin-bottom: 24px; }
.pestana { background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 12px 10px; font: inherit; color: var(--texto-2); cursor: pointer; white-space: nowrap; }
.pestana:hover { color: var(--texto); }
.pestana[aria-selected="true"] { color: var(--texto); border-bottom-color: var(--linea-fuerte); font-weight: 600; }

.tarjeta { border: 1px solid var(--linea); border-radius: var(--radio); padding: 20px; margin-bottom: 16px; background: var(--fondo); }
.desplazable { overflow-x: auto; }
.ayuda { color: var(--texto-2); font-size: 0.85rem; margin: 4px 0 12px; }
small.ayuda { display: block; margin: 4px 0 0; }

/* Formularios */
.opciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.campo { display: flex; flex-direction: column; gap: 4px; }
.etiqueta { font-size: 0.8rem; color: var(--texto-2); }
input, select, textarea {
  font: inherit; color: var(--texto); background: var(--fondo);
  border: 1px solid var(--linea); border-radius: var(--radio); padding: 7px 9px; min-width: 0; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--linea-fuerte); outline-offset: 1px; }
input.num { text-align: center; font-variant-numeric: tabular-nums; }
.datos input.num { font-size: 1.15rem; font-weight: 600; }
textarea { resize: vertical; }

button { font: inherit; cursor: pointer; border-radius: var(--radio); padding: 8px 14px; }
.primario { background: var(--tinta); color: var(--tinta-texto); border: 1px solid var(--tinta); font-weight: 600; }
.primario:disabled { opacity: 0.35; cursor: not-allowed; }
.secundario { background: none; color: var(--texto); border: 1px solid var(--linea); }
.secundario:hover { border-color: var(--linea-fuerte); }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 16px; align-items: center; }
.acciones.izq { justify-content: flex-start; }
.acciones.izq select { width: auto; }

/* Tablas */
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; text-align: center; border-bottom: 1px solid var(--linea); white-space: nowrap; }
th[scope="row"] { text-align: left; font-weight: 400; white-space: normal; min-width: 150px; }
thead th { font-size: 0.78rem; font-weight: 600; color: var(--texto-2); border-bottom: 1px solid var(--linea-fuerte); vertical-align: bottom; white-space: normal; }
table.datos th[scope="row"] { color: var(--texto-2); font-size: 0.85rem; }
table.datos td { min-width: 110px; }
td.total { font-weight: 600; border-left: 1px solid var(--linea); }
tr.fuerte th, tr.fuerte td, td.fuerte { font-weight: 600; }
tr.sombreada th, tr.sombreada td { background: var(--sombreado); }
tr.sub th, tr.sub td { color: var(--texto-2); font-size: 0.85rem; padding-top: 3px; padding-bottom: 3px; }
tr.sub th { padding-left: 24px; }
tr.tenue th, tr.tenue td { color: var(--texto-3); font-size: 0.85rem; }
tr.elegida th, tr.elegida td { background: var(--tinta); color: var(--tinta-texto); }
table.numerica th[scope="row"] { min-width: 0; text-align: center; font-weight: 600; }
table.editor input { max-width: 90px; margin: 0 auto; display: block; }
.marca { color: var(--texto-3); }

/* Resumen */
.resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--linea); border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; margin: 0; }
.resumen > div { background: var(--fondo); padding: 12px 14px; }
.resumen dt { font-size: 0.78rem; color: var(--texto-2); }
.resumen dd { margin: 2px 0 0; font-size: 1.4rem; font-weight: 600; }
.resumen .destacado { background: var(--sombreado); }

/* Mensajes: aquí sí hay color */
.mensajes { border-radius: var(--radio); padding: 10px 14px; margin-top: 12px; font-size: 0.9rem; border: 1px solid; }
.mensajes ul { margin: 4px 0 0; padding-left: 18px; }
.mensajes.error { color: var(--error); background: var(--error-fondo); border-color: currentColor; }
.mensajes.aviso { color: var(--aviso); background: var(--aviso-fondo); border-color: currentColor; }
.txt-error { color: var(--error); font-weight: 600; }
.txt-aviso { color: var(--aviso); font-weight: 600; }

/* Negociación */
.cabecera-neg { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.cabecera-neg h2 { margin-bottom: 2px; }
.huella { text-align: right; }
.huella .etiqueta { display: block; }
.huella code { font: 600 1.35rem var(--mono); letter-spacing: 0.08em; }
.estado { border: 1px solid var(--linea); border-radius: var(--radio); padding: 10px 14px; margin: 12px 0 16px; background: var(--superficie); }
.estado.acuerdo { color: var(--ok); background: var(--ok-fondo); border-color: currentColor; }
.semana { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.dia { border: 1px solid var(--linea); border-radius: var(--radio); padding: 8px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dia.vacio { color: var(--texto-3); border-style: dashed; }
.dia-nombre { font-size: 0.75rem; color: var(--texto-2); text-transform: uppercase; letter-spacing: 0.05em; }
.dia-centro { font-weight: 600; overflow-wrap: anywhere; }
.semana.editable select { padding: 5px; font-size: 0.85rem; }
.enlace-listo { border-color: var(--linea-fuerte); }
.fila-enlace { display: flex; gap: 8px; }
.fila-enlace .enlace { font-family: var(--mono); font-size: 0.8rem; }
.historial { list-style: none; padding: 0; margin: 0; }
.historial li { padding: 10px 0; border-bottom: 1px solid var(--linea); }
.historial li:last-child { border-bottom: 0; }
.historial .cuando { color: var(--texto-3); font-size: 0.8rem; font-family: var(--mono); }
.historial .detalle { color: var(--texto-2); font-size: 0.85rem; }
.historial li.acepta strong { color: var(--ok); }
blockquote { margin: 6px 0 0; padding-left: 12px; border-left: 2px solid var(--linea); color: var(--texto-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.pasos { padding-left: 20px; margin: 0; }
.pasos li { margin-bottom: 8px; }
.lista { padding-left: 18px; margin: 0; }
.lista li { margin-bottom: 8px; }
.notas ul { padding-left: 18px; margin: 0; color: var(--texto-2); font-size: 0.88rem; }
.notas li { margin-bottom: 6px; }

.pie { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--linea); color: var(--texto-3); font-size: 0.8rem; }
.pie p { margin: 4px 0; }

@media (max-width: 600px) {
  h1 { font-size: 1.35rem; }
  .tarjeta { padding: 14px; }
  .semana { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .fila-enlace { flex-wrap: wrap; }
  .huella { text-align: left; }
  th[scope="row"] { min-width: 110px; }
  table.datos td { min-width: 72px; }
  th, td { padding: 6px 6px; }
}

@media print {
  :root { --fondo: #fff; --texto: #000; --linea: #bbb; }
  body { font-size: 11pt; }
  .no-imprimir, .pestanas, .pie, .idiomas { display: none !important; }
  .tarjeta { border: 0; padding: 0; margin-bottom: 12pt; }
  #app { max-width: none; padding: 0; }
  .desplazable { overflow: visible; }
}

/* Tablas plegables: plegadas muestran nombre y fórmula */
details.plegable { padding: 0; }
details.plegable > summary { list-style: none; cursor: pointer; padding: 20px 52px 20px 20px; position: relative; }
details.plegable > summary::-webkit-details-marker { display: none; }
details.plegable > summary::after { content: "+"; position: absolute; right: 20px; top: 16px; font-size: 1.4rem; font-weight: 300; color: var(--texto-2); }
details.plegable[open] > summary::after { content: "−"; }
details.plegable > summary:hover h2 { text-decoration: underline; text-underline-offset: 3px; }
details.plegable > summary:focus-visible { outline: 2px solid var(--linea-fuerte); outline-offset: -2px; border-radius: var(--radio); }
details.plegable h2 { margin-bottom: 6px; }
.formula { margin: 0; font-family: var(--mono); font-size: 0.82rem; color: var(--texto-2); line-height: 1.6; }
details.plegable .cuerpo { padding: 0 20px 20px; }
details.plegable .cuerpo > .ayuda:first-child { margin-top: 0; }

/* Consulta */
.segmentado { display: flex; border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; }
.segmentado button { flex: 1; border: 0; border-radius: 0; background: none; color: var(--texto-2); padding: 7px 10px; font-size: 0.9rem; }
.segmentado button + button { border-left: 1px solid var(--linea); }
.segmentado button[aria-pressed="true"] { background: var(--tinta); color: var(--tinta-texto); font-weight: 600; }
input.num.grande { font-size: 1.15rem; font-weight: 600; }
.separado { margin-top: 16px; }

@media (max-width: 600px) {
  details.plegable > summary { padding: 14px 44px 14px 14px; }
  details.plegable > summary::after { right: 14px; top: 10px; }
  details.plegable .cuerpo { padding: 0 14px 14px; }
}
@media print {
  details.plegable > summary::after { display: none; }
}

/* «Propuesta»: el desglose de B no es norma. Gris y discontinuo, sin color. */
.propuesta { display: inline-block; vertical-align: 1px; border: 1px dashed var(--texto-3); color: var(--texto-2); border-radius: 999px; padding: 0 7px; font-size: 0.68rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; line-height: 1.6; cursor: help; white-space: nowrap; }
tr.grupo th, tr.grupo td { border-bottom: 0; padding-top: 10px; padding-bottom: 2px; }
tr.sub.grupo th { font-style: italic; text-align: left; }
thead tr.grupo th { border-bottom: 0; }
thead th.grupo-act { border-bottom: 1px dashed var(--texto-3); text-align: center; }

/* Guía de desglose y desglose editable */
input.num.peq { width: 52px; padding: 4px 4px; margin: 0 auto; display: block; }
table.editor-guia td, table.editor-guia th { padding: 4px 6px; }
tr.propia th[scope="row"] { box-shadow: inset 3px 0 0 var(--linea-fuerte); }
.otra { display: inline-flex; gap: 4px; align-items: center; }
.otra input { width: 150px; padding: 4px 6px; font-size: 0.82rem; }
thead .otra input { width: 120px; }
button.quitar { background: none; border: 1px solid var(--linea); color: var(--texto-2); padding: 0 7px; line-height: 1.5; }
button.quitar:hover { border-color: var(--linea-fuerte); color: var(--texto); }
button.enlace-texto { background: none; border: 0; padding: 4px 0; color: var(--texto-2); text-decoration: underline; text-underline-offset: 3px; font-size: 0.85rem; margin-right: 12px; }
button.enlace-texto:hover { color: var(--texto); }
button.enlace-texto:disabled { opacity: 0.4; cursor: not-allowed; }

/* Editor de propuesta: tipo de reparto arriba, con su descripción */
.tipo-reparto { border: 1px solid var(--linea); border-radius: var(--radio); padding: 4px 14px 12px; margin: 16px 0 4px; background: var(--superficie); }
.tipo-reparto h3 { margin-top: 10px; }
.tipo-reparto .acciones { margin-top: 0; }
.descripcion { margin: 10px 0 4px; font-size: 0.9rem; }
.tipo-reparto .ayuda { margin-bottom: 0; }
.mensajes + .desplazable, .mensajes + h3 { margin-top: 16px; }
.tipo-reparto.manual { border-color: var(--aviso); background: var(--aviso-fondo); }
.tipo-reparto.manual .descripcion { color: var(--aviso); font-weight: 600; }
.boton-descarga { display: inline-flex; align-items: center; border: 1px solid var(--linea-fuerte); border-radius: var(--radio); padding: 4px 10px; font-size: 0.85rem; text-decoration: none; color: var(--texto); }
.boton-descarga::before { content: "↓"; margin-right: 6px; }
.boton-descarga:hover { background: var(--tinta); color: var(--tinta-texto); }
.ajustes { align-items: center; }

/* Cambios respecto a la propuesta anterior: subrayado de aviso, sin depender solo del color */
td.cambio, .dia.cambio { background: var(--aviso-fondo); }
td.cambio { font-weight: 600; box-shadow: inset 0 -2px 0 var(--aviso); }
.dia.cambio { border-color: var(--aviso); }
.antes { display: block; font-size: 0.72rem; font-weight: 400; color: var(--texto-3); }
.leyenda-cambios { font-size: 0.85rem; color: var(--texto-2); margin: 12px 0 8px; }
.leyenda-cambios::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; background: var(--aviso-fondo); box-shadow: inset 0 -2px 0 var(--aviso); vertical-align: -1px; }
.historial .detalle div { margin-top: 2px; }
.solo-imprimir { display: none; }
@media print { .solo-imprimir { display: block; font-size: 8pt; color: #555; margin-top: 12pt; } }
.novedades h2.version { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--linea); font-family: var(--mono); font-size: 1rem; }
.novedades h3 { margin-top: 14px; }
.titulo { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.version { font-size: 0.8rem; color: var(--texto-3); font-family: var(--mono); }
.version a { color: var(--texto-2); }
.enlace-consulta { margin-top: 16px; display: flex; flex-direction: column; gap: 4px; }
