:root {
  --azul: #1f4e78;
  --azul-claro: #2f6fa8;
  --azul-oscuro: #0c2b45;
  --verde: #1a7f37;
  --rojo: #b42318;
  --gris: #f4f6f8;
  --borde: #dfe3e8;
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  margin: 0;
  background: var(--gris);
  color: #1c1c1c;
}

/* Layout con menú lateral */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--azul-oscuro);
  color: #a9c4dd;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
}
.sidebar .marca {
  color: white;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.sidebar .marca i { color: var(--azul-claro); }
.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 1.25rem;
  color: #a9c4dd;
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
}
.sidebar nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: white; }
.sidebar nav a.activa {
  background: rgba(255,255,255,0.09);
  color: white;
  font-weight: 600;
  border-left-color: var(--azul-claro);
}
.sidebar .salir {
  margin-top: auto;
  padding: 0.65rem 1.25rem;
  color: #a9c4dd;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}
.sidebar .salir:hover { color: white; }

.main { flex: 1; min-width: 0; }
.contenido { max-width: 1100px; margin: 0 auto; padding: 1.75rem 2rem; }

.marca-login { text-align: center; font-weight: 700; color: var(--azul); font-size: 1.2rem; margin-bottom: 0.5rem; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; padding: 0.4rem 0.5rem; overflow-x: auto; }
  .sidebar .marca { display: none; }
  .sidebar nav { flex-direction: row; flex: 1; }
  .sidebar nav a {
    flex-direction: column; gap: 0.2rem; text-align: center;
    border-left: none; border-bottom: 3px solid transparent; padding: 0.5rem 0.65rem; font-size: 0.72rem;
    white-space: nowrap;
  }
  .sidebar nav a.activa { border-left: none; border-bottom-color: var(--azul-claro); }
  .sidebar .salir { margin-top: 0; padding: 0.5rem 0.65rem; }
  .contenido { padding: 1rem; }
}

h1 { color: var(--azul); margin-top: 0; }
h2 { color: var(--azul); margin-top: 2rem; }

.caja-login {
  max-width: 360px;
  margin: 4rem auto;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.caja-login form { display: flex; flex-direction: column; gap: 1rem; }
.caja-login label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; }
.caja-login input { padding: 0.5rem; border: 1px solid var(--borde); border-radius: 4px; }

.form-buscar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.form-buscar input[type=text] {
  flex: 1; padding: 0.6rem; border: 1px solid var(--borde); border-radius: 4px; font-size: 1rem;
}

.boton {
  display: inline-block;
  background: var(--azul-claro);
  color: white;
  text-decoration: none;
  padding: 0.55rem 1.1rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}
.boton:hover { background: var(--azul); }
.boton-chico { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.boton-primario { background: var(--verde); font-weight: 600; }
.boton-primario:hover { background: #145c29; }
.boton-quitar { background: #a33; }

.tabla { width: 100%; border-collapse: collapse; background: white; margin-top: 0.5rem; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.tabla th, .tabla td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--borde); text-align: left; font-size: 0.92rem; }
.tabla th { background: var(--azul); color: white; font-weight: 600; }
.tabla tbody tr:hover { background: #f7fafc; }
.tabla input { width: 100%; padding: 0.35rem; border: 1px solid var(--borde); border-radius: 3px; }
.tabla input.input-clave { font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.85rem; }
.req { color: var(--rojo); font-weight: 700; }

.panel { background: white; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); margin-top: 0.5rem; }
.panel-cabecera { background: var(--azul); color: white; padding: 0.7rem 1rem; font-weight: 600; }
.panel-cuerpo { padding: 1rem; }

.desglose-totales { margin-left: auto; width: 280px; border-collapse: collapse; }
.desglose-totales td { padding: 0.3rem 0; font-size: 0.92rem; }
.desglose-totales td:last-child { text-align: right; }
.desglose-totales .fila-total td { border-top: 1px solid var(--borde); font-weight: 700; padding-top: 0.5rem; font-size: 1.05rem; color: var(--azul); }
.desglose-totales .fila-secundaria td { color: #666; }

.chip { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.75rem; margin-right: 0.25rem; }
.chip-ok { background: #e3f3e6; color: var(--verde); }
.chip-baja { background: #f3e6e6; color: var(--rojo); }
.chip-alerta { background: #fff3cd; color: #8a6d00; }
.chip-info { background: #e0ecf7; color: var(--azul); }

.ficha { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; background: white; padding: 1rem; border-radius: 6px; margin-bottom: 1rem; }

.aviso { padding: 0.75rem 1rem; border-radius: 5px; margin-bottom: 1rem; }
.aviso-error { background: #fbe9e7; color: var(--rojo); border: 1px solid #f3c4bd; }
.aviso-ok { background: #e3f3e6; color: var(--verde); border: 1px solid #bfe3c6; }

.ayuda { color: #666; font-size: 0.9rem; }

.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.tarjeta {
  background: white; padding: 1.25rem; border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); display: flex; align-items: center; gap: 1rem;
}
.tarjeta-icono {
  width: 46px; height: 46px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
  background: #e0ecf7; color: var(--azul);
}
.tarjeta-icono.verde { background: #e3f3e6; color: var(--verde); }
.tarjeta-icono.naranja { background: #fff3cd; color: #8a6d00; }
.tarjeta-icono.morado { background: #efe6fb; color: #5b2ab3; }
.tarjeta-numero { font-size: 1.6rem; font-weight: 700; color: var(--azul); line-height: 1.1; }
.tarjeta-etiqueta { color: #666; font-size: 0.85rem; margin-top: 0.15rem; }

.accesos { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.acceso {
  background: white; border-radius: 10px; padding: 1.25rem; text-decoration: none; color: #1c1c1c;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); display: flex; flex-direction: column; gap: 0.6rem;
  border: 1px solid transparent; transition: border-color 0.15s, transform 0.15s;
}
.acceso:hover { border-color: var(--azul-claro); transform: translateY(-2px); }
.acceso i { font-size: 1.4rem; color: var(--azul-claro); }
.acceso-titulo { font-weight: 600; }
.acceso-desc { color: #666; font-size: 0.82rem; }

#form-facturar label { display: block; margin-bottom: 1rem; }
#form-facturar select { padding: 0.4rem; }
.total-preview { font-size: 1.1rem; margin: 1rem 0; }

@media (max-width: 640px) {
  .ficha { grid-template-columns: 1fr; }
}
