
      :root {
        --azul-gde: #0056A4;
        --azul-oscuro: #003d75;
        --azul-claro: #e8f1f8;
        --gris-100: #f5f7fa;
        --gris-200: #e9ecef;
        --gris-300: #dee2e6;
        --gris-500: #6c757d;
        --gris-700: #343a40;
        --verde: #28a745;
        --naranja: #fd7e14;
        --rojo: #dc3545;
        --blanco: #ffffff;
        --sombra: 0 2px 8px rgba(0, 0, 0, 0.08);
        --radio: 6px;
        --transicion: 0.2s ease;
      }

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

      body {
        font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        background: var(--gris-100);
        color: var(--gris-700);
        display: flex;
        height: 100vh;
        overflow: hidden;
      }

      /* ========== SIDEBAR ========== */
      .sidebar {
        width: 280px;
        background: var(--azul-gde);
        color: white;
        display: flex;
        flex-direction: column;
        transition: width var(--transicion);
        flex-shrink: 0;
        z-index: 100;
      }

      .sidebar.collapsed {
        width: 64px;
      }

      .sidebar.collapsed .nav-text,
      .sidebar.collapsed .sidebar-header h1,
      .sidebar.collapsed .sidebar-footer span {
        display: none;
      }

      .sidebar.collapsed .nav-item {
        justify-content: center;
        padding: 14px 0;
      }

      .sidebar-header {
        padding: 18px 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        display: flex;
        align-items: center;
        gap: 12px;
      }

      .sidebar-header h1 {
        font-size: 15px;
        font-weight: 600;
        line-height: 1.3;
      }

      .logo-icon {
        width: 32px;
        height: 32px;
        background: white;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
      }

      .logo-icon svg {
        width: 20px;
        height: 20px;
        fill: var(--azul-gde);
      }

      .nav {
        flex: 1;
        overflow-y: auto;
        padding: 12px 0;
      }

      .nav-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 11px 18px;
        cursor: pointer;
        transition: background var(--transicion);
        font-size: 13.5px;
        border-left: 3px solid transparent;
      }

      .nav-item:hover {
        background: rgba(255, 255, 255, 0.1);
      }

      .nav-item.active {
        background: rgba(255, 255, 255, 0.18);
        border-left-color: white;
        font-weight: 600;
      }

      .nav-item svg {
        width: 18px;
        height: 18px;
        fill: currentColor;
        flex-shrink: 0;
      }

      .nav-section-title {
        padding: 16px 18px 6px;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        opacity: 0.65;
        font-weight: 600;
      }

      .sidebar.collapsed .nav-section-title {
        display: none;
      }

      .sidebar-footer {
        padding: 14px 16px;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        font-size: 12px;
        display: flex;
        align-items: center;
        gap: 10px;
      }

      /* ========== MAIN ========== */
      .main {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }

      /* Top bar */
      .topbar {
        background: white;
        border-bottom: 1px solid var(--gris-200);
        padding: 0 24px;
        height: 56px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
      }

      .topbar-left {
        display: flex;
        align-items: center;
        gap: 16px;
      }

      .btn-toggle {
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        border-radius: var(--radio);
        display: flex;
        align-items: center;
      }

      .btn-toggle:hover {
        background: var(--gris-100);
      }

      .btn-toggle svg {
        width: 22px;
        height: 22px;
        fill: var(--gris-700);
      }

      .breadcrumb {
        font-size: 14px;
        color: var(--gris-500);
      }

      .breadcrumb strong {
        color: var(--gris-700);
      }

      .alcance-panel {
        background: var(--azul-claro);
        border: 1px solid #b8d4e8;
        border-radius: var(--radio);
        padding: 6px 14px;
        font-size: 12.5px;
        display: flex;
        align-items: center;
        gap: 8px;
      }

      .alcance-panel .badge-alcance {
        font-size: 11px;
      }

      /* Content */
      .content {
        flex: 1;
        overflow-y: auto;
        padding: 24px;
      }

      .panel {
        display: none;
      }

      .panel.active {
        display: block;
      }

      .page-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 24px;
      }

      .page-header h2 {
        font-size: 22px;
        font-weight: 600;
        color: var(--azul-oscuro);
      }

      .page-header p {
        font-size: 13.5px;
        color: var(--gris-500);
        margin-top: 4px;
      }

      /* Cards */
      .card {
        background: white;
        border-radius: var(--radio);
        box-shadow: var(--sombra);
        border: 1px solid var(--gris-200);
        margin-bottom: 20px;
      }

      .card-header {
        padding: 14px 20px;
        border-bottom: 1px solid var(--gris-200);
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-weight: 600;
        font-size: 14.5px;
      }

      .card-body {
        padding: 20px;
      }

      /* Buttons */
      .btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 8px 16px;
        border-radius: var(--radio);
        font-size: 13.5px;
        font-weight: 500;
        cursor: pointer;
        border: 1px solid transparent;
        transition: all var(--transicion);
      }

      .btn svg {
        width: 16px;
        height: 16px;
        fill: currentColor;
      }

      .btn-primary {
        background: var(--azul-gde);
        color: white;
      }

      .btn-primary:hover {
        background: var(--azul-oscuro);
      }

      .btn-secondary {
        background: white;
        border-color: var(--gris-300);
        color: var(--gris-700);
      }

      .btn-secondary:hover {
        background: var(--gris-100);
      }

      .btn-success {
        background: var(--verde);
        color: white;
      }

      .btn-success:hover {
        background: #218838;
      }

      .btn-sm {
        padding: 5px 10px;
        font-size: 12.5px;
      }

      .btn-danger {
        background: white;
        border-color: var(--rojo);
        color: var(--rojo);
      }

      .btn-danger:hover {
        background: #f8d7da;
      }

      /* Forms */
      .form-group {
        margin-bottom: 16px;
      }

      .form-group label {
        display: block;
        font-size: 13px;
        font-weight: 500;
        margin-bottom: 5px;
      }

      .form-control {
        width: 100%;
        padding: 8px 12px;
        border: 1px solid var(--gris-300);
        border-radius: var(--radio);
        font-size: 13.5px;
        transition: border-color var(--transicion);
      }

      .form-control:focus {
        outline: none;
        border-color: var(--azul-gde);
        box-shadow: 0 0 0 3px rgba(0, 86, 164, 0.15);
      }

      select.form-control {
        appearance: auto;
      }

      .search-box {
        display: flex;
        gap: 10px;
        margin-bottom: 20px;
      }

      .search-box input {
        flex: 1;
      }

      /* Table */
      .table-wrap {
        overflow-x: auto;
      }

      table {
        width: 100%;
        border-collapse: collapse;
        font-size: 13.5px;
      }

      th {
        text-align: left;
        padding: 10px 14px;
        background: var(--gris-100);
        font-weight: 600;
        font-size: 12.5px;
        color: var(--gris-500);
        border-bottom: 1px solid var(--gris-200);
        white-space: nowrap;
      }

      td {
        padding: 12px 14px;
        border-bottom: 1px solid var(--gris-200);
        vertical-align: middle;
      }

      tr:hover td {
        background: #fafbfc;
      }

      /* Badges */
      .badge {
        display: inline-block;
        padding: 3px 9px;
        border-radius: 20px;
        font-size: 11.5px;
        font-weight: 600;
        white-space: nowrap;
      }

      .badge-global {
        background: #f8d7da;
        color: #721c24;
      }

      .badge-jurisdiccional {
        background: #fff3cd;
        color: #856404;
      }

      .badge-ambito {
        background: #cce5ff;
        color: #004085;
      }

      .badge-completo {
        background: #d4edda;
        color: #155724;
      }

      .badge-lectura {
        background: #e2e3e5;
        color: #383d41;
      }

      .badge-funcion {
        background: var(--azul-claro);
        color: var(--azul-gde);
        border: 1px solid #b8d4e8;
      }

      /* User card */
      .user-info-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 16px;
        margin-bottom: 8px;
      }

      .user-info-item label {
        font-size: 12px;
        color: var(--gris-500);
        display: block;
      }

      .user-info-item span {
        font-size: 14.5px;
        font-weight: 500;
      }

      /* Permission catalog */
      .perm-catalog {
        max-height: 320px;
        overflow-y: auto;
        border: 1px solid var(--gris-200);
        border-radius: var(--radio);
      }

      .perm-item {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 16px;
        border-bottom: 1px solid var(--gris-200);
      }

      .perm-item:last-child {
        border-bottom: none;
      }

      .perm-item:hover {
        background: var(--gris-100);
      }

      .perm-item input[type="checkbox"] {
        margin-top: 3px;
        width: 16px;
        height: 16px;
        accent-color: var(--azul-gde);
      }

      .perm-item-info {
        flex: 1;
      }

      .perm-item-name {
        font-weight: 500;
        font-size: 13.5px;
      }

      .perm-item-desc {
        font-size: 12.5px;
        color: var(--gris-500);
        margin-top: 2px;
      }

      .perm-item-controls {
        display: flex;
        gap: 8px;
        align-items: center;
        flex-shrink: 0;
      }

      .perm-item-controls select {
        font-size: 12px;
        padding: 4px 6px;
        border-radius: 4px;
        border: 1px solid var(--gris-300);
      }

      /* Templates */
      .templates-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 16px;
      }

      /* Tooltip */
      .tooltip-wrap {
        position: relative;
        display: inline-flex;
        cursor: help;
      }

      .tooltip-wrap .tooltip-icon {
        width: 15px;
        height: 15px;
        fill: var(--gris-500);
        margin-left: 4px;
      }

      .tooltip-wrap:hover .tooltip-text {
        visibility: visible;
        opacity: 1;
      }

      .tooltip-text {
        visibility: hidden;
        opacity: 0;
        position: absolute;
        bottom: 125%;
        left: 50%;
        transform: translateX(-50%);
        background: var(--gris-700);
        color: white;
        padding: 8px 12px;
        border-radius: 4px;
        font-size: 12px;
        width: 260px;
        z-index: 50;
        transition: opacity 0.15s;
        pointer-events: none;
        line-height: 1.4;
      }

      .tooltip-text::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 50%;
        margin-left: -5px;
        border: 5px solid transparent;
        border-top-color: var(--gris-700);
      }

      /* Tabs */
      .tabs {
        display: flex;
        border-bottom: 1px solid var(--gris-200);
        margin-bottom: 20px;
      }

      .tab {
        padding: 10px 18px;
        font-size: 13.5px;
        cursor: pointer;
        border-bottom: 2px solid transparent;
        color: var(--gris-500);
        font-weight: 500;
      }

      .tab:hover {
        color: var(--azul-gde);
      }

      .tab.active {
        color: var(--azul-gde);
        border-bottom-color: var(--azul-gde);
      }

      /* Modal */
      .modal-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 200;
        align-items: center;
        justify-content: center;
      }

      .modal-overlay.show {
        display: flex;
      }

      .modal {
        background: white;
        border-radius: 8px;
        width: 90%;
        max-width: 520px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
        max-height: 90vh;
        overflow-y: auto;
      }

      .modal-header {
        padding: 16px 20px;
        border-bottom: 1px solid var(--gris-200);
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

      .modal-header h3 {
        font-size: 16px;
      }

      .modal-close {
        background: none;
        border: none;
        cursor: pointer;
        font-size: 22px;
        line-height: 1;
        color: var(--gris-500);
      }

      .modal-body {
        padding: 20px;
      }

      .modal-footer {
        padding: 14px 20px;
        border-top: 1px solid var(--gris-200);
        display: flex;
        justify-content: flex-end;
        gap: 10px;
      }

      /* Toast */
      .toast {
        position: fixed;
        bottom: 28px;
        right: 28px;
        background: var(--gris-700);
        color: white;
        padding: 12px 20px;
        border-radius: var(--radio);
        font-size: 14px;
        display: none;
        align-items: center;
        gap: 10px;
        z-index: 300;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
      }

      .toast.show {
        display: flex;
      }

      .toast.success {
        background: var(--verde);
      }

      /* Pagination */
      .pagination {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 16px;
        font-size: 13px;
        color: var(--gris-500);
      }

      .pagination-btns {
        display: flex;
        gap: 6px;
      }

      /* Empty / placeholder panels */
      .placeholder {
        text-align: center;
        padding: 60px 20px;
        color: var(--gris-500);
      }

      .placeholder svg {
        width: 48px;
        height: 48px;
        fill: var(--gris-300);
        margin-bottom: 12px;
      }

      /* Audit table */
      .audit-time {
        font-size: 12px;
        color: var(--gris-500);
      }

      /* Responsive */
      @media (max-width: 900px) {
        .sidebar {
          position: absolute;
          height: 100%;
        }

        .sidebar.collapsed {
          width: 0;
          overflow: hidden;
        }

        .user-info-grid {
          grid-template-columns: 1fr 1fr;
        }
      }

      @media (max-width: 600px) {
        .content {
          padding: 16px;
        }

        .user-info-grid {
          grid-template-columns: 1fr;
        }

        .search-box {
          flex-direction: column;
        }

        .perm-item {
          flex-direction: column;
        }

        .perm-item-controls {
          width: 100%;
        }
      }
    
/* ========== FUNCIÓN COMO ADMINISTRADOR (tags) ========== */
.funcion-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  min-height: 24px;
}

.funcion-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 12px;
}

.funcion-tag .tag-remove {
  background: rgba(0, 86, 164, 0.15);
  border: none;
  color: var(--azul-gde);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.funcion-tag .tag-remove:hover {
  background: rgba(0, 86, 164, 0.3);
}

.funcion-agregar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  max-width: 320px;
}

.funcion-agregar select {
  flex: 1;
}

/* ========== AGRUPACIÓN POR CATEGORÍA (tabla de permisos asignados) ========== */
.grupo-label {
  padding: 8px 16px;
  background: var(--gris-100);
  font-size: 12px;
  font-weight: 600;
  color: var(--azul-gde);
}

tr.grupo-row:hover td {
  background: var(--gris-100);
}
