:root {
  --red: #B92117;
  --mustard: #D4AC0D;
  --orange: #D35400;
  --white: #FFFFFF;
  --text: #1f2937;
  --muted: #6b7280;
  --bg: #f8fafc;
  --card: #ffffff;
  --shadow: 0 10px 25px rgba(0, 0, 0, .08);
  --radius: 16px;
}

/* Base */
* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #fff 0%, var(--bg) 100%);
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(90deg, var(--red), var(--orange));
  color: var(--white);
  box-shadow: var(--shadow)
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px
}

.logo {
  font-size: 22px
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto
}

.actions form {
  margin: 0
}

.btn {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, background-color .12s, border-color .12s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(0, 0, 0, .12)
}

.btn.ghost {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 999px;
  padding: 8px 12px
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, .15)
}

.btn.primary {
  background: linear-gradient(90deg, var(--red), var(--orange));
  color: #fff;
  border-color: transparent
}

.btn.danger {
  background: #fff5f5;
  color: #b91c1c;
  border-color: #fecaca
}

.menu-toggle {
  display: none
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid #eef2f7;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 18px 0;
  overflow: hidden;
}

.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid #eef2f7
}

.card-head.row {
  display: flex;
  align-items: center;
  justify-content: space-between
}

.card-head h3 {
  margin: 0;
  font-size: 16px
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: var(--muted);
  font-weight: 700;
  box-shadow: var(--shadow);
}

/* Perfil */
.perfil-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
  padding: 14px 16px
}

.perfil-block .pair {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed #eef2f7
}

.perfil-block .pair span {
  color: var(--muted);
  font-size: 13px
}

.perfil-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  justify-content: center
}

/* Grid usuarios (tarjetas de ancho fijo) */
.users-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-start;
  align-items: stretch;
  padding: 14px 16px;
}

.user-card {
  flex: 0 0 340px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.user-card header {
  display: flex;
  align-items: center;
  justify-content: space-between
}

.user-card h4 {
  margin: 0;
  font-size: 16px
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px
}

.badge.ok {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0
}

.badge.warn {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa
}

.meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px
}

.meta .item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  color: #334155
}

.meta .item span {
  color: var(--muted)
}

.actions-row {
  margin-top: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end
}

/* Gate admin */
.gate {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.gate-box {
  background: #fff;
  width: min(460px, 90vw);
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.gate-box h2 {
  margin: 0 0 8px;
  color: var(--orange)
}

.gate-box form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center
}

.gate-box input {
  width: 100%;
  max-width: 320px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.muted {
  color: #b91c1c;
  min-height: 18px
}

/* Toast */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  min-width: 220px;
  max-width: 320px;
  background: #fff;
  color: var(--text);
  border: 1px solid #e5e7eb;
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 10px 12px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto
}

.toast.ok {
  border-left: 3px solid #10b981
}

.toast.err {
  border-left: 3px solid #ef4444
}

/* Responsive */
@media (max-width:960px) {
  .actions {
    flex-wrap: wrap;
    gap: 8px
  }

  .perfil-grid {
    grid-template-columns: 1fr
  }

  .perfil-actions {
    align-items: flex-start
  }
}

@media (max-width:720px) {
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, .6);
    padding: 8px 12px;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
  }

  .topbar .actions {
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(60px + 8px);
    display: none;
    flex-direction: column;
    gap: 8px;
    background: linear-gradient(90deg, var(--red), var(--orange));
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 12px;
    padding: 10px;
    box-shadow: var(--shadow);
  }

  .topbar .actions.show {
    display: flex
  }

  .topbar .actions .btn {
    width: 100%;
    text-align: left;
    padding: 10px 12px
  }

  .topbar .actions form {
    width: 100%
  }

  .topbar .actions .btn.danger {
    text-align: center
  }

  .users-grid {
    justify-content: center
  }

  /* centradas cuando hay 1–2 cards */
}

/* Campos bonitos dentro de los modales */
.modal .field {
  margin: 8px 0 12px;
  text-align: left;
}

.modal .field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.modal .field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.modal .actions-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.badge.ok {
  background: #e8f9ee;
  color: #16a34a;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.badge.warn {
  background: #fff7ed;
  color: #b45309;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, .15);
  display: none;
  z-index: 9999;
}

/* ===== Layout 2 columnas ===== */
.main-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  /* izquierda + derecha */
  gap: 20px;
  align-items: start;
}

.profile-card {
  /* la card de la izquierda más angosta */
  position: sticky;
  top: 90px;
  /* se queda visible mientras haces scroll */
}

/* La card inferior ocupa ambas columnas */
.span-2 {
  grid-column: 1 / -1;
}

/* ===== Carrusel de activos ===== */
.carousel {
  position: relative;
  padding: 8px 36px;
  /* espacio para flechas */
  isolation: isolate;
  /* que los fades no se tapen entre sí */
}

.carousel-viewport {
  overflow: auto hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.carousel-track {
  display: flex;
  gap: 16px;
  padding: 6px 4px 10px;
}

.carousel-track .user-card {
  flex: 0 0 320px;
  /* ancho de cada tarjeta en el carrusel */
  scroll-snap-align: start;
}

/* Flechas */
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(90deg, var(--red), var(--orange));
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  z-index: 3;
}

.carousel-prev {
  left: 6px;
}

.carousel-next {
  right: 6px;
}

.carousel-btn:disabled {
  opacity: .4;
  cursor: default
}

/* Fades laterales bonitos */
.carousel::before,
.carousel::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28px;
  z-index: 2;
  pointer-events: none;
}

.carousel::before {
  left: 0;
  background: linear-gradient(90deg, #fff, rgba(255, 255, 255, 0));
}

.carousel::after {
  right: 0;
  background: linear-gradient(270deg, #fff, rgba(255, 255, 255, 0));
}

/* ===== Modales (aseguramos estilo bonito) ===== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .45);
  z-index: 2100;
}

.modal.show {
  display: flex;
}

.modal .modal-content {
  background: #fff;
  width: min(520px, 92vw);
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
  position: relative;
}

.modal .close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: 0;
  font-size: 26px;
  color: #64748b;
  cursor: pointer;
}

/* ===== Responsivo ===== */
@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 320px 1fr;
  }
}

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

  .profile-card {
    position: static;
  }

  .span-2 {
    grid-column: auto;
  }

  .carousel-btn {
    display: none;
  }

  /* en móvil se arrastra con el dedo */
  .carousel {
    padding: 8px 0;
  }
}