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

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Inter", sans-serif;
  min-height: 100%;
  background: radial-gradient(circle at top left, #020617 0%, #020617 40%, #0f172a 70%, #1d2247 100%);
  color: #f9fafb;
}

/* LAYOUT PRINCIPAL */
.shell {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR IZQUIERDO */
.main-sidebar {
  width: 250px;
  background: radial-gradient(circle at top left, rgba(15,23,42,0.98), rgba(15,23,42,0.94));
  border-right: 1px solid rgba(129,140,248,0.6);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 12px 0 40px rgba(0,0,0,0.8);
}

.main-sidebar.hidden {
  display: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid rgba(248,250,252,0.9);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sb-title {
  font-size: 0.95rem;
  font-weight: 600;
}
.sb-subtitle {
  font-size: 0.7rem;
  color: #9ca3af;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-nav-item {
  border-radius: 999px;
  border: none;
  padding: 8px 12px;
  text-align: left;
  background: transparent;
  color: #9ca3af;
  font-size: 0.86rem;
  cursor: pointer;
  transition: all 0.18s ease-out;
}

.sidebar-nav-item:hover {
  background: rgba(15,23,42,0.9);
  color: #e5e7eb;
}

.sidebar-nav-item.active {
  background: linear-gradient(135deg, #4f46e5, #ec4899);
  color: #f9fafb;
  box-shadow: 0 10px 26px rgba(15,23,42,0.9);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 0.7rem;
  color: #9ca3af;
}

.sb-email {
  word-break: break-all;
}

/* CONTENIDO PRINCIPAL */
.main-content {
  flex: 1;
  padding: 16px 18px 28px;
  max-width: 1100px;
  margin: 0 auto;
}

/* HEADER SUPERIOR */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  margin-bottom: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(56,189,248,0.22), rgba(139,92,246,0.4), rgba(244,63,94,0.32));
  box-shadow: 0 24px 60px rgba(0,0,0,0.65);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(148,163,184,0.5);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  object-fit: cover;
  border: 2px solid rgba(248,250,252,0.75);
  box-shadow: 0 14px 30px rgba(15,23,42,0.75);
}

.brand-text h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
}
.subtitle {
  font-size: 0.76rem;
  color: #e5e7eb;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* BOTONES */
.primary-btn,
.ghost-btn {
  border-radius: 999px;
  border: none;
  font-size: 0.84rem;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease-out;
}

.primary-btn {
  background: linear-gradient(135deg, #ff4f81, #8b5cf6);
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(15,23,42,0.7);
}
.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 42px rgba(15,23,42,0.9);
}

.ghost-btn {
  background: transparent;
  color: #9ca3af;
  border: 1px solid rgba(148,163,184,0.35);
}
.ghost-btn:hover {
  background: rgba(15,23,42,0.75);
  color: #f9fafb;
}

.ghost-small {
  padding: 4px 10px;
  font-size: 0.76rem;
}

.full {
  width: 100%;
}

.danger {
  border-color: #f97373;
  color: #f97373;
}

/* CARDS GENERALES */
.card {
  background: radial-gradient(circle at top left, rgba(15,23,42,0.98), rgba(15,23,42,0.94));
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  border: 1px solid rgba(31,41,55,0.9);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.card-header h2 {
  margin: 0;
  font-size: 1rem;
}

/* AUTH */
.auth-card {
  max-width: 420px;
  margin: 36px auto;
}

.tabs {
  display: flex;
  background: rgba(15,23,42,0.9);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #9ca3af;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.88rem;
}
.tab.active {
  background: radial-gradient(circle at top, #111827, #020617);
  color: #f9fafb;
  box-shadow: 0 10px 24px rgba(15,23,42,0.95);
}

/* FORMULARIOS */
.form {
  display: none;
}
.form.active {
  display: block;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.form-group label {
  font-size: 0.78rem;
  color: #9ca3af;
}

.form-group input,
.form-group select,
.form-group textarea {
  border-radius: 10px;
  border: 1px solid rgba(148,163,184,0.45);
  padding: 8px 10px;
  background: rgba(15,23,42,0.96);
  color: #f9fafb;
  outline: none;
  font-size: 0.88rem;
}
.form-group textarea {
  resize: vertical;
}

.helper-text {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 6px;
}

/* DASHBOARD */
.dashboard {
  margin-bottom: 16px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  padding: 10px 12px;
  border-radius: 16px;
  background: radial-gradient(circle at top, #111827, #020617);
  border: 1px solid rgba(148,163,184,0.4);
  color: #e5e7eb;
}
.stat-label {
  font-size: 0.76rem;
  color: #9ca3af;
}
.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
}

.stat-green {
  background: linear-gradient(135deg, rgba(34,197,94,0.35), #052e16);
}
.stat-amber {
  background: linear-gradient(135deg, rgba(245,158,11,0.4), #451a03);
}
.stat-red {
  background: linear-gradient(135deg, rgba(239,68,68,0.4), #450a0a);
}

/* SECCIONES */
.page-section {
  margin-top: 12px;
}

/* TABLAS */
.table-wrapper {
  overflow-x: auto;
  margin-top: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
thead {
  background: rgba(15,23,42,0.96);
}
th,
td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid rgba(31,41,55,0.9);
}
th {
  font-weight: 500;
  color: #e5e7eb;
  white-space: nowrap;
}
tbody tr:hover {
  background: rgba(15,23,42,0.82);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* SIDEBAR DERECHO */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 90%;
  height: 100vh;
  background: radial-gradient(circle at top, #020617, #020617);
  box-shadow: -28px 0 65px rgba(0,0,0,0.9);
  border-left: 1px solid rgba(148,163,184,0.5);
  transform: translateX(100%);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease-out;
  z-index: 60;
  backdrop-filter: blur(24px);
}
.sidebar.open {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
}
.sidebar.hidden {
  display: none;
}
.sidebar-inner {
  padding: 18px 18px 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sidebar-subtitle {
  font-size: 0.75rem;
  color: #9ca3af;
}
.sidebar-form {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

/* MODALES */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
}
.modal.hidden {
  display: none;
}
.modal-content {
  width: 100%;
  max-width: 460px;
  background: radial-gradient(circle at top, #020617, #020617);
  border-radius: 20px;
  padding: 16px 18px 18px;
  box-shadow: 0 22px 50px rgba(0,0,0,0.9);
  border: 1px solid rgba(129,140,248,0.6);
}
.modal-content h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.modal-helper {
  font-size: 0.76rem;
  color: #9ca3af;
  margin-bottom: 8px;
}
.modal-content textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(148,163,184,0.4);
  background: rgba(15,23,42,0.96);
  color: #f9fafb;
  padding: 8px 10px;
  resize: vertical;
  min-height: 120px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* SERVICIOS IPTV - TARJETAS MEDIANAS */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.service-card {
  position: relative;
  border-radius: 20px;
  padding: 12px 12px 12px;
  background: radial-gradient(circle at top left, #020617, #020617);
  border: 1px solid rgba(129,140,248,0.6);
  box-shadow: 0 16px 40px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.service-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.service-logo,
.service-logo-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid rgba(248,250,252,0.9);
}
.service-logo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #4f46e5, #ec4899);
  color: #f9fafb;
  font-size: 0.9rem;
  font-weight: 600;
}
.service-name {
  font-size: 0.96rem;
  font-weight: 600;
}
.service-url,
.service-links {
  font-size: 0.78rem;
  color: #9ca3af;
  white-space: pre-wrap;
}
.service-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,23,42,0.98);
  border-radius: 999px;
  padding: 10px 18px;
  color: #e5e7eb;
  font-size: 0.84rem;
  box-shadow: 0 18px 45px rgba(0,0,0,0.9);
  z-index: 90;
  border: 1px solid rgba(148,163,184,0.6);
}
.toast.hidden {
  display: none;
}

/* UTILIDADES */
.hidden {
  display: none !important;
}
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .shell {
    flex-direction: column;
  }
  .main-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .sidebar-nav {
    flex-direction: row;
  }
  .main-content {
    padding: 12px 12px 24px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
