:root {
  --navy: #1f4e78;
  --navy-dark: #163a58;
  --navy-light: #2f6ba3;
  --gold: #e8a83c;
  --green: #2e7d32;
  --red: #c62828;
  --orange: #e08600;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #222;
  --muted: #6b7280;
  --border: #e2e5e9;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
}

h1 {
  font-size: 1.3rem;
  color: var(--navy);
  margin: 0 0 .8rem;
}

h2 {
  font-size: 1.05rem;
  color: var(--navy);
  margin: 1.4rem 0 .6rem;
}

a {
  color: var(--navy);
}

/* =========================
   ANIMACIONES
   ========================= */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes crecer {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes pulseSuave {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* =========================
   BARRA SUPERIOR
   ========================= */

.topbar {
  background: linear-gradient(
    135deg,
    var(--navy-light),
    var(--navy) 60%,
    var(--navy-dark)
  );
  color: #fff;
  padding: .8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

.topbar a {
  color: #fff;
  text-decoration: none;
  transition: opacity .15s ease;
}

.topbar a:active {
  opacity: .6;
}

.topbar .titulo {
  font-weight: 600;
  font-size: 1rem;
}

.topbar .contexto {
  font-size: .8rem;
  opacity: .85;
}

/* =========================
   CONTENEDOR
   ========================= */

.contenedor {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
  animation: fadeIn .3s ease both;
}

.contenedor.ancho {
  max-width: 1100px;
}

/* =========================
   TARJETAS
   ========================= */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  animation: fadeInUp .35s ease both;
  transition: box-shadow .2s ease;
  overflow: visible;
}

@media (hover: hover) {
  .card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,.07);
  }
}

/* =========================
   BOTONES
   ========================= */

.grid-botones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .7rem;
}

.grid-botones.col-1 {
  grid-template-columns: 1fr;
}

.grid-botones.col-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.boton-grande {
  display: block;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  text-align: center;
  padding: 1rem .7rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 2px 6px rgba(31,78,120,.18);
  transition:
    transform .12s ease,
    box-shadow .12s ease,
    background .15s ease;
}

.boton-grande:active {
  background: var(--navy-dark);
  transform: scale(.97);
}

@media (hover: hover) {
  .boton-grande:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(31,78,120,.24);
  }
}

.boton-grande.secundario {
  background: #fff;
  color: var(--navy);
  border: 2px solid var(--navy);
  box-shadow: none;
}

.boton-grande.chico {
  padding: .7rem .8rem;
  font-size: .9rem;
  white-space: nowrap;
}

.boton-grande.rojo {
  background: var(--red);
}

.boton-grande.verde {
  background: var(--green);
}

.boton-grande[disabled] {
  opacity: .4;
  transform: none !important;
}

/* =========================
   MENÚ
   ========================= */

.menu-item {
  display: flex;
  align-items: center;
  gap: .8rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  margin-bottom: .7rem;
  transition:
    transform .12s ease,
    box-shadow .12s ease,
    background .12s ease;
  animation: fadeInUp .35s ease both;
}

.menu-item .emoji {
  font-size: 1.6rem;
}

.menu-item:active {
  background: #f0f2f5;
  transform: scale(.98);
}

@media (hover: hover) {
  .menu-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    transform: translateY(-1px);
  }
}

/* =========================
   FORMULARIOS
   ========================= */

form label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  color: var(--muted);
  margin: .8rem 0 .3rem;
}

input,
select,
textarea {
  width: 100%;
  padding: .7rem .6rem;
  font-size: 1rem;
  border: 1px solid #c9ced6;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  transition:
    border-color .15s ease,
    box-shadow .15s ease;
}

textarea {
  min-height: 5rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(31,78,120,.15);
}

/* Checkbox: evita que ocupe todo el ancho */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-width: 18px;
  height: 18px;
  cursor: pointer;
}

.fila-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .8rem;
}

/* =========================
   RESUMEN DE PRECIO
   ========================= */

.resumen-precio {
  background: #eef4fa;
  border: 1px solid #cfe0f0;
  border-radius: 10px;
  padding: .8rem;
  margin-top: .8rem;
  font-size: 1rem;
  animation: fadeInUp .25s ease both;
}

.resumen-precio .total {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
}

/* =========================
   ALERTAS
   ========================= */

.alert {
  padding: .8rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: .95rem;
  animation: slideDown .25s ease both;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

.alert::before {
  flex: none;
  font-size: 1.05rem;
  line-height: 1.3;
}

.alert-ok {
  background: #e6f4ea;
  color: #1e4620;
  border: 1px solid #b7ddc0;
}

.alert-ok::before {
  content: "✅";
}

.alert-bad {
  background: #fdecea;
  color: #7a1a13;
  border: 1px solid #f3b8b0;
}

.alert-bad::before {
  content: "❌";
}

.alert-warn {
  background: #fff4e0;
  color: #7a4b00;
  border: 1px solid #f3d599;
}

.alert-warn::before {
  content: "⚠️";
}

/* =========================
   TABLAS
   CORREGIDO: el encabezado ya
   NO tapa la primera fila
   ========================= */

.tabla-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: .9rem;
  background: #fff;
}

table th,
table td {
  padding: .65rem .7rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

/*
 IMPORTANTE:
 Se quitó position:sticky.
 Era lo que tapaba Croacia y
 la primera vendedora.
*/
table th {
  background: #f0f2f5;
  color: var(--navy);
  position: static;
  top: auto;
  font-weight: 700;
  white-space: nowrap;
}

table tbody tr:last-child td {
  border-bottom: none;
}

table tbody tr {
  transition: background .12s ease;
}

table td input[type="text"],
table td input[type="number"],
table td select {
  min-width: 150px;
}

table td .boton-grande {
  min-width: 120px;
}

@media (hover: hover) {
  table tbody tr:hover {
    background: #f7f9fb;
  }
}

/* =========================
   BADGES
   ========================= */

.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}

.badge-ok {
  background: #e6f4ea;
  color: #1e4620;
}

.badge-bad {
  background: #fdecea;
  color: #7a1a13;
}

.badge-warn {
  background: #fff4e0;
  color: #7a4b00;
  animation: pulseSuave 1.8s ease-in-out infinite;
}

/* =========================
   DASHBOARD
   ========================= */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px,1fr));
  gap: .8rem;
}

.kpi {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  animation: fadeInUp .35s ease both;
  transition:
    box-shadow .15s ease,
    transform .15s ease;
}

@media (hover: hover) {
  .kpi:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    transform: translateY(-1px);
  }
}

.kpi .label {
  font-size: .8rem;
  color: var(--muted);
  font-weight: 600;
}

.kpi .valor {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  margin-top: .2rem;
}

.kpi.destacado {
  border-color: var(--gold);
  background: linear-gradient(180deg, #fff, #fff8ea);
}

.kpi.destacado .valor {
  color: var(--gold);
}

/* =========================
   GRÁFICOS
   ========================= */

.barra-fondo {
  background: var(--border);
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
}

.barra-fill {
  background: var(--navy);
  height: 10px;
  transform-origin: left;
  animation: crecer .8s ease-out both;
}

/* =========================
   MENÚ ADMINISTRADOR
   ========================= */

.nav-admin {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

.nav-admin a {
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--navy);
  padding: .55rem .9rem;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 600;
  transition:
    background .15s ease,
    color .15s ease,
    transform .12s ease;
}

.nav-admin a:active {
  transform: scale(.96);
}

@media (hover: hover) {
  .nav-admin a:hover {
    background: #eef4fa;
  }
}

.nav-admin a.activo {
  background: var(--navy);
  color: #fff;
}

/* =========================
   PIE
   ========================= */

.pie {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  margin: 1.5rem 0;
}

.link-volver {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
}

/* =========================
   CELULAR / TABLET
   ========================= */

@media (max-width: 700px) {

  html,
  body {
    font-size: 16px;
  }

  .contenedor,
  .contenedor.ancho {
    width: 100%;
    max-width: 100%;
    padding: .7rem;
  }

  .card {
    padding: .75rem;
  }

  .fila-2 {
    grid-template-columns: 1fr;
  }

  .grid-botones,
  .grid-botones.col-3 {
    grid-template-columns: 1fr;
  }

  .nav-admin {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: .3rem;
    -webkit-overflow-scrolling: touch;
  }

  .nav-admin a {
    flex: 0 0 auto;
  }

  .tabla-scroll {
    overflow-x: auto;
  }

  table {
    min-width: 600px;
  }

  table th,
  table td {
    padding: .55rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 430px) {

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: .7rem;
  }
}

/* =========================
   MODO OSCURO
   ========================= */

@media (prefers-color-scheme: dark) {

  :root {
    --bg: #14181f;
    --card: #1c222c;
    --text: #e7ebf0;
    --muted: #97a1af;
    --border: #2b3340;
  }

  input,
  select,
  textarea {
    background: #232a35;
    color: var(--text);
    border-color: #3a4354;
  }

  .tabla-scroll,
  table {
    background: var(--card);
  }

  table th {
    background: #232a35;
  }

  @media (hover: hover) {
    table tbody tr:hover {
      background: #232a35;
    }
  }

  .menu-item {
    background: #1c222c;
    border-color: #2b3340;
    color: var(--text);
  }

  .boton-grande.secundario {
    background: #1c222c;
  }

  .resumen-precio {
    background: #1b2a3a;
    border-color: #274158;
  }

  .alert-ok {
    background: #163821;
    color: #b7ddc0;
  }

  .alert-bad {
    background: #3a1a17;
    color: #f3b8b0;
  }

  .alert-warn {
    background: #3a2c0a;
    color: #f3d599;
  }

  .badge-ok {
    background: #163821;
    color: #b7ddc0;
  }

  .badge-bad {
    background: #3a1a17;
    color: #f3b8b0;
  }

  .badge-warn {
    background: #3a2c0a;
    color: #f3d599;
  }

  .nav-admin a {
    background: #1c222c;
    border-color: #2b3340;
  }

  .kpi.destacado {
    background: linear-gradient(180deg, #1c222c, #2a2213);
    border-color: var(--gold);
  }
}