:root {
  color-scheme: light dark;
  --bg: #f6f2f5;
  --fg: #241b22;
  --fg-muted: #6b5c67;
  --card-bg: #ffffff;
  --border: #e4d9e1;
  --brand-magenta: #9c1780;
  --brand-magenta-dark: #7a1264;
  --brand-gold: #d4a017;
  --accent: var(--brand-magenta);
  --accent-contrast: #ffffff;
  --warn-bg: #fff4e0;
  --warn-fg: #8a5300;
  --shadow: 0 1px 3px rgba(60, 20, 50, 0.08), 0 1px 2px rgba(60, 20, 50, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1418;
    --fg: #f1e9ee;
    --fg-muted: #b8a7b2;
    --card-bg: #261e24;
    --border: #3c313a;
    --brand-magenta: #e069c6;
    --brand-magenta-dark: #c94fac;
    --brand-gold: #f0c14b;
    --accent: var(--brand-magenta);
    --accent-contrast: #1a1418;
    --warn-bg: #3a2c12;
    --warn-fg: #ffcf8b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.5rem;
  background: var(--card-bg);
  border-bottom: 3px solid var(--brand-gold);
  box-shadow: var(--shadow);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-brand img { height: 42px; width: auto; display: block; }

.topbar h1 {
  font-size: 1.15rem;
  margin: 0;
  color: var(--brand-magenta);
  letter-spacing: 0.02em;
}

.topbar-subtitle {
  font-size: 0.72rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.topbar-actions { display: flex; gap: 0.5rem; }

main { max-width: 960px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }

.search-box {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 1.25rem;
  background: var(--card-bg);
  padding: 1rem 1.25rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.search-box label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--fg-muted);
  gap: 0.3rem;
  flex: 1;
}

input, button {
  font-size: 1rem;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-family: inherit;
}

input:focus, button:focus-visible {
  outline: 2px solid var(--brand-gold);
  outline-offset: 1px;
}

button {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.15s ease;
}

button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.6; cursor: default; filter: none; }

.topbar-actions button[type="submit"] {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  font-weight: 500;
}

.mensaje { min-height: 1.2em; color: var(--brand-magenta); font-weight: 600; }

.aviso {
  padding: 0.75rem 1rem;
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-radius: 8px;
}

.tarjeta-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tarjeta-card h2 {
  margin: 0;
  padding: 0.9rem 1.25rem;
  background: linear-gradient(90deg, var(--brand-magenta), var(--brand-magenta-dark));
  color: #fff;
  font-size: 1.05rem;
}

.tarjeta-body { padding: 0.5rem 1.25rem 1.1rem; }

.revision-manual {
  margin: 0.9rem 1.25rem 0;
  background: var(--warn-bg);
  color: var(--warn-fg);
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.resumen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem 1.25rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.resumen-item .campo-label { color: var(--fg-muted); }
.resumen-item .campo-valor { font-size: 1.05rem; font-weight: 600; }

.grupo { margin: 0; border-top: 1px solid var(--border); }
.grupo:first-of-type { border-top: none; }
.grupo summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.65rem 0;
  color: var(--brand-magenta-dark);
  list-style: none;
}
.grupo summary::-webkit-details-marker { display: none; }
.grupo summary::before { content: "▸ "; }
.grupo[open] summary::before { content: "▾ "; }

.campos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem 1.25rem;
  padding: 0.25rem 0 0.75rem;
}

.campo { display: flex; flex-direction: column; font-size: 0.9rem; }
.campo-label { opacity: 0.7; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--fg-muted); }
.campo-valor { word-break: break-word; }

.galeria { margin-top: 1.5rem; }
.galeria h2 { color: var(--brand-magenta-dark); font-size: 1.05rem; }

.galeria-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.6rem;
}

.galeria-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}

.galeria-grid img:hover { transform: scale(1.03); }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 9, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.lightbox.oculto { display: none; }

.lightbox img {
  max-width: 88vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-cerrar {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.6rem;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  cursor: pointer;
}

.lightbox-nav:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.lightbox-contador {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.4);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg) 60%, var(--warn-bg) 140%);
}

.login-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 4px solid var(--brand-gold);
  border-radius: 14px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 300px;
  box-shadow: var(--shadow);
}

.login-box img { height: 56px; margin-bottom: 0.25rem; }
.login-box h1 { margin: 0; color: var(--brand-magenta); }
.subtitle { margin: 0 0 0.5rem; opacity: 0.7; font-size: 0.85rem; text-align: center; }

.login-box label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  width: 100%;
}

.login-box button { width: 100%; margin-top: 0.25rem; }

.error { color: #d33; margin: 0; font-size: 0.85rem; }

/* Aviso de que algo no esta disponible ahora, distinto de un dato ausente:
   el usuario tiene que notar que no es lo mismo. */
.aviso-alerta {
  border-left: 4px solid #c47f00;
  background: #fff8e6;
  color: #6b4c00;
}

/* --- Pantalla de usuarios --- */
.panel {
  background: #fff;
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.panel h2 { margin-top: 0; font-size: 1.05rem; }

.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabla th, .tabla td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid #eee; }
.tabla th { font-weight: 600; color: #666; font-size: .82rem; text-transform: uppercase; }
.fila-inactiva { opacity: .55; }
.fila-fallida td { color: #a33; }

.acciones { white-space: nowrap; }
.acciones button { margin-right: .3rem; font-size: .82rem; padding: .25rem .55rem; }

.form-linea { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.form-linea label { display: flex; flex-direction: column; font-size: .82rem; color: #666; gap: .25rem; }
.form-linea input, .form-linea select { padding: .4rem .5rem; border: 1px solid #ccc; border-radius: 4px; }

.nota { font-size: .85rem; color: #777; margin: .7rem 0 0; }
.etiqueta { font-size: .72rem; background: #eee; border-radius: 3px; padding: .05rem .3rem; color: #666; }
.mensaje-error { color: #a33; }

.boton-enlace {
  display: inline-block;
  padding: .5rem .9rem;
  border-radius: 5px;
  text-decoration: none;
  background: #fff;
  border: 1px solid #ccc;
  color: #333;
  font-size: .9rem;
}

/* --- Resultados de busqueda --- */
.pista { font-size: .85rem; color: #888; margin: .4rem 0 1rem; text-align: center; }
.pista em { color: #666; font-style: normal; background: #f0f0f0;
            padding: .05rem .35rem; border-radius: 3px; }

.resultados h2 { font-size: 1rem; color: #666; font-weight: 600; }
.tabla-resultados { background: #fff; border-radius: 8px; overflow: hidden;
                    box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.fila-resultado { cursor: pointer; }
.fila-resultado:hover { background: #faf3f8; }
.col-ot { font-weight: 700; color: #8e1b6b; }

.chip-ot { font-size: .85rem; padding: .2rem .5rem; margin: .15rem;
           border: 1px solid #ccc; border-radius: 4px; background: #fff;
           cursor: pointer; }
.chip-ot:hover { background: #faf3f8; }

/* --- Buscador en dos bloques --- */
.separador-o { display: flex; align-items: center; gap: 1rem;
               margin: 1.1rem auto; max-width: 900px; color: #999; font-size: .85rem; }
.separador-o::before, .separador-o::after {
  content: ""; flex: 1; height: 1px; background: #ddd; }

.busqueda-campos {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem;
  align-items: end; background: #fff; border-radius: 8px;
  padding: 1.1rem 1.3rem; max-width: 900px; margin: 0 auto;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.busqueda-campos label {
  display: flex; flex-direction: column; gap: .3rem;
  font-size: .82rem; color: #666;
}
.busqueda-campos input {
  padding: .5rem .6rem; border: 1px solid #ccc; border-radius: 5px; font-size: .95rem;
}
.busqueda-acciones { grid-column: 1 / -1; display: flex; gap: .6rem; justify-content: flex-end; }
.busqueda-campos button.secundario { background: #fff; color: #666; border: 1px solid #ccc; }

@media (max-width: 760px) {
  .busqueda-campos { grid-template-columns: 1fr 1fr; }
}
