:root {
  --azul-1: #0b2a6f;
  --azul-2: #1240a8;
  --card: #0f172a;
  --borde: #26304a;
  --texto: #e5e7eb;
  --muted: #9ca3af;
  --acento: #6366f1;
  --pendiente: #94a3b8;
  --en_curso: #f59e0b;
  --migrado: #22c55e;
  --bloqueado: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--texto);
  background: linear-gradient(160deg, #0a1f55 0%, var(--azul-2) 60%, #0b2a6f 100%);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
.muted { color: var(--muted); }
.error { color: #fca5a5; font-size: 0.9rem; margin: 0.5rem 0 0; }

/* Login */
.login-screen {
  position: relative; overflow: hidden; min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--borde); border-radius: 16px;
  padding: 1.75rem; box-shadow: 0 30px 80px rgba(2, 6, 23, 0.55);
  display: flex; flex-direction: column;
}
.logo-login { height: 28px; width: auto; align-self: flex-start; filter: brightness(0) invert(1); margin-bottom: 1.25rem; }
.login-card h1 { font-size: 1.25rem; margin: 0 0 0.75rem; }
.login-card p.muted { font-size: 0.9rem; margin: 0 0 1.25rem; }
label { font-size: 0.85rem; color: #cbd5e1; margin: 0.75rem 0 0.35rem; display: block; }
input, select, textarea {
  width: 100%; padding: 0.6rem 0.75rem; border-radius: 8px;
  border: 1px solid var(--borde); background: #0b0f1a; color: var(--texto);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acento); outline-offset: 1px; }
button {
  cursor: pointer; border: 0; border-radius: 8px; padding: 0.6rem 1rem;
  background: #e5e7eb; color: #0f172a; font-weight: 600;
}
button:disabled { opacity: 0.6; cursor: default; }
#login-btn { margin-top: 1.25rem; padding: 0.7rem; }
.btn-ghost { background: transparent; color: var(--texto); border: 1px solid var(--borde); }

/* Tablero */
#app { max-width: 1200px; margin: 0 auto; padding: 1rem 1.25rem 3rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.5rem 0 1.25rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 0.9rem; font-weight: 700; font-size: 1.1rem; }
.logo-top { height: 24px; filter: brightness(0) invert(1); }
.user { display: flex; align-items: center; gap: 0.75rem; color: #cbd5e1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }
.kpi, .avance, .panel { background: rgba(15, 23, 42, 0.88); border: 1px solid var(--borde); border-radius: 12px; }
.kpi { padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.25rem; }
.kpi-label { color: var(--muted); font-size: 0.85rem; }
.kpi strong { font-size: 1.6rem; }
.avance { margin-top: 0.75rem; padding: 1rem; }
.avance-head { display: flex; justify-content: space-between; margin-bottom: 0.6rem; }
.barra { height: 12px; background: #1e293b; border-radius: 999px; overflow: hidden; }
#barra-fill { height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, #4ade80); transition: width 0.5s ease; }
.panel { margin-top: 0.75rem; padding: 1rem; }
.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.toolbar input { flex: 1 1 240px; width: auto; }
.toolbar select { flex: 0 0 190px; width: auto; }
.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td a { color: #93c5fd; word-break: break-all; }
td .nota { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; color: #0f172a; white-space: nowrap; }
.badge.pendiente { background: var(--pendiente); }
.badge.en_curso { background: var(--en_curso); }
.badge.migrado { background: var(--migrado); }
.badge.bloqueado { background: var(--bloqueado); color: #fff; }
.acciones-fila { white-space: nowrap; display: flex; gap: 0.35rem; }
.acciones-fila button { padding: 0.3rem 0.6rem; font-size: 0.82rem; }
.btn-peligro { background: transparent; color: #fca5a5; border: 1px solid #7f1d1d; }
.vacio { text-align: center; padding: 1.5rem 0; }

/* Dialogo */
dialog { border: 1px solid var(--borde); border-radius: 14px; background: var(--card); color: var(--texto); width: min(640px, 94vw); padding: 1.5rem; }
dialog::backdrop { background: rgba(2, 6, 23, 0.65); }
dialog h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; }
.acciones { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

@media (prefers-reduced-motion: reduce) { #barra-fill { transition: none; } }
