: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, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 17px;
}
h1 { font-size: 1.3rem; color: var(--navy); margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; color: var(--navy); margin: 1.2rem 0 .5rem; }
a { color: var(--navy); }

@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; }
}

.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: 10;
  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 {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
  animation: fadeIn .3s ease both;
}
.contenedor.ancho { max-width: 900px; }

.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;
}
@media (hover: hover) {
  .card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.07); }
}

.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: 1.1rem .6rem;
  border-radius: 12px;
  font-size: 1.05rem;
  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); box-shadow: 0 1px 2px rgba(31,78,120,.18); }
@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: .8rem .5rem; font-size: .95rem; }
.boton-grande.rojo { background: var(--red); box-shadow: 0 2px 6px rgba(198,40,40,.2); }
.boton-grande.verde { background: var(--green); box-shadow: 0 2px 6px rgba(46,125,50,.2); }
.boton-grande[disabled] { opacity: .4; transform: none !important; }

.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; display: inline-block; transition: transform .15s ease; }
.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); }
  .menu-item:hover .emoji { transform: scale(1.15) rotate(-4deg); }
}
.menu-item:nth-child(1) { animation-delay: .02s; }
.menu-item:nth-child(2) { animation-delay: .06s; }
.menu-item:nth-child(3) { animation-delay: .10s; }
.menu-item:nth-child(4) { animation-delay: .14s; }
.menu-item:nth-child(5) { animation-delay: .18s; }
.menu-item:nth-child(6) { animation-delay: .22s; }
.menu-item:nth-child(7) { animation-delay: .26s; }
.menu-item:nth-child(8) { animation-delay: .30s; }
.menu-item:nth-child(9) { animation-delay: .34s; }
.menu-item:nth-child(10) { animation-delay: .38s; }

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: 1.05rem;
  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); }

.fila-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

.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); }

.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: "⚠️"; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; background: #fff; }
table th, table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; }
table th { background: #f0f2f5; color: var(--navy); position: sticky; top: 48px; }
table tbody tr { transition: background .12s ease; }
@media (hover: hover) {
  table tbody tr:hover { background: #f7f9fb; }
}
.tabla-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }

.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; }

.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); }

.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; }

.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: .5rem .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 { 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; }

@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; }
  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); }
}
