:root {
  --fondo: #f4f6f8;
  --papel: #ffffff;
  --texto: #1d2733;
  --flojo: #5b6b7b;
  --borde: #d5dde5;
  --marca: #1f5f8b;
  --marca-oscura: #174a6d;
  --duda: #fff4d6;
  --duda-borde: #e5b84a;
  --bien: #e3f4e8;
  --mal: #fde4e4;
  --mal-texto: #9c1c1c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #12171d;
    --papel: #1b232c;
    --texto: #e6edf3;
    --flojo: #9aa8b6;
    --borde: #33404d;
    --marca: #4b9bd1;
    --marca-oscura: #357fb0;
    --duda: #3a3016;
    --duda-borde: #a8832c;
    --bien: #173524;
    --mal: #3d1d1d;
    --mal-texto: #f2a7a7;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--marca); }
.barra {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px;
  background: var(--marca); color: #fff;
}
.marca { color: #fff; font-weight: 600; text-decoration: none; }
nav { display: flex; align-items: center; gap: 10px; }
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.15); }
.menu summary::-webkit-details-marker { display: none; }
.menu-lista {
  position: absolute; right: 0; top: 40px; min-width: 170px;
  background: var(--papel); border: 1px solid var(--borde); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 6px 0;
}
.menu-lista a { display: block; padding: 9px 14px; color: var(--texto); text-decoration: none; }
.menu-lista a:hover { background: var(--fondo); }
.contenido { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.35rem; margin: 6px 0 14px; }
h2 { font-size: 1.1rem; margin: 22px 0 10px; }
.tarjeta {
  background: var(--papel); border: 1px solid var(--borde); border-radius: 12px;
  padding: 16px; margin-bottom: 14px;
}
.estrecha { max-width: 420px; margin: 30px auto; }
label { display: block; font-size: .9rem; color: var(--flojo); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=date], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--texto);
  background: var(--papel); border: 1px solid var(--borde); border-radius: 8px;
}
textarea { min-height: 160px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--marca); border-color: transparent; }
.boton {
  display: inline-block; padding: 11px 16px; border: 0; border-radius: 9px; cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none; text-align: center;
  background: var(--marca); color: #fff;
}
.boton:hover { background: var(--marca-oscura); }
.boton[disabled] { opacity: .5; cursor: default; }
.boton-claro { background: rgba(255,255,255,.18); color: #fff; padding: 7px 12px; }
.boton-gris { background: var(--fondo); color: var(--texto); border: 1px solid var(--borde); }
.boton-gris:hover { background: var(--borde); }
.boton-peligro { background: var(--mal); color: var(--mal-texto); }
.boton-ancho { width: 100%; margin-top: 14px; }
.botones { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.error { background: var(--mal); color: var(--mal-texto); padding: 10px 12px; border-radius: 8px; margin: 10px 0; }
.mensaje { background: var(--bien); padding: 10px 12px; border-radius: 8px; margin: 10px 0; word-break: break-word; }
.flojo { color: var(--flojo); font-size: .9rem; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }

/* listado de hojas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { border-bottom: 1px solid var(--borde); }
.lista li:last-child { border-bottom: 0; }
.lista a.fila { display: flex; justify-content: space-between; gap: 10px; padding: 12px 4px; color: var(--texto); text-decoration: none; }
.estado { font-size: .8rem; padding: 3px 8px; border-radius: 99px; background: var(--fondo); border: 1px solid var(--borde); white-space: nowrap; align-self: center; }
.estado-hecha { background: var(--bien); border-color: transparent; }
.estado-revisar { background: var(--duda); border-color: var(--duda-borde); }
.estado-error { background: var(--mal); }
.filtros { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.filtros > * { flex: 1 1 160px; }

/* subir fotos */
.elegir { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.elegir label.boton { margin: 0; color: #fff; font-size: 1rem; }
.elegir input { display: none; }
.miniaturas { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 14px; }
.miniaturas div { position: relative; }
.miniaturas img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--borde); }
.miniaturas button { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 99px; width: 26px; height: 26px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
progress { width: 100%; height: 14px; margin-top: 12px; }

/* revisión */
.material { display: grid; gap: 10px; }
.linea { display: grid; grid-template-columns: 84px 1fr; gap: 10px; padding: 10px; border: 1px solid var(--borde); border-radius: 10px; background: var(--papel); }
.linea.duda { background: var(--duda); border-color: var(--duda-borde); }
.linea img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }
.sin-foto { width: 84px; height: 84px; border-radius: 8px; border: 1px dashed var(--borde); display: grid; place-items: center; color: var(--flojo); font-size: .8rem; text-align: center; }
.campos { display: grid; grid-template-columns: 1fr 2fr; gap: 6px 8px; }
.campos label { margin: 0; font-size: .75rem; }
.campos input { padding: 7px 9px; }
.ancho2 { grid-column: span 2; }
.aviso { font-size: .85rem; margin-top: 6px; }
.aviso-duda { color: #8a5a00; }
@media (prefers-color-scheme: dark) { .aviso-duda { color: #f0c46a; } }
.quitar { font-size: .85rem; color: var(--flojo); display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.quitar input { width: auto; }
.visor { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; z-index: 20; }
.visor img { max-width: 96vw; max-height: 92vh; }
.visor.abierto { display: flex; }
.esperando { text-align: center; padding: 26px 10px; }
.giro { width: 34px; height: 34px; border: 4px solid var(--borde); border-top-color: var(--marca); border-radius: 50%; margin: 0 auto 12px; animation: giro 1s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.pie-fijo { position: sticky; bottom: 0; background: var(--fondo); padding: 10px 0; border-top: 1px solid var(--borde); }

/* tablas de administración */
.tabla-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { color: var(--flojo); font-weight: 600; }
td form { display: inline; }
.pequeno { padding: 6px 10px; font-size: .85rem; }
.codigo-qr { background: #fff; padding: 12px; border-radius: 10px; display: inline-block; }
.codigo-qr img { width: 220px; height: 220px; }
@media (min-width: 760px) {
  .material { grid-template-columns: 1fr 1fr; }
}

/* móvil: la barra y el pie en una sola fila */
.marca, nav .boton, .menu summary { white-space: nowrap; }
.pie-fijo { flex-wrap: nowrap; }
.pie-fijo .boton { flex: 1 1 auto; padding: 11px 8px; font-size: .95rem; }
@media (max-width: 420px) {
  .marca { font-size: .98rem; }
  .barra { padding: 10px 12px; }
  .contenido { padding: 12px; }
}

/* archivo */
.archivo-fila { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.archivo-fila .fila { flex: 1 1 260px; min-width: 0; }
.archivo-nombre { display: flex; align-items: center; gap: 10px; min-width: 0; overflow-wrap: anywhere; }
.mini-archivo { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--borde); flex: none; }
.acciones { display: flex; gap: 6px; padding: 6px 0; }
.icono-carpeta { display: inline-block; width: 18px; height: 13px; margin-right: 8px; vertical-align: -1px; border-radius: 2px 3px 3px 3px; background: var(--duda-borde); position: relative; }
.icono-carpeta::before { content: ""; position: absolute; left: 0; top: -3px; width: 8px; height: 4px; border-radius: 2px 2px 0 0; background: var(--duda-borde); }
.icono-pdf { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 6px; background: var(--mal); color: var(--mal-texto); font-size: .75rem; font-weight: 700; }
.elegir label.apagado { opacity: .45; pointer-events: none; }
