/* ==========================================================================
   SECURYTECH MASTER ENTERPRISE V1.0 — DESIGN SYSTEM & TOKENS CSS (V4.1 FINAL)
   Soporte: Light/Dark Mode | Sidebar Mini Fix | Mobile Dropdowns & Stock Cards
   ========================================================================== */

:root {
  /* 1. Paleta de Marca (Configurable dinámicamente) */
  --brand-primary: #0f766e;
  --brand-primary-hover: #115e59;
  --brand-primary-soft: rgba(15, 118, 110, 0.12);
  --brand-primary-ring: rgba(15, 118, 110, 0.28);
  --accent: var(--brand-primary);
  --accent-hover: var(--brand-primary-hover);
  --accent-soft: var(--brand-primary-soft);
  --accent-ring: var(--brand-primary-ring);

  /* 2. Superficies y Fondos (Light Mode Default) */
  --bg-body: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #e2e8f0;
  --input-bg: #ffffff;

  /* 3. Tipografía y Jerarquía de Texto */
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-on-brand: #ffffff;

  /* 4. Bordes y Divisores */
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  /* 5. Layout (Header & Sidebar) */
  --header-bg: #ffffff;
  --header-text: #0f172a;
  --header-border: #e2e8f0;
  --sidebar-bg-1: #04202f;
  --sidebar-bg-2: #082f49;
  --sidebar-width: 240px;
  --sidebar-mini-width: 64px;
  --header-height: 58px;

  /* 6. Estados Semánticos */
  --st-success: #15803d;
  --st-success-bg: #dcfce7;
  --st-success-border: rgba(21, 128, 61, 0.25);

  --st-warning: #b45309;
  --st-warning-bg: #fef3c7;
  --st-warning-border: rgba(180, 83, 9, 0.25);

  --st-danger: #b91c1c;
  --st-danger-bg: #fee2e2;
  --st-danger-border: rgba(185, 28, 28, 0.25);

  --st-info: #0369a1;
  --st-info-bg: #e0f2fe;
  --st-info-border: rgba(3, 105, 161, 0.25);

  /* 7. Geometría, Sombras y Transiciones */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-pill: 9999px;

  --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 4px 10px -3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 45px -10px rgba(15, 23, 42, 0.16);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);

  --skeleton-base: #e2e8f0;
  --skeleton-highlight: #f8fafc;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ==========================================================================
   DARK MODE TOKENS (html[data-theme="dark"])
   ========================================================================== */
html[data-theme="dark"] {
  --brand-primary: #14b8a6;
  --brand-primary-hover: #0d9488;
  --brand-primary-soft: rgba(20, 184, 166, 0.16);
  --brand-primary-ring: rgba(20, 184, 166, 0.35);

  --bg-body: #0b1120;
  --bg-surface: #111c2d;
  --bg-surface-elevated: #17253b;
  --bg-subtle: #1e293b;
  --bg-muted: #334155;
  --input-bg: #0f172a;

  --text-main: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --border-color: #1e293b;
  --border-strong: #334155;

  --header-bg: #111c2d;
  --header-text: #f1f5f9;
  --header-border: #1e293b;
  --sidebar-bg-1: #020617;
  --sidebar-bg-2: #0f172a;

  --st-success: #4ade80;
  --st-success-bg: rgba(22, 163, 74, 0.18);
  --st-warning: #fbbf24;
  --st-warning-bg: rgba(217, 119, 6, 0.18);
  --st-danger: #f87171;
  --st-danger-bg: rgba(220, 38, 38, 0.18);
  --st-info: #38bdf8;
  --st-info-bg: rgba(2, 132, 199, 0.18);

  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 55px rgba(0, 0, 0, 0.65);

  --skeleton-base: #1e293b;
  --skeleton-highlight: #334155;
}

/* ==========================================================================
   BASE Y RESETEO ENTERPRISE
   ========================================================================== */
body.app,
body {
  font-family: var(--font-sans);
  font-size: 14.5px;
  background-color: var(--bg-body);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color var(--transition-base), color var(--transition-base);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  color: var(--text-main);
  letter-spacing: -0.015em;
}

a {
  color: var(--brand-primary);
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--brand-primary-hover);
  text-decoration: none;
}

:focus-visible {
  outline: 3px solid var(--brand-primary-ring);
  outline-offset: 2px;
}

/* ==========================================================================
   1. HEADER / TOPBAR PERSISTENTE
   ========================================================================== */
.app-header {
  background-color: var(--header-bg) !important;
  border-bottom: 1px solid var(--header-border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  height: var(--header-height);
  padding-right: 18px !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1030;
}

.app-header__logo {
  background-color: var(--sidebar-bg-1) !important;
  color: #ffffff !important;
  font-family: var(--font-sans) !important;
  font-weight: 700;
  font-size: 0.95rem !important;
  line-height: var(--header-height) !important;
  height: var(--header-height);
  width: var(--sidebar-width) !important;
  flex: 0 0 var(--sidebar-width) !important;
  padding: 0 16px !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: width var(--transition-base), flex-basis var(--transition-base), padding var(--transition-base);
}

.app-header__logo i,
.app-header__logo .logo-img-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand-primary);
  color: #ffffff;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.app-sidebar__toggle {
  color: var(--text-secondary) !important;
  width: 38px;
  height: 38px;
  margin-left: 10px;
  padding: 0 !important;
  border-radius: var(--radius-md);
  line-height: 38px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.app-sidebar__toggle:before {
  font-size: 18px !important;
}

.app-sidebar__toggle:hover,
.app-sidebar__toggle:focus {
  color: var(--brand-primary) !important;
  background-color: var(--brand-primary-soft) !important;
}

.app-nav {
  flex: 0 0 auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  margin-left: auto !important;
  margin-bottom: 0;
  padding-left: 0;
  list-style: none;
  gap: 8px;
}

.app-nav > li {
  display: flex;
  align-items: center;
  position: relative;
}

.app-nav__item {
  color: var(--text-secondary) !important;
  height: 38px;
  padding: 0 12px !important;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  line-height: 1 !important;
  transition: all var(--transition-fast);
}

.app-nav__item.icon-btn {
  width: 38px;
  padding: 0 !important;
  background-color: var(--bg-subtle);
  border-color: var(--border-color);
}

.app-nav__item:hover,
.app-nav__item:focus {
  background-color: var(--brand-primary-soft) !important;
  border-color: var(--brand-primary-ring);
  color: var(--brand-primary) !important;
}

.app-nav__user-pill {
  height: 40px;
  padding: 4px 12px 4px 6px !important;
  background-color: var(--bg-subtle) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-pill) !important;
}

.app-nav__user-pill:hover,
.app-nav__user-pill[aria-expanded="true"] {
  background-color: var(--brand-primary-soft) !important;
  border-color: var(--brand-primary) !important;
}

.notif-dot {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--brand-primary);
  box-shadow: 0 0 0 2px var(--header-bg);
}

.app-nav .dropdown-menu {
  list-style: none;
  padding: 6px;
  margin-top: 8px !important;
  right: 0 !important;
  left: auto !important;
  min-width: 245px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
}

.app-nav .dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  transition: background-color var(--transition-fast);
}

.app-nav .dropdown-item i {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
}

.app-nav .dropdown-item:hover,
.app-nav .dropdown-item:focus {
  background-color: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.app-nav .dropdown-item.text-danger:hover {
  background-color: var(--st-danger-bg);
  color: var(--st-danger) !important;
}

/* ==========================================================================
   2. SIDEBAR IZQUIERDO Y MODO CONTRAÍDO (MINI SIDEBAR)
   ========================================================================== */
.app-sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg-1) 0%, var(--sidebar-bg-2) 100%) !important;
  width: var(--sidebar-width);
  padding-top: var(--header-height) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: none;
  transition: width var(--transition-base), left var(--transition-base);
}

.app-sidebar__user {
  padding: 14px 12px !important;
  margin: 0 10px 10px !important;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: all var(--transition-base);
}

.app-sidebar__user-avatar {
  width: 40px !important;
  height: 40px !important;
  margin-right: 12px !important;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.18);
  transition: all var(--transition-base);
}

.app-sidebar__user > div {
  overflow: hidden;
  width: 100%;
}

.app-sidebar__user-name {
  font-size: 0.86rem !important;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.25 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.app-sidebar__user-designation {
  font-size: 0.74rem !important;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
}

.app-menu {
  padding: 4px 10px 40px;
}

.app-menu__item {
  margin: 3px 0;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.76);
  border-left: 0 !important;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  transition: all var(--transition-fast);
}

.app-menu__item:hover,
.app-menu__item:focus {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
}

.app-menu__item.active {
  background: var(--brand-primary) !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.35);
}

.app-menu__icon {
  width: 24px;
  font-size: 0.98rem;
  margin-right: 8px;
  text-align: center;
  flex-shrink: 0;
}

.treeview-menu {
  margin: 2px 0 6px 16px;
  background: transparent !important;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
}

.treeview-item {
  margin: 2px 0 2px 8px;
  padding: 8px 12px;
  font-size: 0.83rem;
  color: rgba(255, 255, 255, 0.68);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.treeview-item:hover,
.treeview-item:focus {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
}

.treeview-item.active {
  background: rgba(20, 184, 166, 0.22) !important;
  color: #ffffff !important;
  font-weight: 600;
}

/* Sidebar Contraído en Desktop (.sidebar-mini.sidenav-toggled) */
@media (min-width: 768px) {
  .sidebar-mini.sidenav-toggled .app-header__logo {
    width: var(--sidebar-mini-width) !important;
    flex: 0 0 var(--sidebar-mini-width) !important;
    padding: 0 !important;
    justify-content: center !important;
  }

  .sidebar-mini.sidenav-toggled .app-header__logo span {
    display: none !important;
  }

  .sidebar-mini.sidenav-toggled .app-sidebar {
    width: var(--sidebar-mini-width) !important;
    overflow: visible !important;
  }

  .sidebar-mini.sidenav-toggled .app-content {
    margin-left: var(--sidebar-mini-width) !important;
  }

  .sidebar-mini.sidenav-toggled .app-sidebar__user {
    margin: 0 6px 10px !important;
    padding: 12px 0 !important;
    justify-content: center !important;
  }

  .sidebar-mini.sidenav-toggled .app-sidebar__user-avatar {
    width: 34px !important;
    height: 34px !important;
    margin-right: 0 !important;
  }

  .sidebar-mini.sidenav-toggled .app-sidebar__user > div {
    display: none !important;
  }

  .sidebar-mini.sidenav-toggled .app-menu {
    padding: 4px 8px 40px !important;
  }

  .sidebar-mini.sidenav-toggled .app-menu__item {
    padding: 11px 0 !important;
    justify-content: center !important;
    position: relative;
  }

  .sidebar-mini.sidenav-toggled .app-menu__icon {
    margin-right: 0 !important;
    width: auto !important;
    font-size: 1.08rem;
  }

  .sidebar-mini.sidenav-toggled .app-menu__label {
    left: var(--sidebar-mini-width) !important;
    top: 0;
    background: var(--sidebar-bg-2) !important;
    color: #ffffff !important;
    padding: 11px 16px !important;
    border-radius: 0 var(--radius-md) var(--radius-md) 0 !important;
    box-shadow: var(--shadow-md);
    font-weight: 600;
    z-index: 1050;
  }

  .sidebar-mini.sidenav-toggled .treeview-menu {
    left: var(--sidebar-mini-width) !important;
    background: var(--sidebar-bg-2) !important;
    margin: 0 !important;
    padding: 8px !important;
    border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 0 0 var(--radius-md) 0 !important;
    box-shadow: var(--shadow-md);
  }
}

/* ==========================================================================
   3. CONTENEDOR PRINCIPAL Y PAGE HEADER (.app-content y .app-title)
   ========================================================================== */
.app-content {
  background-color: var(--bg-body) !important;
  margin-top: var(--header-height) !important;
  padding: 24px 28px !important;
  min-height: calc(100vh - var(--header-height));
  transition: margin-left var(--transition-base), opacity var(--transition-fast);
}

@media (min-width: 768px) {
  .app-content {
    margin-left: var(--sidebar-width);
  }
}

.app-title {
  margin: 0 0 22px 0 !important;
  padding: 18px 22px !important;
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow) !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.app-title h1 {
  font-size: 1.25rem !important;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-title h1 > i {
  color: var(--brand-primary);
}

.app-title p {
  margin-top: 4px;
  margin-bottom: 0;
  font-size: 0.84rem;
  font-style: normal !important;
  color: var(--text-muted);
}

.app-breadcrumb {
  margin-bottom: 0;
  font-size: 0.82rem;
  background: transparent;
  padding: 0;
}

/* ==========================================================================
   4. TARJETAS, TILES, KPI METRIC CARDS Y VISTA DE PERFIL MODERNA
   ========================================================================== */
.tile {
  background-color: var(--bg-surface) !important;
  color: var(--text-main);
  border-radius: var(--radius-lg) !important;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow) !important;
  padding: 22px !important;
  margin-bottom: 24px;
}

.tile .tile-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 16px;
}

.tile .tile-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  margin-top: 16px;
}

.line-head {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  padding-bottom: 10px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
}

.st-profile-banner {
  background: linear-gradient(135deg, var(--sidebar-bg-1) 0%, var(--sidebar-bg-2) 55%, var(--brand-primary) 130%);
  border-radius: var(--radius-lg);
  padding: 28px;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.st-profile-avatar-lg {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  object-fit: cover;
  background-color: var(--bg-surface);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.st-profile-field-box {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  height: 100%;
}

.st-profile-field-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}

.st-profile-field-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0;
  word-break: break-word;
}

.kpi-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-primary-ring);
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 600;
}
.kpi-trend.up { background: var(--st-success-bg); color: var(--st-success); }
.kpi-trend.down { background: var(--st-danger-bg); color: var(--st-danger); }

.bg-primary-soft, .badge-primary-soft { background-color: var(--brand-primary-soft) !important; color: var(--brand-primary) !important; }
.bg-success-soft, .badge-success-soft { background-color: var(--st-success-bg) !important; color: var(--st-success) !important; }
.bg-info-soft, .badge-info-soft { background-color: var(--st-info-bg) !important; color: var(--st-info) !important; }
.bg-warning-soft, .badge-warning-soft { background-color: var(--st-warning-bg) !important; color: var(--st-warning) !important; }
.bg-danger-soft, .badge-danger-soft { background-color: var(--st-danger-bg) !important; color: var(--st-danger) !important; }

/* ==========================================================================
   5. BOTONES, LOADERS DE BOTÓN Y FORMULARIOS
   ========================================================================== */
.btn {
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 8px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.btn-sm {
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 6px;
}

.btn-primary {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  color: #ffffff !important;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--brand-primary-hover) !important;
  border-color: var(--brand-primary-hover) !important;
}

.btn-outline-primary {
  color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
}
.btn-outline-primary:hover {
  background-color: var(--brand-primary) !important;
  color: #ffffff !important;
}

.btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
  position: relative;
}

.btn.is-loading .btn-spinner-inline {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: st-spin 0.7s linear infinite;
  display: inline-block;
}

.form-control {
  height: 40px;
  padding: 8px 12px;
  font-size: 0.88rem;
  color: var(--text-main);
  background-color: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  color: var(--text-main);
  background-color: var(--input-bg);
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-ring);
}

.form-control[readonly],
.form-control:disabled {
  background-color: var(--bg-subtle) !important;
  color: var(--text-muted) !important;
  border-color: var(--border-color);
}

label, .control-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.required { color: var(--st-danger); }

/* ==========================================================================
   6. FILTER PANEL Y BARRA DE BÚSQUEDA ENTERPRISE
   ========================================================================== */
.st-filter-panel {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.st-filter-group {
  flex: 1 1 180px;
  min-width: 160px;
}

.st-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.has-st-filter-panel .dataTables_filter {
  display: none !important;
}

/* ==========================================================================
   7. TABLAS ENTERPRISE Y DATATABLES
   ========================================================================== */
.table {
  color: var(--text-main);
  margin-bottom: 0;
}

.table thead th,
.thead-light th {
  background-color: var(--bg-subtle) !important;
  color: var(--text-muted) !important;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color) !important;
  border-top: 0 !important;
  padding: 12px 14px;
  vertical-align: middle;
}

.table td {
  padding: 12px 14px;
  vertical-align: middle !important;
  border-top: 1px solid var(--border-color) !important;
  font-size: 0.88rem;
  color: var(--text-main);
}

.table-hover tbody tr:hover {
  background-color: var(--brand-primary-soft) !important;
}

.table-bordered,
.table-bordered td,
.table-bordered th {
  border-color: var(--border-color) !important;
}

.dataTables_wrapper .dt-buttons {
  margin-top: 6px;
  margin-bottom: 12px;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  height: 36px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background-color: var(--input-bg);
  color: var(--text-main);
}

/* ==========================================================================
   8. BADGES SEMÁNTICOS
   ========================================================================== */
.badge {
  padding: 5px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  letter-spacing: 0.015em;
}

.badge-success { background-color: var(--st-success-bg) !important; color: var(--st-success) !important; border: 1px solid var(--st-success-border); }
.badge-danger  { background-color: var(--st-danger-bg) !important; color: var(--st-danger) !important; border: 1px solid var(--st-danger-border); }
.badge-warning { background-color: var(--st-warning-bg) !important; color: var(--st-warning) !important; border: 1px solid var(--st-warning-border); }
.badge-info    { background-color: var(--st-info-bg) !important; color: var(--st-info) !important; border: 1px solid var(--st-info-border); }
.badge-secondary { background-color: var(--bg-subtle) !important; color: var(--text-secondary) !important; border: 1px solid var(--border-color); }

/* ==========================================================================
   9. MODALES PROFESIONALES
   ========================================================================== */
.modal-content {
  background-color: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-color);
  align-items: center;
}

.headerRegister {
  background: linear-gradient(135deg, var(--sidebar-bg-1), var(--brand-primary)) !important;
  color: #ffffff !important;
}

.headerUpdate {
  background: linear-gradient(135deg, #0369a1, #0284c7) !important;
  color: #ffffff !important;
}

.header-primary {
  background: linear-gradient(135deg, var(--sidebar-bg-1), var(--sidebar-bg-2)) !important;
  color: #ffffff !important;
}

.modal-header .modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: inherit;
}

.modal-header .close {
  color: #ffffff !important;
  opacity: 0.85;
  text-shadow: none;
}

.modal-footer {
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  padding: 14px 22px;
}

/* ==========================================================================
   10. SKELETON LOADERS, BARRA SPA, ESTADOS Y TOASTS
   ========================================================================== */
#spaProgressBar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-primary), #38bdf8);
  z-index: 99999;
  transition: width 0.25s ease, opacity 0.2s ease;
  box-shadow: 0 0 10px var(--brand-primary);
  pointer-events: none;
}

.st-skeleton {
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-highlight) 50%, var(--skeleton-base) 75%);
  background-size: 200% 100%;
  animation: st-shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
  display: inline-block;
  width: 100%;
}

.st-skeleton-title { height: 22px; width: 45%; margin-bottom: 12px; }
.st-skeleton-text  { height: 14px; width: 100%; margin-bottom: 8px; }
.st-skeleton-kpi   { height: 110px; border-radius: var(--radius-lg); }
.st-skeleton-row   { height: 42px; margin-bottom: 8px; border-radius: var(--radius-sm); }

@keyframes st-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes st-spin {
  to { transform: rotate(360deg); }
}

.st-state-box {
  text-align: center;
  padding: 40px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background-color: var(--bg-subtle);
}

.st-state-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background-color: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.st-state-box.is-error .st-state-icon {
  background-color: var(--st-danger-bg);
  color: var(--st-danger);
}

#stToastContainer {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 10999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100vw - 40px);
  pointer-events: none;
}

.st-toast {
  pointer-events: auto;
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--brand-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: st-toast-in 0.25s ease forwards;
}

.st-toast.toast-success { border-left-color: var(--st-success); }
.st-toast.toast-error   { border-left-color: var(--st-danger); }
.st-toast.toast-warning { border-left-color: var(--st-warning); }
.st-toast.toast-info    { border-left-color: var(--st-info); }

.st-toast__icon { font-size: 1.15rem; margin-top: 2px; }
.st-toast.toast-success .st-toast__icon { color: var(--st-success); }
.st-toast.toast-error   .st-toast__icon { color: var(--st-danger); }
.st-toast.toast-warning .st-toast__icon { color: var(--st-warning); }
.st-toast.toast-info    .st-toast__icon { color: var(--st-info); }

.st-toast__body { flex: 1; min-width: 0; }
.st-toast__title { font-weight: 700; font-size: 0.88rem; margin-bottom: 2px; color: var(--text-main); }
.st-toast__msg   { font-size: 0.82rem; color: var(--text-muted); margin: 0; }
.st-toast__close {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px;
}

@keyframes st-toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   11. CORRECCIONES INTEGRALES PARA MODO OSCURO
   ========================================================================== */
html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .modalPermisos strong {
  color: var(--text-main) !important;
}

html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .modalPermisos thead tr {
  background-color: var(--bg-subtle) !important;
  color: var(--text-main) !important;
}

html[data-theme="dark"] .dropdown-menu {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
}

html[data-theme="dark"] .dropdown-item {
  color: var(--text-main);
}

html[data-theme="dark"] .dropdown-item:hover {
  background-color: var(--bg-subtle);
}

html[data-theme="dark"] .bootstrap-select > .dropdown-toggle {
  background-color: var(--input-bg) !important;
  color: var(--text-main) !important;
  border-color: var(--border-strong) !important;
}

html[data-theme="dark"] .sweet-alert {
  background-color: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-strong);
}
html[data-theme="dark"] .sweet-alert h2 { color: var(--text-main) !important; }
html[data-theme="dark"] .sweet-alert p  { color: var(--text-muted) !important; }

/* ==========================================================================
   12. OVERLAY DE CARGA Y UTILIDADES DE CONFIGURACIÓN (LOGO + FAVICON)
   ========================================================================== */
#divLoading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.loading-spinner-box {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 20px 32px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow-lg);
}

.notBlock { display: none !important; }

.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--brand-primary-soft);
  color: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.prevPhoto {
  position: relative;
  width: 145px;
  height: 145px;
  margin: 0 auto;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-subtle);
}

.prevPhoto.prevFavicon {
  width: 84px;
  height: 84px;
  border-radius: var(--radius-md);
}

.prevPhoto img { max-width: 100%; max-height: 100%; object-fit: contain; padding: 6px; }

.delPhoto, .delFavicon {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #ef4444;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  z-index: 2;
}
.input-hidden { display: none; }
.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--brand-primary);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background var(--transition-fast);
}
.btn-upload:hover {
  background: var(--brand-primary-hover);
  color: #fff;
}
.tech-container { display: flex; gap: 10px; flex-wrap: wrap; }
.tech-item input[type="checkbox"] { display: none; }
.tech-label {
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-subtle);
  transition: all var(--transition-fast);
  margin-bottom: 0;
}
.tech-item input[type="checkbox"]:checked + .tech-label {
  background-color: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}

/* ==========================================================================
   13. EXPERIENCIA MOBILE-FIRST (< 768px): HEADER, DROPDOWNS, MODALES Y TARJETAS
   ========================================================================== */
@media (max-width: 767.98px) {
  .app .app-sidebar {
    left: -260px !important;
    width: 250px !important;
    box-shadow: none !important;
  }

  .app.sidenav-toggled .app-sidebar {
    left: 0 !important;
    box-shadow: 12px 0 35px rgba(2, 6, 23, 0.55) !important;
  }

  .app.sidenav-toggled .app-sidebar__overlay {
    background: rgba(2, 6, 23, 0.5);
    backdrop-filter: blur(2px);
  }

  .app-content {
    margin-left: 0 !important;
    padding: 12px 10px !important;
  }

  /* 1. Topbar Móvil Unificada */
  .app-header {
    padding: 0 10px !important;
    background-color: var(--header-bg) !important;
    justify-content: flex-start !important;
    gap: 6px;
  }

  .app-sidebar__toggle {
    order: -1;
    margin-left: 0 !important;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-color);
  }

  .app-header__logo {
    background-color: transparent !important;
    color: var(--text-main) !important;
    border-right: 0 !important;
    padding: 0 4px !important;
    width: auto !important;
    flex: 1 1 auto !important;
    min-width: 0;
    justify-content: flex-start !important;
    gap: 8px;
  }

  .app-header__logo span {
    font-size: 0.92rem !important;
    font-weight: 800;
    color: var(--text-main) !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-nav {
    gap: 6px !important;
    flex: 0 0 auto !important;
  }

  .app-nav__item.icon-btn {
    width: 34px;
    height: 34px;
  }

  .app-nav__user-pill {
    height: 34px;
    padding: 2px 8px 2px 4px !important;
  }

  /* 2. Dropdowns del Topbar centrados en pantalla móvil */
  .app-nav .dropdown {
    position: static !important;
  }

  .app-nav .dropdown-menu {
    position: fixed !important;
    top: calc(var(--header-height) + 6px) !important;
    right: 12px !important;
    left: 12px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: calc(100vw - 24px) !important;
    transform: none !important;
    margin-top: 0 !important;
    z-index: 1060 !important;
  }

  /* 3. PageHeader (.app-title) con botones táctiles al 100% de ancho */
  .app-title {
    padding: 14px !important;
    margin-bottom: 14px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .app-title h1 {
    font-size: 1.06rem !important;
    line-height: 1.3;
  }

  .app-title > div:last-child {
    width: 100% !important;
    justify-content: stretch !important;
  }

  .app-title > div:last-child > div,
  .app-title > div:last-child > .btn {
    width: 100% !important;
  }

  .app-title > div:last-child > div .btn {
    flex: 1 1 auto !important;
    justify-content: center !important;
  }

  .tile {
    padding: 14px 12px !important;
    border-radius: 12px !important;
    margin-bottom: 16px !important;
  }

  /* 4. Panel de Filtros y Botones de Exportación en Cuadrícula 2x2 */
  .st-filter-panel {
    padding: 12px;
    gap: 10px;
  }

  .st-filter-group {
    flex: 1 1 100%;
    max-width: 100% !important;
  }

  .st-filter-actions,
  .st-filter-actions .btn {
    width: 100%;
  }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    text-align: center !important;
    float: none !important;
    width: 100%;
  }

  .dataTables_wrapper .dt-buttons {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
    gap: 6px;
    margin-bottom: 12px;
  }

  .dataTables_wrapper .dt-buttons .btn {
    margin: 0 !important;
    width: 100%;
  }

  /* 5. Todas las Tablas convertidas en Tarjetas Móviles Perfectamente Alineadas */
  .table-responsive {
    border: 0 !important;
    overflow-x: visible !important;
  }

  table.dataTable.st-mobile-cards,
  .table.st-mobile-cards {
    border: 0 !important;
    width: 100% !important;
  }

  table.dataTable.st-mobile-cards thead,
  .table.st-mobile-cards thead {
    display: none !important;
  }

  table.dataTable.st-mobile-cards tbody tr,
  .table.st-mobile-cards tbody tr {
    display: block;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-strong) !important;
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 8px 12px;
    box-shadow: var(--card-shadow);
  }

  table.dataTable.st-mobile-cards tbody td,
  .table.st-mobile-cards tbody td {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    text-align: right !important;
    padding: 8px 4px !important;
    border: 0 !important;
    border-bottom: 1px dashed var(--border-color) !important;
    font-size: 0.85rem;
    gap: 10px;
    width: 100% !important;
    box-sizing: border-box !important;
    word-break: break-word;
  }

  table.dataTable.st-mobile-cards tbody td:last-child,
  .table.st-mobile-cards tbody td:last-child {
    border-bottom: 0 !important;
    padding-top: 10px !important;
    justify-content: space-between !important;
    flex-wrap: wrap;
  }

  table.dataTable.st-mobile-cards tbody td::before,
  .table.st-mobile-cards tbody td::before {
    content: attr(data-label);
    font-size: 0.71rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-align: left;
    flex: 0 0 36%;
    max-width: 40%;
    line-height: 1.25;
  }

  /* Contenedor de botones de acción dentro de la última celda móvil */
  table.dataTable.st-mobile-cards tbody td:last-child > div,
  .table.st-mobile-cards tbody td:last-child > div {
    margin-left: auto !important;
    justify-content: flex-end !important;
    flex-wrap: wrap !important;
    gap: 5px !important;
  }

  /* Celdas vacías (Sin registros) centradas a ancho completo sin etiqueta lateral */
  table.dataTable.st-mobile-cards tbody td.dataTables_empty,
  .table.st-mobile-cards tbody td[colspan] {
    display: block !important;
    text-align: center !important;
    width: 100% !important;
    padding: 18px 8px !important;
  }

  table.dataTable.st-mobile-cards tbody td.dataTables_empty::before,
  .table.st-mobile-cards tbody td[colspan]::before {
    display: none !important;
    content: none !important;
  }

  /* 6. Modales y Botones de Formulario adaptados a pantallas pequeñas */
  .modal-dialog {
    margin: 8px !important;
    max-width: calc(100vw - 16px) !important;
  }

  .modal-header {
    padding: 13px 16px !important;
  }

  .modal-body {
    padding: 16px 14px !important;
  }

  .modal-body .tile-footer,
  .modal-footer {
    flex-direction: column-reverse !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .modal-body .tile-footer .btn,
  .modal-footer .btn {
    width: 100% !important;
    margin: 0 !important;
    padding: 10px 14px !important;
  }
}