/*
 * Hoja de estilos única para todo /upgrade.
 * Reemplaza table.css + select.css + los ~150 líneas de <style> con
 * .button/.button2../.button7 y .modal que estaban copiadas en cada
 * archivo PHP del sistema anterior.
 */

:root {
  --azul: #14477a;
  --azul-claro: #4793e3;
  --gris-fondo: #eef1f4;
  --gris-borde: #d7dde3;
  --texto: #1c2733;
  --texto-suave: #5b6b7a;
  --ok: #16794f;
  --ok-bg: #e3f5ec;
  --alerta: #b3261e;
  --alerta-bg: #fdeceb;
  --tier-100: #16794f;
  --tier-75: #5c8a1f;
  --tier-50: #b58900;
  --tier-25: #c1440e;
  --tier-bajo: #b3261e;
  --tier-inv: #5b4fd1;
  --radio: 8px;
  --sombra: 0 1px 3px rgba(20, 71, 122, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gris-fondo);
  color: var(--texto);
  font-size: 14px;
}

a { color: var(--azul); }

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--azul);
  color: #fff;
  padding: 12px 20px;
}
.app-header__title { font-size: 17px; font-weight: 600; }
.app-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.app-nav a {
  color: #fff;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radio);
  font-size: 13px;
  opacity: .85;
}
.app-nav a:hover { background: rgba(255,255,255,.12); opacity: 1; }
.app-nav a.active { background: #fff; color: var(--azul); opacity: 1; font-weight: 600; }

.app-main { padding: 16px 20px 40px; max-width: 1400px; margin: 0 auto; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.toolbar form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar select, .toolbar input[type=text], .toolbar input[type=number] {
  padding: 6px 8px;
  border: 1px solid var(--gris-borde);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.toolbar .estado {
  font-size: 12px;
  color: var(--texto-suave);
  margin-left: auto;
}
.btn {
  display: inline-block;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--azul);
  color: #fff;
  text-decoration: none;
}
.btn:hover { background: var(--azul-claro); }
.btn.secundario { background: #fff; color: var(--azul); border: 1px solid var(--azul); }
.btn.pequeno { padding: 4px 9px; font-size: 12px; }

.table-scroll {
  width: 100%;
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
}

table.datos {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
  font-size: 12.5px;
}
table.datos caption { caption-side: top; text-align: left; padding: 10px 12px; font-weight: 600; }
table.datos th, table.datos td {
  border: 1px solid var(--gris-borde);
  padding: 6px 8px;
  text-align: center;
  white-space: nowrap;
}
table.datos thead th {
  background: var(--azul);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.datos tbody tr:nth-child(even) { background: #f6f8fa; }
table.datos td.nombre-producto {
  text-align: left;
  font-weight: 600;
  color: var(--azul);
  position: sticky;
  left: 0;
  background: inherit;
  max-width: 260px;
  white-space: normal;
}
table.datos .negativo { color: var(--alerta); font-weight: 700; }
table.datos small { display: block; color: var(--texto-suave); font-weight: 400; }

.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.chip-ok, .chip-100 { background: var(--tier-100); }
.chip-75 { background: var(--tier-75); }
.chip-50 { background: var(--tier-50); }
.chip-25 { background: var(--tier-25); }
.chip-bajo { background: var(--tier-bajo); }
.chip-inv { background: var(--tier-inv); }
.chip-na { background: #9aa7b3; }

.etapa-activa { text-decoration: underline; text-decoration-color: var(--azul-claro); text-decoration-thickness: 2px; }

.alerta-banner {
  background: var(--alerta-bg);
  border: 1px solid var(--alerta);
  color: var(--alerta);
  padding: 8px 12px;
  border-radius: var(--radio);
  margin-bottom: 12px;
  font-size: 13px;
}

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(15,23,32,.5); z-index: 50; padding: 40px 16px; overflow: auto; }
.modal.abierto { display: block; }
.modal-content { background: #fff; max-width: 900px; margin: 0 auto; border-radius: var(--radio); overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal-header { background: var(--azul); color: #fff; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 12px 16px; max-height: 70vh; overflow: auto; }
.modal-close { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }

.form-linea { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.form-linea label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--texto-suave); }
.form-linea input, .form-linea select {
  padding: 6px 8px; border: 1px solid var(--gris-borde); border-radius: 6px; font-size: 13px; width: 90px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.card {
  background: #fff;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio);
  padding: 14px 16px;
  box-shadow: var(--sombra);
}
.card h3 { margin: 0 0 10px; font-size: 13px; color: var(--texto-suave); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

@media (max-width: 700px) {
  .app-main { padding: 12px; }
  table.datos { min-width: 700px; }
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--azul) 0%, var(--azul-claro) 100%);
  padding: 16px;
}
.login-card {
  background: #fff;
  border-radius: var(--radio);
  box-shadow: 0 12px 30px rgba(0,0,0,.2);
  padding: 28px 26px;
  width: 100%;
  max-width: 360px;
}
.login-card h1 { font-size: 18px; margin: 0 0 4px; color: var(--azul); }
.login-card p.subtitulo { margin: 0 0 20px; color: var(--texto-suave); font-size: 13px; }
.login-card label { display: block; font-size: 12px; color: var(--texto-suave); margin-bottom: 4px; margin-top: 14px; }
.login-card input[type=text], .login-card input[type=password] {
  width: 100%; padding: 9px 10px; border: 1px solid var(--gris-borde); border-radius: 6px; font-size: 14px;
}
.login-card .btn { width: 100%; margin-top: 20px; padding: 10px; font-size: 14px; }
.login-error {
  background: var(--alerta-bg); border: 1px solid var(--alerta); color: var(--alerta);
  padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-top: 14px;
}
.login-aviso {
  background: #fff8e1; border: 1px solid #d9a441; color: #7a5200;
  padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-top: 14px;
}

/* Inicio / selección de módulo */
.inicio-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--azul) 0%, var(--azul-claro) 100%);
  color: #fff;
}
.inicio-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 28px;
}
.inicio-top .marca { font-size: 14px; font-weight: 600; letter-spacing: .04em; opacity: .9; }
.inicio-top .sesion { display: flex; align-items: center; gap: 14px; font-size: 13px; opacity: .9; }
.inicio-top .sesion a {
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, .45);
  padding: 5px 13px;
  border-radius: 999px;
}
.inicio-top .sesion a:hover { background: rgba(255, 255, 255, .15); }

.inicio-centro {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 64px;
  text-align: center;
}
.inicio-centro h1 { font-size: 26px; margin: 0 0 6px; font-weight: 600; }
.inicio-centro p.lead { margin: 0 0 34px; font-size: 14px; opacity: .82; }

.modulos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 300px));
  gap: 20px;
  justify-content: center;
  width: 100%;
  max-width: 680px;
}
.modulo {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  color: var(--texto);
  border-radius: 14px;
  padding: 24px 22px;
  text-decoration: none;
  text-align: left;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
  transition: transform .12s ease, box-shadow .12s ease;
}
.modulo:hover { transform: translateY(-3px); box-shadow: 0 18px 42px rgba(0, 0, 0, .28); }
.modulo .icono {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gris-fondo);
  font-size: 22px;
}
.modulo h2 { margin: 0; font-size: 16px; color: var(--azul); }
.modulo p { margin: 0; font-size: 13px; color: var(--texto-suave); line-height: 1.45; }
.modulo .entrar {
  margin-top: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--azul);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.inicio-vacio {
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 12px;
  padding: 18px 22px;
  font-size: 14px;
  max-width: 420px;
}

.inicio-bloqueo {
  background: #fff;
  color: var(--texto);
  border-radius: 14px;
  padding: 32px 28px;
  max-width: 460px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .28);
  text-align: center;
}
.inicio-bloqueo h2 { margin: 0 0 10px; font-size: 20px; color: var(--alerta); }
.inicio-bloqueo p { margin: 0 0 22px; font-size: 14px; line-height: 1.55; color: var(--texto-suave); }
.inicio-bloqueo .btn-bloqueo {
  display: inline-block;
  background: var(--azul);
  color: #fff;
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
}
.inicio-bloqueo .btn-bloqueo:hover { background: var(--azul-claro); }
.inicio-bloqueo .volver { display: block; margin-top: 16px; font-size: 13px; color: var(--texto-suave); text-decoration: none; }
.inicio-bloqueo .volver:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .inicio-top { padding: 16px; }
  .modulos { grid-template-columns: 1fr; max-width: 340px; }
}
