*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --acento:       #6366f1;
  --acento-dark:  #4f46e5;
  --fondo:        #f1f5f9;
  --blanco:       #ffffff;
  --texto:        #1e293b;
  --texto-suave:  #64748b;
  --borde:        #e2e8f0;
  --cab:          #1e293b;
  --ok:           #10b981;
  --error:        #ef4444;
  --radio:        10px;
  --sombra:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  min-height: 100vh;
}

.oculto { display: none !important; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: .9rem;
  z-index: 9999;
  animation: fadeToast .25s ease;
  white-space: nowrap;
}
@keyframes fadeToast {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
}

/* ── LOGIN ── */
#pantalla-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #312e81 100%);
}

.login-caja {
  background: var(--blanco);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 40px rgba(0,0,0,.3);
  text-align: center;
}

.login-logo  { font-size: 3rem; margin-bottom: 8px; }
.login-caja h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.login-sub   { color: var(--texto-suave); font-size: .85rem; margin-bottom: 28px; }

#form-login { display: flex; flex-direction: column; gap: 12px; }

#form-login input {
  padding: 12px 14px;
  border: 1.5px solid var(--borde);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
}
#form-login input:focus { border-color: var(--acento); }

#btn-login {
  padding: 12px;
  background: var(--acento);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background .2s;
}
#btn-login:hover { background: var(--acento-dark); }
#btn-login:disabled { opacity: .6; cursor: not-allowed; }

.error { color: var(--error); font-size: .875rem; }

/* ── CABECERA ── */
#cabecera {
  background: var(--cab);
  color: white;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.cab-izq       { display: flex; align-items: center; gap: 10px; }
.cab-logo      { font-size: 1.4rem; }
.cab-titulo    { font-size: 1.1rem; font-weight: 700; }
.cab-der       { display: flex; align-items: center; gap: 12px; }
.cab-usuario   { font-size: .82rem; color: #94a3b8; }

.btn-salir {
  padding: 6px 14px;
  background: rgba(255,255,255,.1);
  color: white;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px;
  font-size: .85rem;
  cursor: pointer;
  transition: background .2s;
}
.btn-salir:hover { background: rgba(255,255,255,.2); }

/* ── MAIN ── */
#contenido {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px;
}

.vista-cab {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.vista-cab h2 { font-size: 1.4rem; font-weight: 700; }

.btn-nuevo {
  margin-left: auto;
  padding: 9px 18px;
  background: var(--acento);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-nuevo:hover { background: var(--acento-dark); }

.btn-volver {
  padding: 7px 14px;
  background: white;
  color: var(--texto);
  border: 1.5px solid var(--borde);
  border-radius: 8px;
  font-size: .9rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-volver:hover { border-color: var(--acento); color: var(--acento); }

/* ── RESUMEN ── */
.resumen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.resumen-card {
  background: white;
  border-radius: var(--radio);
  padding: 20px;
  box-shadow: var(--sombra);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.res-num   { font-size: 1.9rem; font-weight: 700; color: var(--acento); }
.res-label { font-size: .78rem; color: var(--texto-suave); text-transform: uppercase; letter-spacing: .5px; }

/* ── TABLA ── */
.tabla-wrap {
  background: white;
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  padding: 14px 16px;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--texto-suave);
  border-bottom: 1.5px solid var(--borde);
}

tbody tr {
  border-bottom: 1px solid var(--borde);
  cursor: pointer;
  transition: background .12s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

tbody td { padding: 14px 16px; font-size: .9rem; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
}
.badge-basico    { background: #dbeafe; color: #1d4ed8; }
.badge-completo  { background: #dcfce7; color: #166534; }
.badge-activo    { background: #d1fae5; color: #065f46; }
.badge-prueba    { background: #ede9fe; color: #5b21b6; }
.badge-suspendido { background: #fee2e2; color: #991b1b; }
.badge-cancelado { background: #f1f5f9; color: #64748b; }

.link-app {
  color: var(--acento);
  font-size: .82rem;
  text-decoration: none;
}
.link-app:hover { text-decoration: underline; }

.td-acciones { text-align: right; }

.btn-editar {
  padding: 5px 12px;
  background: white;
  color: var(--texto);
  border: 1.5px solid var(--borde);
  border-radius: 6px;
  font-size: .82rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-editar:hover { border-color: var(--acento); color: var(--acento); }

/* ── FORMULARIO ── */
#vista-formulario {
  background: white;
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 28px;
}

.form-seccion {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--borde);
}
.form-seccion:last-of-type { border-bottom: none; }
.form-seccion h3 {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--texto-suave);
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.campo { display: flex; flex-direction: column; gap: 6px; }
.campo-ancho { grid-column: 1 / -1; }

.campo label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--texto-suave);
}

.campo input,
.campo select,
.campo textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--borde);
  border-radius: 8px;
  font-size: .9rem;
  font-family: inherit;
  color: var(--texto);
  outline: none;
  transition: border-color .2s;
  background: white;
}
.campo input:focus,
.campo select:focus,
.campo textarea:focus { border-color: var(--acento); }

.campo-mono { font-family: 'Courier New', monospace; font-size: .8rem; }

#vista-formulario textarea { resize: vertical; width: 100%; }

.form-acciones {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-guardar {
  padding: 10px 26px;
  background: var(--acento);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-guardar:hover { background: var(--acento-dark); }
.btn-guardar:disabled { opacity: .6; cursor: not-allowed; }

.btn-cancelar {
  padding: 10px 20px;
  background: white;
  color: var(--texto);
  border: 1.5px solid var(--borde);
  border-radius: 8px;
  font-size: .95rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-cancelar:hover { border-color: var(--texto-suave); }

.btn-eliminar {
  margin-left: auto;
  padding: 10px 20px;
  background: white;
  color: var(--error);
  border: 1.5px solid var(--error);
  border-radius: 8px;
  font-size: .95rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-eliminar:hover { background: #fee2e2; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  #contenido { padding: 16px 12px; }
  .resumen-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .campo-ancho { grid-column: 1; }
  .btn-eliminar { margin-left: 0; }
  .cab-usuario { display: none; }
}
