:root {
  --azul: #0B2A4A;
  --azul-claro: #1e4d7b;
  --acento: #E87722;
  --gris: #64748b;
  --gris-claro: #f1f5f9;
  --borde: #e2e8f0;
  --texto: #1e293b;
  --ok: #16a34a;
  --error: #dc2626;
  --radio: 10px;
  --sombra: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--gris-claro);
  color: var(--texto);
  font-size: 15px;
  line-height: 1.5;
}

.cargando { padding: 4rem 1rem; text-align: center; color: var(--gris); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(150deg, var(--azul) 0%, #123a63 55%, var(--azul-claro) 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(2, 10, 25, .35);
}
.login-logo { display: block; max-height: 54px; margin: 0 auto 1rem; }
.login-card h1 { font-size: 1.35rem; margin: 0 0 .25rem; text-align: center; }
.login-card .sub { text-align: center; color: var(--gris); font-size: .875rem; margin-bottom: 1.5rem; }

/* ---------- Formularios ---------- */
label { display: block; font-size: .8125rem; font-weight: 600; margin-bottom: .35rem; color: #334155; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  font-size: .9375rem;
  font-family: inherit;
  background: #fff;
  color: var(--texto);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--acento);
  box-shadow: 0 0 0 3px rgba(232, 119, 34, .15);
}
.campo { margin-bottom: 1rem; }
.ayuda { font-size: .75rem; color: var(--gris); margin-top: .3rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radio);
  font-size: .9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn-primario { background: var(--acento); color: #fff; }
.btn-primario:hover { background: #d26612; }
.btn-azul { background: var(--azul); color: #fff; }
.btn-azul:hover { background: var(--azul-claro); }
.btn-gris { background: #fff; color: var(--texto); border-color: var(--borde); }
.btn-gris:hover { background: var(--gris-claro); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-bloque { width: 100%; }

/* ---------- Alertas ---------- */
.alerta {
  padding: .7rem .9rem;
  border-radius: var(--radio);
  font-size: .875rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alerta-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alerta-ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alerta-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* ---------- Layout app ---------- */
.topbar {
  background: var(--azul);
  color: #fff;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--sombra);
}
.topbar .marca { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.topbar .marca img { max-height: 32px; }
.topbar .empresa { font-size: .8125rem; opacity: .8; font-weight: 400; }
.topbar .espaciador { flex: 1; }
.topbar .usuario { font-size: .8125rem; text-align: right; line-height: 1.25; }
.topbar .usuario b { display: block; font-size: .875rem; }
.topbar .usuario span { opacity: .75; }

.nav { background: #fff; border-bottom: 1px solid var(--borde); display: flex; gap: .25rem; padding: 0 .75rem; overflow-x: auto; }
.nav a {
  padding: .75rem .9rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--gris);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.nav a.activo { color: var(--azul); border-bottom-color: var(--acento); }

.contenido { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
h2 { font-size: 1.25rem; margin: 0 0 .25rem; }
.subtitulo { color: var(--gris); font-size: .875rem; margin-bottom: 1.25rem; }

/* ---------- Tarjetas ---------- */
.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 1.25rem; box-shadow: var(--sombra); margin-bottom: 1rem; }
.tarjeta h3 { margin: 0 0 .75rem; font-size: 1rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.kpi { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem; box-shadow: var(--sombra); }
.kpi .valor { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.kpi .etiqueta { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); margin-top: .25rem; }

/* ---------- Tablas ---------- */
.tabla-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .65rem .85rem; text-align: left; border-bottom: 1px solid var(--borde); }
th { background: #f8fafc; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); font-weight: 700; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcff; }

.chip { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.chip-ok { background: #f0fdf4; color: #166534; }
.chip-pend { background: #fffbeb; color: #92400e; }
.chip-off { background: #fef2f2; color: #991b1b; }
.chip-gris { background: var(--gris-claro); color: var(--gris); }

.vacio { padding: 2rem; text-align: center; color: var(--gris); font-size: .875rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--texto);
  color: #fff;
  padding: .7rem 1.2rem;
  border-radius: 999px;
  font-size: .875rem;
  box-shadow: 0 10px 30px rgba(2, 10, 25, .3);
  transition: transform .25s;
  z-index: 9999;
  max-width: 90vw;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--error); }
.toast.ok { background: var(--ok); }

@media (max-width: 640px) {
  .contenido { padding: 1rem .75rem 3rem; }
  .topbar .usuario { display: none; }
  th, td { padding: .5rem .6rem; font-size: .8125rem; }
}
