/* ============================================
   MXTunnel Panel — "Terminal Pro" UI
   Paleta basada en terminal.html (negro + verde neón)
   Todo en JetBrains Mono. Dark.
   ============================================ */

:root {
  /* Backgrounds */
  --bg:         #0a0a0a;
  --bg-1:       #111111;
  --bg-2:       #161616;
  --bg-3:       #1a1a1a;

  /* Texto */
  --ink:        #e4e4e4;
  --ink-2:      #b8b8b8;
  --ink-3:      #6e6e6e;
  --dim:        #5c5c5c;

  /* Acentos */
  --accent:     #00ff88;
  --accent-d:   #00cc6e;
  --accent-glow:rgba(0, 255, 136, 0.22);
  --cyan:       #5ee7ff;
  --amber:      #ffb000;
  --danger:     #ff5c5c;

  /* Bordes */
  --border:     #1f1f1f;
  --border-hi:  #2a2a2a;

  /* Radios */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* Sombras */
  --shadow-card: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.28);
  --shadow-lift: 0 2px 4px rgba(0,0,0,.5), 0 16px 44px rgba(0,0,0,.4);
  --glow-accent: 0 0 0 1px rgba(0,255,136,.15), 0 0 24px rgba(0,255,136,.12);

  /* Fuentes */
  --f-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --f-body: var(--f-mono);

  /* Layout */
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
}
[data-bs-theme="dark"] { color-scheme: dark; }

::selection { background: rgba(0,255,136,.25); color: #fff; }

/* Focus visible global (accesibilidad) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a:focus-visible, button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================
   Background: glows animados (panel)
   ============================================ */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(110px);
  opacity: .14;
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
.bg-glow-1 {
  width: 560px; height: 560px;
  top: -160px; left: -180px;
  background: var(--accent);
  animation: drift1 44s ease-in-out infinite;
}
.bg-glow-2 {
  width: 480px; height: 480px;
  top: 34%; right: -220px;
  background: var(--cyan);
  opacity: .09;
  animation: drift2 50s ease-in-out infinite;
}
@keyframes drift1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(120px,80px) scale(1.12); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-110px,70px) scale(.94); } }
@media (prefers-reduced-motion: reduce) {
  .bg-glow-1, .bg-glow-2 { animation: none !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-d); }

/* ============================================
   Layout
   ============================================ */
.app-layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }
.app-main { flex: 1; margin-left: var(--sidebar-w); padding: 2rem 2.25rem; min-width: 0; }

/* ============================================
   Sidebar (terminal)
   ============================================ */
.app-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  position: fixed; top: 0; left: 0;
  background: rgba(10, 10, 10, .9);
  backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 1.4rem 1rem;
  z-index: 100;
}
.app-sidebar .brand {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 700; font-size: .95rem;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink);
  margin-bottom: .3rem;
}
.app-sidebar .brand .brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center;
}
.app-sidebar .brand .brand-mark i { color: var(--accent); font-size: .9rem; }
.app-sidebar .brand::after {
  content: '▌';
  color: var(--accent);
  animation: blink 1.1s steps(2) infinite;
  font-size: .85rem;
}
@keyframes blink { 50% { opacity: 0; } }
.app-sidebar .user-tag {
  font-size: .76rem; color: var(--ink-3);
  margin: .35rem 0 1.25rem; padding-left: .1rem;
  font-family: var(--f-mono);
}
.app-sidebar .user-tag::before { content: '~ $ '; color: var(--accent); }
.app-sidebar .user-tag .badge { margin-left: .4rem; }
.app-sidebar .nav-item { margin-bottom: .15rem; }
.app-sidebar .nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .58rem .8rem;
  border-radius: var(--r-sm);
  border-left: 3px solid transparent;
  color: var(--ink-2);
  font-size: .84rem;
  transition: color .18s, background .18s, transform .18s, border-color .18s;
  text-decoration: none;
  position: relative;
}
.app-sidebar .nav-link::before {
  content: '$';
  color: var(--dim);
  font-size: .72rem;
  transition: color .18s;
  width: .7rem;
}
.app-sidebar .nav-link i { font-size: .92rem; width: 1.05rem; text-align: center; }
.app-sidebar .nav-link span { flex: 1; }
.app-sidebar .nav-link:hover {
  color: var(--ink);
  background: rgba(0,255,136,.06);
  transform: translateX(3px);
}
.app-sidebar .nav-link:hover::before { color: var(--accent); }
.app-sidebar .nav-link.active {
  color: var(--accent);
  background: rgba(0,255,136,.08);
  border-left-color: var(--accent);
}
.app-sidebar .nav-link.active::before { color: var(--accent); }
.app-sidebar .nav-link.active i { color: var(--accent); }

/* Submenú colapsable (p. ej. Aplicación → Ajustes app / Temas) */
.app-sidebar .nav-group { display: flex; flex-direction: column; }
.app-sidebar .nav-group-toggle { width: 100%; border: 0; background: none; cursor: pointer; font-family: inherit; }
.app-sidebar .nav-group-toggle .nav-caret {
  font-size: .7rem; color: var(--ink-3);
  width: auto; flex: none; margin-left: .15rem;
  transition: transform .2s ease;
}
.app-sidebar .nav-group.open .nav-group-toggle .nav-caret { transform: rotate(180deg); }
.app-sidebar .nav-submenu {
  list-style: none;
  margin: 0 0 .2rem;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease;
}
.app-sidebar .nav-group.open .nav-submenu { max-height: 200px; }
.app-sidebar .nav-submenu .nav-link {
  padding: .38rem .6rem .38rem 1.15rem;
  font-size: .8rem;
  color: var(--ink-3);
  border-left: 2px solid transparent;
}
.app-sidebar .nav-submenu .nav-link::before { content: '▸'; width: .7rem; color: var(--dim); font-size: .6rem; }
.app-sidebar .nav-submenu .nav-link i { font-size: .8rem; width: .95rem; }
.app-sidebar .nav-submenu .nav-link:hover { transform: none; background: transparent; color: var(--ink); }
.app-sidebar .nav-submenu .nav-link.active {
  color: var(--accent);
  background: transparent;
  border-left-color: var(--accent);
}
.app-sidebar .nav-submenu .nav-link.active::before,
.app-sidebar .nav-submenu .nav-link.active i { color: var(--accent); }
.app-sidebar .nav-link .nav-ext { font-size: .62rem; color: var(--dim); width: auto; flex: none; margin-left: .1rem; }
.app-sidebar .nav-link:hover .nav-ext { color: var(--accent); }
.app-sidebar .sidebar-footer { margin-top: auto; padding-top: 1rem; }
.app-sidebar .sidebar-footer .btn { width: 100%; }

/* ============================================
   Page header
   ============================================ */
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.75rem;
  gap: 1rem; flex-wrap: wrap;
}
.page-header h3 {
  margin: 0 0 .2rem;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: .02em;
  color: var(--ink);
  display: flex; align-items: center; gap: .6rem;
}
.page-header h3::before { content: '$'; color: var(--accent); font-size: 1rem; }
.page-header .text-muted { font-size: .82rem; color: var(--ink-3) !important; }

/* ============================================
   Cards (superficies)
   ============================================ */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--ink);
  box-shadow: var(--shadow-card);
  transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: var(--border-hi); }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  padding: .9rem 1.2rem;
  color: var(--ink);
  font-size: .9rem;
  display: flex; align-items: center; gap: .55rem;
}
.card-header i { color: var(--accent); }
.card-body { padding: 1.25rem; }

/* ============================================
   Tabs de configuración (categorías / servidores)
   ============================================ */
.config-tabs .card-header {
  display: block;
  padding: 0;
  border-bottom: 1px solid var(--border);
}
.config-tabs .nav-tabs,
.config-tabs .card-header-tabs {
  border-bottom: 0;
  margin: 0;
  gap: .15rem;
}
.config-tabs .nav-link {
  border: 0;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-3);
  font-weight: 500;
  font-size: .8rem;
  letter-spacing: .01em;
  padding: .9rem .85rem .75rem;
  transition: color .15s, border-color .15s;
}
.config-tabs .nav-link:hover { color: var(--ink); }
.config-tabs .nav-link:focus-visible { outline-offset: -2px; }
.config-tabs .nav-link.active {
  background: transparent;
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.config-tabs .nav-link .badge {
  background: var(--bg-3);
  color: var(--ink-2);
  font-weight: 600;
  vertical-align: 1px;
}
.config-tabs .nav-link.active .badge {
  background: var(--accent-glow);
  color: var(--accent);
}
.config-tabs .card-body { padding: 1.25rem 1.25rem 1rem; }

/* ============================================
   Stat cards
   ============================================ */
.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.3rem 1.4rem;
  min-height: 108px;
  display: flex; align-items: center; gap: 1rem;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  border-color: rgba(0,255,136,.35);
  transform: translateY(-2px);
  box-shadow: var(--glow-accent);
}
.stat-card::after {
  content: '';
  position: absolute;
  right: 1.2rem; bottom: 1rem;
  width: 54px; height: 22px;
  background-image:
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-size: 4px 38%, 4px 62%, 4px 48%, 4px 84%, 4px 58%, 4px 96%;
  background-position: 0 100%, 10px 100%, 20px 100%, 30px 100%, 40px 100%, 50px 100%;
  opacity: .5;
  pointer-events: none;
}
.stat-card .icon-box {
  width: 44px; height: 44px;
  border-radius: 11px;
  background: var(--bg-3);
  border: 1px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; flex-shrink: 0;
  color: var(--accent);
}
.stat-card .icon-box.success { color: var(--accent); border-color: rgba(0,255,136,.35); }
.stat-card .icon-box.warning { color: var(--amber); border-color: rgba(255,176,0,.35); }
.stat-card .icon-box.danger  { color: var(--danger); border-color: rgba(255,92,92,.35); }
.stat-card .icon-box.info    { color: var(--cyan); border-color: rgba(94,231,255,.35); }
.stat-card .icon-box.indigo  { color: var(--accent); border-color: rgba(0,255,136,.35); }
.stat-card .label {
  font-family: var(--f-mono);
  font-size: 9px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-3);
  margin-bottom: .3rem; font-weight: 600;
}
.stat-card .value {
  font-family: var(--f-mono); font-weight: 700;
  font-size: 1.6rem; color: var(--ink);
  letter-spacing: -.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-card .value small { font-size: .8rem; font-weight: 500; color: var(--ink-2); margin-left: 4px; }
.stat-card .sub { color: var(--ink-3); font-size: .72rem; margin-top: .2rem; font-family: var(--f-mono); }

/* ============================================
   Welcome card (dashboard)
   ============================================ */
.welcome-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.8rem 2rem;
  margin-bottom: 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 2rem;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.welcome-card::before {
  content: '';
  position: absolute;
  top: -60%; left: -10%;
  width: 60%; height: 220%;
  background: radial-gradient(circle, rgba(0,255,136,.08), transparent 62%);
  pointer-events: none;
}
.welcome-left { position: relative; z-index: 1; }
.welcome-eyebrow {
  font-size: 10px; letter-spacing: .2em;
  color: var(--accent); text-transform: uppercase;
  font-weight: 600;
  margin-bottom: .7rem;
  display: inline-flex; align-items: center; gap: .5rem;
}
.welcome-eyebrow::before { content: '$'; }
.welcome-title {
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -.02em;
  color: var(--ink);
  margin: 0 0 .45rem;
}
.welcome-sub { font-size: .9rem; color: var(--ink-2); margin: 0; }
.welcome-right {
  position: relative; z-index: 1;
  min-width: 250px;
  display: flex; flex-direction: column; gap: .6rem;
}
.welcome-info-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .8rem;
  background: rgba(0,0,0,.3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.welcome-info-row .info-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: .85rem; flex-shrink: 0;
}
.welcome-info-row .info-text { display: flex; flex-direction: column; min-width: 0; }
.welcome-info-row .info-label {
  font-size: 8px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600;
}
.welcome-info-row .info-value {
  color: var(--ink); font-size: .82rem;
  font-family: var(--f-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.welcome-info-row .info-value code { color: var(--accent); background: transparent; padding: 0; font-size: .76rem; }
.welcome-info-row .copy-btn {
  background: transparent; border: 1px solid var(--border-hi);
  color: var(--ink-2); border-radius: 6px;
  padding: 2px 7px; font-size: .72rem;
  margin-left: auto; cursor: pointer;
  transition: all .18s;
}
.welcome-info-row .copy-btn:hover { color: var(--accent); border-color: var(--accent); box-shadow: var(--glow-accent); }

@media (max-width: 768px) {
  .welcome-card { flex-direction: column; align-items: flex-start; gap: 1.2rem; padding: 1.4rem; }
  .welcome-right { width: 100%; min-width: 0; }
}

/* ============================================
   Tables (terminal)
   ============================================ */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: rgba(0,255,136,.05);
  color: var(--ink);
  margin-bottom: 0;
}
.table thead th {
  background: var(--bg-2);
  color: var(--ink-3);
  font-weight: 600;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
  border: 0;
  padding: .7rem 1rem;
  white-space: nowrap;
}
.table thead th:first-child { border-radius: 8px 0 0 8px; }
.table thead th:last-child { border-radius: 0 8px 8px 0; }
.table tbody td {
  border-color: var(--border);
  padding: .75rem 1rem;
  vertical-align: middle;
}
.table-hover tbody tr {
  transition: background .15s;
}
.table-hover tbody tr:hover td { background: rgba(0,255,136,.05); }
.table tbody td:first-child { border-left: 2px solid transparent; border-radius: 8px 0 0 8px; }
.table-hover tbody tr:hover td:first-child { border-left-color: var(--accent); }
.table code {
  color: var(--accent);
  background: rgba(0,255,136,.08);
  padding: .15rem .45rem;
  border-radius: 5px;
  font-size: .76rem;
  font-family: var(--f-mono);
}
.table-responsive { position: relative; }
.table-responsive thead th { position: sticky; top: 0; z-index: 2; }

/* ============================================
   Buttons (terminal)
   ============================================ */
.btn {
  border-radius: var(--r-sm);
  font-weight: 600;
  transition: all .18s;
  font-family: var(--f-body);
  font-size: .85rem;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.5;
}
.btn i { line-height: 1; flex: none; }

.btn-primary {
  background: var(--accent);
  color: #06130d;
  box-shadow: 0 0 20px rgba(0,255,136,.2);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-d);
  color: #06130d;
  transform: translateY(-1px);
  box-shadow: 0 0 28px rgba(0,255,136,.35);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline-primary {
  color: var(--accent);
  border: 1px solid rgba(0,255,136,.35);
  background: transparent;
}
.btn-outline-primary:hover {
  background: rgba(0,255,136,.1);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--glow-accent);
}

.btn-success { background: var(--accent); color: #06130d; }
.btn-success:hover { background: var(--accent-d); color: #06130d; }

.btn-danger  { background: var(--danger); color: #1a0505; box-shadow: 0 0 18px rgba(255,92,92,.18); }
.btn-danger:hover { background: #ff4a4a; color: #1a0505; box-shadow: 0 0 26px rgba(255,92,92,.32); }
.btn-outline-danger {
  color: var(--danger);
  border: 1px solid rgba(255,92,92,.4);
  background: transparent;
}
.btn-outline-danger:hover { background: rgba(255,92,92,.12); color: var(--danger); border-color: var(--danger); }

.btn-secondary {
  background: var(--bg-3);
  border-color: var(--border-hi);
  color: var(--ink-2);
}
.btn-secondary:hover { background: var(--border-hi); border-color: var(--border-hi); color: var(--ink); }
.btn-outline-secondary {
  color: var(--ink-2);
  border: 1px solid var(--border-hi);
  background: transparent;
}
.btn-outline-secondary:hover { background: var(--bg-2); color: var(--ink); border-color: var(--border-hi); }

.btn-link { color: var(--accent); text-decoration: none; }
.btn-link:hover { color: var(--accent-d); text-decoration: underline; }

/* Botones solo-ícono circulares */
.btn-icon {
  width: 32px; height: 32px;
  padding: 0; display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: 8px;
}

.btn-sm { padding: .32rem .7rem; font-size: .78rem; }
.btn .spinner-border { width: .9rem; height: .9rem; border-width: .14rem; }

/* Iconos de acciones de fila (tablas y listas): tamaño uniforme para que
   ningún glifo se vea más chico que el resto (sin tocar el tamaño del botón). */
.table .btn-sm i,
.list-group-item .btn-sm i {
  font-size: .92rem;
  line-height: 1;
}

/* ============================================
   Forms (terminal)
   ============================================ */
.form-control, .form-select {
  background: var(--bg-3);
  border: 1px solid var(--border-hi);
  color: var(--ink);
  border-radius: var(--r-sm);
  font-size: .85rem;
  padding: .55rem .8rem;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.form-control:focus, .form-select:focus {
  background: var(--bg-2);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px rgba(0,255,136,.12);
  color: var(--ink);
}
.form-control::placeholder { color: var(--ink-3); }
.form-label { font-size: .78rem; font-weight: 600; color: var(--ink-2); margin-bottom: .35rem; letter-spacing: .02em; }
.form-label::before { content: '> '; color: var(--accent); }
.form-control:disabled, .form-control[readonly] { background: rgba(0,0,0,.3); color: var(--ink-3); }
.form-control[type="color"] { padding: .25rem; height: 38px; }
.font-monospace { font-family: var(--f-mono) !important; }

.form-hint {
  font-size: .72rem;
  color: var(--ink-3);
  margin-top: .3rem;
  font-family: var(--f-mono);
  letter-spacing: .01em;
}
.form-hint::before { content: '$ '; color: var(--accent); opacity: .7; }

/* Bloque de switches: 2 columnas en lg, 1 en md- */
.cfg-switches { display: grid; gap: .55rem; grid-template-columns: 1fr; }
@media (min-width: 992px) {
  .cfg-switches { grid-template-columns: 1fr 1fr; }
}

.form-check-label { color: var(--ink-2); font-size: .85rem; }
.form-check-input { background-color: var(--bg-3); border-color: var(--border-hi); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(0,255,136,.12); border-color: var(--accent); }

/* Toggle switch */
.form-switch .form-check-input {
  width: 2.4em; height: 1.3em;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23b8b8b8'/%3e%3c/svg%3e");
}
.form-switch .form-check-input:checked { background-color: var(--accent); border-color: var(--accent); background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%230a0a0a'/%3e%3c/svg%3e"); }

/* ============================================
   Modal
   ============================================ */
.modal-content {
  background: var(--bg-1);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-lg);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  position: relative;
}
.modal-content::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), rgba(0,255,136,.1));
  z-index: 5;
}
.modal-header { border-bottom: 1px solid var(--border); padding: 1rem 1.4rem; }
.modal-header .modal-title i { color: var(--accent); margin-right: .4rem; }
.modal-footer { border-top: 1px solid var(--border); padding: 1rem 1.4rem; }
.modal-title { font-weight: 700; font-size: 1.02rem; }
.btn-close { filter: invert(1) grayscale(100%) brightness(200%); opacity: .6; }
.btn-close:hover { opacity: 1; }
.modal-backdrop.show { opacity: .72; }
.modal-backdrop { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

/* ============================================
   Toast
   ============================================ */
.toast-container { z-index: 1090; }
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  position: relative;
  --toast-delay: 3500ms;
  animation: toastIn .3s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) translateX(6px); }
  to { opacity: 1; transform: none; }
}
.toast .toast-body { padding: .8rem 1rem .95rem; display: flex; align-items: center; gap: .6rem; font-size: .82rem; }
.toast .toast-body i { font-size: 1.05rem; }
.toast .toast-progress {
  position: absolute; left: 0; bottom: 0;
  height: 2px; width: 100%;
  background: currentColor;
  transform-origin: left center;
  animation: toastProgress var(--toast-delay) linear forwards;
  opacity: .8;
}
@keyframes toastProgress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.toast.toast-success { border-left: 3px solid var(--accent); color: var(--ink); }
.toast.toast-success i, .toast.toast-success .toast-progress { color: var(--accent); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-error i, .toast.toast-error .toast-progress { color: var(--danger); }
.toast.toast-info { border-left: 3px solid var(--cyan); }
.toast.toast-info i, .toast.toast-info .toast-progress { color: var(--cyan); }
.toast.toast-warning { border-left: 3px solid var(--amber); }
.toast.toast-warning i, .toast.toast-warning .toast-progress { color: var(--amber); }

/* ============================================
   Badges
   ============================================ */
.badge {
  font-weight: 600; padding: .32em .62em;
  font-family: var(--f-mono); font-size: .68rem;
  letter-spacing: .06em;
  border-radius: 6px;
}
.badge.bg-success { background: rgba(0,255,136,.12) !important; color: var(--accent) !important; border: 1px solid rgba(0,255,136,.3); }
.badge.bg-danger  { background: rgba(255,92,92,.12) !important; color: var(--danger) !important; border: 1px solid rgba(255,92,92,.3); }
.badge.bg-warning { background: rgba(255,176,0,.12) !important; color: var(--amber) !important; border: 1px solid rgba(255,176,0,.3); }
.badge.bg-secondary { background: rgba(184,184,184,.1) !important; color: var(--ink-2) !important; border: 1px solid var(--border-hi); }
.badge.bg-primary { background: rgba(0,255,136,.12) !important; color: var(--accent) !important; border: 1px solid rgba(0,255,136,.3); }

/* ============================================
   Alerts
   ============================================ */
.alert {
  border-radius: var(--r-sm);
  border: 1px solid var(--border-hi);
  background: var(--bg-2);
  color: var(--ink);
  font-size: .85rem;
}
.alert-danger { background: rgba(255,92,92,.1); border-color: rgba(255,92,92,.3); color: #ffd9d9; }
.alert-warning { background: rgba(255,176,0,.08); border-color: rgba(255,176,0,.3); color: #ffe9b8; }

/* ============================================
   Empty state
   ============================================ */
.empty-state { text-align: center; padding: 2.6rem 1.5rem; color: var(--ink-2); }
.empty-state i { font-size: 2.4rem; color: var(--ink-3); margin-bottom: .9rem; display: block; }
.empty-state h6 { color: var(--ink); font-weight: 700; }
.empty-state p { font-size: .84rem; margin-bottom: 1rem; color: var(--ink-3); }

/* ============================================
   Text helpers
   ============================================ */
.text-muted, .text-secondary { color: var(--ink-3) !important; }
.text-warning { color: var(--amber) !important; }
h1, h2, h3, h4, h5, h6 { color: var(--ink); font-family: var(--f-mono); }

/* ============================================
   Login
   ============================================ */
.login-shell {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 90% 55% at 12% -5%, rgba(0,255,136,.09) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 105% 105%, rgba(94,231,255,.07) 0%, transparent 55%),
    radial-gradient(ellipse 80% 60% at 50% 0%, #101010 0%, var(--bg) 60%);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
.login-card {
  background: var(--bg-1);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-xl);
  padding: 2.4rem;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lift);
  position: relative;
  animation: loginIn .55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.login-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), rgba(0,255,136,.08));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
@keyframes loginIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.login-card .brand-row {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  margin-bottom: .7rem;
  font-size: 1.15rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
}
.login-card .brand-row .brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--bg-3);
  border: 1px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center;
}
.login-card .brand-row .brand-mark i { color: var(--accent); font-size: 1rem; }

/* Logo (candado SVG) dentro del brand-mark: verde neón y centrado */
.brand-mark { color: var(--accent); }
.brand-mark svg {
  width: 62%; height: 62%;
  flex: none;
  display: block;
}
.login-card .subtitle {
  text-align: center; color: var(--ink-3); margin-bottom: 1.8rem;
  font-size: .78rem; letter-spacing: .06em;
}
.login-card .subtitle::before { content: '$ '; color: var(--accent); }

/* ============================================
   Chart
   ============================================ */
.chart-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-card);
}
.chart-card h6 {
  color: var(--ink-3);
  font-size: 9px; letter-spacing: .18em; text-transform: uppercase;
  margin-bottom: 1rem;
  font-weight: 600;
}
.chart-card h6 i { color: var(--accent); }
.chart-wrap { position: relative; height: 280px; }

/* ============================================
   Color dot
   ============================================ */
.color-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.15);
  vertical-align: middle;
}

/* ============================================
   Token
   ============================================ */
.token-box {
  background: rgba(0,0,0,.35);
  border: 1px dashed var(--border-hi);
  border-radius: var(--r-sm);
  padding: .6rem .9rem;
  font-family: var(--f-mono);
  font-size: .78rem;
  color: var(--accent);
  word-break: break-all;
}
.token-highlight {
  display: inline-block;
  background: var(--accent);
  color: #06130d;
  padding: .55rem 1rem;
  border-radius: var(--r-sm);
  font-family: var(--f-mono);
  font-size: .82rem;
  letter-spacing: .01em;
  box-shadow: 0 0 22px rgba(0,255,136,.25);
  word-break: break-all;
  user-select: all;
  border: none;
}
.token-highlight code { color: #06130d !important; background: transparent !important; padding: 0 !important; font-size: inherit !important; }

/* ============================================
   Profile
   ============================================ */
.profile-section {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.6rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
}
.profile-section h6 {
  color: var(--ink-3);
  font-size: 9px; letter-spacing: .18em; text-transform: uppercase;
  margin-bottom: 1rem;
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex; align-items: center; gap: .5rem;
}
.profile-section h6::before { content: '$'; color: var(--accent); font-size: .9rem; }
.dl-info { margin-bottom: 0; }
.dl-info dt { color: var(--ink-3); font-weight: 500; padding: .35rem 0; font-size: .78rem; }
.dl-info dd { padding: .35rem 0; color: var(--ink); font-size: .85rem; }

/* ============================================
   Section divider
   ============================================ */
.section-divider {
  border-top: 1px solid var(--border);
  padding-top: .85rem;
  margin-top: 1.2rem !important;
  display: flex; align-items: center; gap: .5rem;
}
.section-divider strong {
  color: var(--accent);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 600;
}
.section-divider i { color: var(--accent); font-size: .9rem; }

/* ============================================
   Grupos colapsables (edit-server) — <details>
   ============================================ */
details.cfg-group {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-1);
  margin-bottom: .75rem;
  overflow: hidden;
  transition: border-color .18s;
}
details.cfg-group[open] { border-color: var(--border-hi); }
details.cfg-group summary {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .95rem;
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
  font-size: .8rem;
  list-style: none;
  user-select: none;
}
details.cfg-group summary::-webkit-details-marker { display: none; }
details.cfg-group summary::before { content: '$'; color: var(--accent); font-size: .8rem; font-weight: 700; }
details.cfg-group summary .cfg-count { margin-left: auto; font-size: .68rem; color: var(--ink-3); }
details.cfg-group summary .chev { color: var(--ink-3); font-size: .72rem; transition: transform .2s; margin-left: .35rem; }
details.cfg-group[open] summary .chev { transform: rotate(90deg); color: var(--accent); }
details.cfg-group summary:hover { background: rgba(0,255,136,.04); }
details.cfg-group .cfg-body {
  padding: .85rem .95rem 1rem;
  border-top: 1px solid var(--border);
}

/* ============================================
   Temas — tarjetas con miniatura
   ============================================ */
.theme-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.theme-card:hover { border-color: rgba(0,255,136,.35); transform: translateY(-2px); box-shadow: var(--glow-accent); }
.theme-card-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-thumb { position: relative; width: 100%; overflow: hidden; background: #0B0B0B; }
.theme-thumb iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: top left; }
/* Thumb que ocupa todo el alto disponible de la card, con scroll interno si hace falta */
.theme-thumb-fill { flex: 1; min-height: 340px; max-height: 380px; overflow-y: auto; pointer-events: auto; overflow-x: hidden; }
.theme-thumb-lg { max-width: 360px; margin: 0 auto; overflow-y: auto; pointer-events: auto; }
.theme-card-body { padding: 8px 12px; }
.theme-card-actions { padding: 0 12px 10px; display: flex; gap: 6px; }
.theme-card-actions .btn { font-size: .7rem; line-height: 1.2; padding: .2rem .4rem; }
.theme-card-actions .btn i { font-size: .68rem; }

/* ============================================
   List groups
   ============================================ */
.list-group-item {
  background: var(--bg-1);
  border-color: var(--border);
  color: var(--ink);
}
.list-group-item strong { color: var(--ink); }

/* ============================================
   Animaciones
   ============================================ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn .3s ease-out both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ============================================
   Responsive — mobile + tablet
   ============================================ */

/* Sidebar toggle (inyectado por JS, solo móvil/tablet) */
.sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 50;
  width: 42px;
  height: 42px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-1);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: border-color .18s, color .18s, transform .12s, opacity .18s;
  padding: 0;
}
.sidebar-toggle:hover { border-color: var(--accent); color: var(--accent); }
.sidebar-toggle:active { transform: scale(.96); }
.sidebar-toggle.hidden { opacity: 0; pointer-events: none; }

/* Backdrop del sidebar móvil */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

/* Botón cerrar dentro del sidebar (oculto en desktop) */
.app-sidebar .btn-close-sidebar {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: .95rem;
  cursor: pointer;
  z-index: 5;
  transition: color .18s, border-color .18s;
}
.app-sidebar .btn-close-sidebar:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- Tablet (769–991px): sidebar oculta + ajustes intermedios ---- */
@media (max-width: 991px) {
  .sidebar-toggle { display: flex; }

  .app-sidebar {
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 4px 0 28px rgba(0,0,0,.55);
  }
  .app-sidebar.show {
    transform: translateX(0);
    /* Al estar sobre el backdrop, su propio backdrop-filter ya no aporta
       nada y vuelve el sidebar borroso. Lo neutralizamos y damos fondo
       sólido para que se lea bien y los clicks se enfoquen en los items. */
    background: rgba(10, 10, 10, 0.98);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .app-sidebar .btn-close-sidebar { display: flex; }

  .app-main {
    margin-left: 0;
    padding: 4.25rem 1.1rem 2rem;
  }

  /* Stat cards más compactas en tablet */
  .stat-card { padding: 1.1rem 1.15rem; min-height: 96px; }
  .stat-card .value { font-size: 1.35rem; }

  /* Tablas: padding reducido en tablet (sin romper el layout) */
  .table thead th, .table tbody td {
    padding: .55rem .75rem;
    font-size: .8rem;
  }

  /* Gráfico admin */
  .chart-wrap { height: 240px; }
}

/* ---- Móvil (<=768px) ---- */
@media (max-width: 768px) {
  .app-main { padding: 4.25rem .85rem 2rem; }

  /* Reducir glows de fondo para que no causen overflow-x */
  .bg-glow-1 { width: 360px !important; height: 360px !important; filter: blur(80px) !important; opacity: .1 !important; }
  .bg-glow-2 { width: 320px !important; height: 320px !important; filter: blur(80px) !important; opacity: .07 !important; }

  /* Page-header: título arriba, botones debajo a ancho completo */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: .85rem;
    margin-bottom: 1.25rem;
  }
  .page-header > .btn,
  .page-header > .d-flex,
  .page-header > a {
    width: 100%;
    justify-content: center;
  }
  .page-header > .d-flex > .btn { width: auto; flex: 1; }

  /* Welcome card del dashboard */
  .welcome-card {
    flex-direction: column;
    align-items: stretch;
    gap: 1.1rem;
    padding: 1.3rem 1.1rem;
  }
  .welcome-right { width: 100%; min-width: 0; }

  /* Profile section */
  .profile-section { padding: 1.15rem 1rem; }
  .dl-info dt, .dl-info dd { padding: .3rem 0; }
  .dl-info dt { font-size: .72rem; }
  .dl-info dd { font-size: .82rem; word-break: break-word; }

  /* Token highlight: wrap correcto en móvil */
  .token-highlight {
    font-size: .72rem;
    padding: .45rem .65rem;
    word-break: break-all;
  }

  /* Tablas: transformar en tarjetas apiladas usando data-label */
  .table-responsive > .table,
  .table-responsive .table {
    border: 0;
  }
  .table-responsive .table thead { display: none; }
  .table-responsive .table tbody,
  .table-responsive .table tr,
  .table-responsive .table td {
    display: block;
    width: 100%;
  }
  .table-responsive .table tbody tr {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: .8rem;
    padding: .25rem;
    box-shadow: var(--shadow-card);
  }
  .table-responsive .table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .65rem .8rem;
    border: 0;
    border-bottom: 1px solid var(--border);
    text-align: right;
    min-height: 44px;
  }
  .table-responsive .table tbody td:last-child {
    border-bottom: 0;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .4rem;
  }
  .table-responsive .table tbody td::before {
    content: attr(data-label);
    color: var(--ink-3);
    font-size: 9px;
    letter-spacing: .14em;
    text-transform: uppercase;
    font-weight: 600;
    text-align: left;
    flex-shrink: 0;
    max-width: 55%;
  }
  /* Override del primer-hijo (border-left + radius) */
  .table-responsive .table tbody td:first-child {
    border-left: 0;
    border-radius: 0;
  }
  /* Empty state: colspan no debe mostrarse como fila normal */
  .table-responsive .table tbody td[colspan] {
    display: block;
    padding: 0;
    border: 0;
  }
  .table-responsive .table tbody td[colspan]::before { display: none; }
  .table-responsive .table tbody td[colspan] .empty-state { padding: 1.6rem 1rem; }

  /* Theme cards: pasar de 2 columnas a 1 en móvil pequeño */
  .theme-card-actions .btn { font-size: .72rem; padding: .25rem .5rem; }

  /* Acciones: el label "Acciones" se come el ancho y queda tapado por el
     toggle. Como los iconos son autoexplicativos, lo ocultamos. */
  .table-responsive .table tbody td[data-label="Acciones"]::before { display: none; }

  /* Switches de tabla: alineación correcta en card */
  .table-responsive .form-check.form-switch { padding-left: 0; }

  /* List-group de categorías (admin/config): apilar en móvil */
  .list-group-item {
    flex-direction: column;
    align-items: stretch !important;
    gap: .65rem;
    padding: .85rem;
  }
  .list-group-item > .d-flex.align-items-center.gap-2 {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .4rem !important;
  }

  /* Modal: ocupar casi todo el ancho en móvil */
  .modal-dialog { margin: .5rem; max-width: calc(100% - 1rem); }
  .modal-content { border-radius: var(--r-md); }
  .modal-body { padding: 1rem; }
  .modal-header, .modal-footer { padding: .75rem 1rem; }

  /* Login / register */
  .login-shell { padding: .75rem; }
  .login-card { padding: 1.5rem 1.2rem; border-radius: var(--r-lg); }
  .login-card .brand-row { font-size: 1rem; }

  /* Stat cards */
  .stat-card { padding: 1rem 1.1rem; min-height: auto; }
  .stat-card .value { font-size: 1.3rem; }

  /* Forms: min-height para touch targets */
  .form-control, .form-select { min-height: 42px; }

  /* Section divider más compacto */
  .section-divider { margin-top: 1rem !important; padding-top: .65rem; }

  /* cfg-switches en una columna ya es el default, pero asegura padding */
  .cfg-switches { gap: .35rem; }
  details.cfg-group summary { padding: .65rem .85rem; }
  details.cfg-group .cfg-body { padding: .75rem .85rem .9rem; }

  /* Chart */
  .chart-wrap { height: 220px; }

  /* Badges más pequeños en rows para que no rompan */
  .table-responsive .table .badge { font-size: .65rem; }
}

/* ---- Móvil pequeño (<=576px) ---- */
@media (max-width: 576px) {
  .app-main { padding: 4.25rem .75rem 2rem; }

  /* Toast: top-center en lugar de bottom-right */
  .toast-container {
    top: .75rem !important;
    right: .75rem !important;
    left: .75rem !important;
    bottom: auto !important;
    padding: 0 !important;
  }
  .toast-container .toast { width: 100%; max-width: 100%; }

  /* Glows aún más sutiles */
  .bg-glow-1 { width: 260px !important; height: 260px !important; }
  .bg-glow-2 { width: 220px !important; height: 220px !important; }

  /* Botones principales a ancho completo en formularios cortos */
  .profile-section .btn { width: 100%; }
  .profile-section .d-flex { flex-direction: column; align-items: stretch !important; }
  .profile-section .token-highlight + .btn { width: 100%; margin-top: .35rem; }

  /* Footer del sidebar: el botón de logout a ancho completo ya está, ok */

  /* Page header h3 más pequeño */
  .page-header h3 { font-size: 1.15rem; }
  .page-header .text-muted { font-size: .75rem; }
}

/* ---- Tablet intermedia (769–991px): ajustes específicos sin sidebar toggle conflict ---- */
@media (min-width: 769px) and (max-width: 991px) {
  /* Garantiza que el contenido aproveche mejor el ancho */
  .welcome-card { padding: 1.5rem 1.4rem; gap: 1.5rem; }
  .welcome-right { min-width: 220px; }

  /* Listas de acciones en celdas: que no se desborden */
  .table tbody td { font-size: .78rem; }
}
