:root {
  --azul: #1e5c8a;
  --azul-osc: #123c5c;
  --verde: #1f8a4c;
  --rojo: #c0392b;
  --amarillo: #b8860b;
  --gris: #6b7280;
  --fondo: #f4f6f8;
  --superficie: #ffffff;
  --borde: #dbe2e8;
  --texto: #1f2937;
  --blanco: #ffffff;
  --codigo-fondo: #eef4fa;
  --sombra: 0 1px 2px rgba(20, 30, 45, 0.06);
}

html[data-tema="oscuro"] {
  --azul: #4a9fd6;
  --azul-osc: #0d2438;
  --verde: #3ecb7a;
  --rojo: #f0665a;
  --amarillo: #e0ac3f;
  --gris: #9aa5b1;
  --fondo: #12181f;
  --superficie: #1b232c;
  --borde: #2c3944;
  --texto: #e5eaef;
  --codigo-fondo: #22303b;
  --sombra: 0 1px 3px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body { background: var(--fondo); }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  font-size: 15px;
  transition: background 0.15s ease, color 0.15s ease;
}

a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--azul-osc);
  color: var(--blanco);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.2rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.topbar .marca {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--blanco);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar .marca-logo {
  height: 28px;
  width: auto;
  display: block;
}

.login-logo {
  display: block;
  height: 64px;
  width: auto;
  margin: 0 auto 0.75rem;
}

.topbar nav a {
  color: #dce8f2;
  margin-right: 1rem;
  font-size: 0.92rem;
}

.topbar nav a:hover { color: var(--blanco); }

.topbar .usuario {
  font-size: 0.85rem;
  color: #cfe0ee;
}

.contenedor {
  max-width: 1050px;
  margin: 0 auto;
  padding: 1.3rem 1rem 3rem;
}

.contenedor-angosto {
  max-width: 460px;
  margin: 2.5rem auto;
  padding: 0 1rem;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.7rem; }
h3 { font-size: 1.02rem; margin: 1rem 0 0.5rem; }

.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 1.2rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--sombra);
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.stat {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  box-shadow: var(--sombra);
}

.stat .num { font-size: 1.7rem; font-weight: 700; color: var(--azul); }
.stat .label { font-size: 0.82rem; color: var(--gris); }

label { display: block; font-size: 0.85rem; margin: 0.7rem 0 0.25rem; color: var(--gris); font-weight: 600; }

.opcion-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--texto);
  margin: 1rem 0 0.4rem;
}
.opcion-checkbox input[type="checkbox"] {
  width: auto;
  margin-top: 0.2rem;
}

input[type="text"], input[type="password"], input[type="date"], input[type="tel"],
select, textarea, input[type="file"] {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--borde);
  border-radius: 7px;
  font-size: 0.95rem;
  background: var(--superficie);
  color: var(--texto);
}

textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-block;
  background: var(--azul);
  color: var(--blanco);
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 7px;
  font-size: 0.92rem;
  cursor: pointer;
  margin-top: 0.9rem;
}
.btn:hover { background: var(--azul-osc); text-decoration: none; color: var(--blanco); }

.btn.secundario { background: var(--gris); }
.btn.exito { background: var(--verde); }
.btn.peligro { background: var(--rojo); }
.btn.pequeno { padding: 0.32rem 0.7rem; font-size: 0.8rem; margin-top: 0; }

.oculto { display: none; }

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--borde); }
th { color: var(--gris); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }

.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.pendiente { background: #fdecea; color: var(--rojo); }
.badge.parcial { background: #fff6e0; color: var(--amarillo); }
.badge.completo { background: #e7f6ec; color: var(--verde); }
.badge.error { background: #fdecea; color: var(--rojo); }
.badge.ok { background: #e7f6ec; color: var(--verde); }
.badge.novedad { background: var(--azul); color: var(--blanco); margin-left: 0.3rem; }

.flashes { margin-bottom: 1rem; }
.flash {
  padding: 0.6rem 0.9rem;
  border-radius: 7px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.flash.success { background: #e7f6ec; color: #146c34; }
.flash.danger { background: #fdecea; color: #92251b; }
.flash.warning { background: #fff6e0; color: #8a6100; }
.flash.info { background: #e7f0fb; color: #164a7a; }

.fila-medicamento {
  border: 1px dashed var(--borde);
  border-radius: 8px;
  padding: 0.8rem;
  margin-bottom: 0.6rem;
  position: relative;
}

.fila-medicamento .quitar {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  background: none;
  border: none;
  color: var(--rojo);
  cursor: pointer;
  font-size: 0.85rem;
}

.ayuda { font-size: 0.78rem; color: var(--gris); margin-top: 0.2rem; }

.catalogo-sugerencias {
  position: absolute;
  z-index: 20;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 7px;
  box-shadow: var(--sombra);
  list-style: none;
  margin: 2px 0 0;
  padding: 0.25rem 0;
  max-height: 220px;
  overflow-y: auto;
}
.catalogo-sugerencias li { padding: 0; }
.catalogo-sugerencias button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  color: var(--texto);
  font-size: 0.88rem;
}
.catalogo-sugerencias button:hover,
.catalogo-sugerencias button:focus { background: var(--fondo); }
.catalogo-sugerencias .cat-detalle { color: var(--gris); font-size: 0.78rem; }
.catalogo-sugerencias .cat-tag {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--gris);
  border: 1px solid var(--borde);
  border-radius: 999px;
  padding: 0 0.4rem;
  margin-left: 0.3rem;
}

.enlace-registro { text-align: center; margin-top: 1rem; font-size: 0.88rem; }

.codigo-box {
  font-family: "Courier New", monospace;
  font-weight: 700;
  letter-spacing: 1px;
  background: var(--codigo-fondo);
  color: var(--texto);
  padding: 0.15rem 0.5rem;
  border-radius: 5px;
}

.boton-tema {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--blanco);
  border-radius: 999px;
  width: 1.9rem;
  height: 1.9rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  margin-right: 0.6rem;
  vertical-align: middle;
}
.boton-tema:hover { background: rgba(255, 255, 255, 0.22); }

.modal-fondo {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 20, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-caja {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 14px;
  padding: 2rem 2.2rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.modal-etiqueta {
  font-size: 0.8rem;
  color: var(--gris);
  text-transform: uppercase;
  font-weight: 600;
  margin: 1.1rem 0 0.2rem;
}

.modal-dato {
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--azul);
  margin: 0;
}

.modal-dato.codigo-box {
  font-size: 1.3rem;
  display: inline-block;
}

.modal-dato.modal-alerta {
  color: var(--rojo);
}

footer.pie-app {
  text-align: center;
  color: var(--gris);
  font-size: 0.78rem;
  padding: 2rem 1rem 1rem;
}

@media print {
  .topbar, footer.pie-app, .no-imprimir { display: none !important; }
  body { background: var(--blanco); }
}
